Merge lp:~3v1n0/unity/memory-fixes into lp:unity
- memory-fixes
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Marco Trevisan (Treviño) |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3432 |
Proposed branch: | lp:~3v1n0/unity/memory-fixes |
Merge into: | lp:unity |
Diff against target: |
1149 lines (+323/-284) 22 files modified
UnityCore/Model-inl.h (+3/-3) dash/previews/TabIterator.cpp (+6/-9) dash/previews/TabIterator.h (+3/-2) debian/changelog (+4/-2) debian/control (+1/-1) launcher/Launcher.cpp (+1/-0) launcher/TrashLauncherIcon.cpp (+1/-0) tests/test_filter_multirange.h (+8/-12) tests/test_glib_signals.cpp (+3/-4) tests/test_grabhandle.cpp (+6/-9) tests/test_icon_loader.cpp (+54/-44) tests/test_launcher_entry_remote.cpp (+1/-0) tests/test_preview_player.cpp (+1/-1) tests/test_previews.cpp (+6/-1) tests/test_quicklist_menu_item.cpp (+2/-0) tests/test_scope.cpp (+8/-2) tests/test_session_controller.cpp (+1/-1) tests/test_tabiterator.cpp (+209/-190) tests/test_time_util.cpp (+1/-1) tests/test_xdnd_manager_imp.cpp (+1/-0) unity-shared/PlacesOverlayVScrollBar.cpp (+1/-1) unity-shared/PlacesOverlayVScrollBar.h (+2/-1) |
To merge this branch: | bzr merge lp:~3v1n0/unity/memory-fixes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Brandon Schaefer (community) | Approve | ||
Review via email: mp+175703@code.launchpad.net |
Commit message
Unity: improve the correctness of the memory usage of various components
Thanks to valgrind...
Description of the change
Fix various read/write errors or leaks found through valgrind that should prevent crashes during tests or runtime.
Bumping ABI as requested by lp:~3v1n0/nux/memory-fixes
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3451
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'UnityCore/Model-inl.h' | |||
2 | --- UnityCore/Model-inl.h 2013-05-17 22:53:57 +0000 | |||
3 | +++ UnityCore/Model-inl.h 2013-07-18 23:02:25 +0000 | |||
4 | @@ -44,9 +44,9 @@ | |||
5 | 44 | void Model<RowAdaptor>::Init () | 44 | void Model<RowAdaptor>::Init () |
6 | 45 | { | 45 | { |
7 | 46 | swarm_name.changed.connect(sigc::mem_fun(this, &Model<RowAdaptor>::OnSwarmNameChanged)); | 46 | swarm_name.changed.connect(sigc::mem_fun(this, &Model<RowAdaptor>::OnSwarmNameChanged)); |
11 | 47 | count.SetGetterFunction(sigc::mem_fun(this, &Model<RowAdaptor>::get_count)); | 47 | count.SetGetterFunction(std::bind(&Model<RowAdaptor>::get_count, this)); |
12 | 48 | seqnum.SetGetterFunction(sigc::mem_fun(this, &Model<RowAdaptor>::get_seqnum)); | 48 | seqnum.SetGetterFunction(std::bind(&Model<RowAdaptor>::get_seqnum, this)); |
13 | 49 | model.SetGetterFunction(sigc::mem_fun(this, &Model<RowAdaptor>::get_model)); | 49 | model.SetGetterFunction(std::bind(&Model<RowAdaptor>::get_model, this)); |
14 | 50 | } | 50 | } |
15 | 51 | 51 | ||
16 | 52 | template<class RowAdaptor> | 52 | template<class RowAdaptor> |
17 | 53 | 53 | ||
18 | === modified file 'dash/previews/TabIterator.cpp' | |||
19 | --- dash/previews/TabIterator.cpp 2013-01-22 11:25:38 +0000 | |||
20 | +++ dash/previews/TabIterator.cpp 2013-07-18 23:02:25 +0000 | |||
21 | @@ -32,10 +32,7 @@ | |||
22 | 32 | 32 | ||
23 | 33 | void TabIterator::Remove(nux::InputArea* area) | 33 | void TabIterator::Remove(nux::InputArea* area) |
24 | 34 | { | 34 | { |
29 | 35 | std::list<nux::InputArea*>::iterator it = std::find(areas_.begin(), areas_.end(), | 35 | areas_.remove(area); |
26 | 36 | area); | ||
27 | 37 | if (it != areas_.end()) | ||
28 | 38 | areas_.erase(it); | ||
30 | 39 | } | 36 | } |
31 | 40 | 37 | ||
32 | 41 | void TabIterator::Prepend(nux::InputArea* area) | 38 | void TabIterator::Prepend(nux::InputArea* area) |
33 | @@ -50,11 +47,11 @@ | |||
34 | 50 | areas_.push_back(area); | 47 | areas_.push_back(area); |
35 | 51 | } | 48 | } |
36 | 52 | 49 | ||
38 | 53 | void TabIterator::Insert(nux::InputArea* area, int index) | 50 | void TabIterator::Insert(nux::InputArea* area, unsigned index) |
39 | 54 | { | 51 | { |
40 | 55 | Remove(area); | 52 | Remove(area); |
41 | 56 | std::list<nux::InputArea*>::iterator it = areas_.begin(); | 53 | std::list<nux::InputArea*>::iterator it = areas_.begin(); |
43 | 57 | if ((uint)index < areas_.size()) | 54 | if (index < areas_.size()) |
44 | 58 | { | 55 | { |
45 | 59 | std::advance(it, index); | 56 | std::advance(it, index); |
46 | 60 | areas_.insert(it, area); | 57 | areas_.insert(it, area); |
47 | @@ -126,12 +123,12 @@ | |||
48 | 126 | if (direction == nux::KEY_NAV_TAB_PREVIOUS) | 123 | if (direction == nux::KEY_NAV_TAB_PREVIOUS) |
49 | 127 | { | 124 | { |
50 | 128 | if (it == areas_.begin()) | 125 | if (it == areas_.begin()) |
52 | 129 | return *areas_.end(); | 126 | return *areas_.rbegin(); |
53 | 130 | else | 127 | else |
54 | 131 | { | 128 | { |
55 | 132 | it--; | 129 | it--; |
56 | 133 | if (it == areas_.begin()) | 130 | if (it == areas_.begin()) |
58 | 134 | return *areas_.end(); | 131 | return *areas_.rbegin(); |
59 | 135 | return *it; | 132 | return *it; |
60 | 136 | } | 133 | } |
61 | 137 | } | 134 | } |
62 | @@ -156,7 +153,7 @@ | |||
63 | 156 | { | 153 | { |
64 | 157 | if (direction == nux::KEY_NAV_TAB_PREVIOUS) | 154 | if (direction == nux::KEY_NAV_TAB_PREVIOUS) |
65 | 158 | { | 155 | { |
67 | 159 | return *areas_.end(); | 156 | return *areas_.rbegin(); |
68 | 160 | } | 157 | } |
69 | 161 | else if (direction == nux::KEY_NAV_TAB_NEXT) | 158 | else if (direction == nux::KEY_NAV_TAB_NEXT) |
70 | 162 | { | 159 | { |
71 | 163 | 160 | ||
72 | === modified file 'dash/previews/TabIterator.h' | |||
73 | --- dash/previews/TabIterator.h 2013-01-22 11:54:25 +0000 | |||
74 | +++ dash/previews/TabIterator.h 2013-07-18 23:02:25 +0000 | |||
75 | @@ -41,7 +41,7 @@ | |||
76 | 41 | 41 | ||
77 | 42 | void Prepend(nux::InputArea* area); | 42 | void Prepend(nux::InputArea* area); |
78 | 43 | void Append(nux::InputArea* area); | 43 | void Append(nux::InputArea* area); |
80 | 44 | void Insert(nux::InputArea* area, int index); | 44 | void Insert(nux::InputArea* area, unsigned index); |
81 | 45 | void InsertBefore(nux::InputArea* area, nux::InputArea* after); | 45 | void InsertBefore(nux::InputArea* area, nux::InputArea* after); |
82 | 46 | void InsertAfter(nux::InputArea* area, nux::InputArea* before); | 46 | void InsertAfter(nux::InputArea* area, nux::InputArea* before); |
83 | 47 | void Remove(nux::InputArea* area); | 47 | void Remove(nux::InputArea* area); |
84 | @@ -53,7 +53,8 @@ | |||
85 | 53 | unsigned long special_keys_state); | 53 | unsigned long special_keys_state); |
86 | 54 | nux::Area* KeyNavIteration(nux::KeyNavDirection direction); | 54 | nux::Area* KeyNavIteration(nux::KeyNavDirection direction); |
87 | 55 | 55 | ||
89 | 56 | protected: | 56 | private: |
90 | 57 | friend class TestTabIterator; | ||
91 | 57 | std::list<nux::InputArea*> areas_; | 58 | std::list<nux::InputArea*> areas_; |
92 | 58 | }; | 59 | }; |
93 | 59 | 60 | ||
94 | 60 | 61 | ||
95 | === modified file 'debian/changelog' | |||
96 | --- debian/changelog 2013-07-15 10:00:58 +0000 | |||
97 | +++ debian/changelog 2013-07-18 23:02:25 +0000 | |||
98 | @@ -1,7 +1,9 @@ | |||
99 | 1 | unity (7.0.2+13.10.20130705.1-0ubuntu4) UNRELEASED; urgency=low | 1 | unity (7.0.2+13.10.20130705.1-0ubuntu4) UNRELEASED; urgency=low |
100 | 2 | 2 | ||
103 | 3 | * debian/control: build-depends on xserver-xorg-video-dummy and libgl1-mesa-dri | 3 | * debian/control: |
104 | 4 | 4 | - build-depend on xserver-xorg-video-dummy and libgl1-mesa-dri | |
105 | 5 | - build-depend on libnux-4.0-dev (>= 4.0.2+13.10.20130718.1) | ||
106 | 6 | |||
107 | 5 | -- Marco Trevisan (Treviño) <marco@ubuntu.com> Tue, 09 Jul 2013 03:55:14 +0200 | 7 | -- Marco Trevisan (Treviño) <marco@ubuntu.com> Tue, 09 Jul 2013 03:55:14 +0200 |
108 | 6 | 8 | ||
109 | 7 | unity (7.0.2+13.10.20130705.1-0ubuntu3) saucy; urgency=low | 9 | unity (7.0.2+13.10.20130705.1-0ubuntu3) saucy; urgency=low |
110 | 8 | 10 | ||
111 | === modified file 'debian/control' | |||
112 | --- debian/control 2013-07-15 10:00:58 +0000 | |||
113 | +++ debian/control 2013-07-18 23:02:25 +0000 | |||
114 | @@ -32,7 +32,7 @@ | |||
115 | 32 | libjson-glib-dev, | 32 | libjson-glib-dev, |
116 | 33 | libjson-perl, | 33 | libjson-perl, |
117 | 34 | libnotify-dev, | 34 | libnotify-dev, |
119 | 35 | libnux-4.0-dev (>= 4.0.2), | 35 | libnux-4.0-dev (>= 4.0.2+13.10.20130718.1), |
120 | 36 | libpango1.0-dev, | 36 | libpango1.0-dev, |
121 | 37 | libsigc++-2.0-dev, | 37 | libsigc++-2.0-dev, |
122 | 38 | libstartup-notification0-dev, | 38 | libstartup-notification0-dev, |
123 | 39 | 39 | ||
124 | === modified file 'launcher/Launcher.cpp' | |||
125 | --- launcher/Launcher.cpp 2013-07-01 21:20:51 +0000 | |||
126 | +++ launcher/Launcher.cpp 2013-07-18 23:02:25 +0000 | |||
127 | @@ -157,6 +157,7 @@ | |||
128 | 157 | , _drag_out_delta_x(0.0f) | 157 | , _drag_out_delta_x(0.0f) |
129 | 158 | , _drag_gesture_ongoing(false) | 158 | , _drag_gesture_ongoing(false) |
130 | 159 | , _last_reveal_progress(0.0f) | 159 | , _last_reveal_progress(0.0f) |
131 | 160 | , _drag_action(nux::DNDACTION_NONE) | ||
132 | 160 | , _selection_atom(0) | 161 | , _selection_atom(0) |
133 | 161 | , icon_renderer(std::make_shared<ui::IconRenderer>()) | 162 | , icon_renderer(std::make_shared<ui::IconRenderer>()) |
134 | 162 | { | 163 | { |
135 | 163 | 164 | ||
136 | === modified file 'launcher/TrashLauncherIcon.cpp' | |||
137 | --- launcher/TrashLauncherIcon.cpp 2013-07-01 10:43:39 +0000 | |||
138 | +++ launcher/TrashLauncherIcon.cpp 2013-07-18 23:02:25 +0000 | |||
139 | @@ -42,6 +42,7 @@ | |||
140 | 42 | 42 | ||
141 | 43 | TrashLauncherIcon::TrashLauncherIcon(FileManager::Ptr const& fmo) | 43 | TrashLauncherIcon::TrashLauncherIcon(FileManager::Ptr const& fmo) |
142 | 44 | : SimpleLauncherIcon(IconType::TRASH) | 44 | : SimpleLauncherIcon(IconType::TRASH) |
143 | 45 | , empty_(true) | ||
144 | 45 | , file_manager_(fmo ? fmo : GnomeFileManager::Get()) | 46 | , file_manager_(fmo ? fmo : GnomeFileManager::Get()) |
145 | 46 | { | 47 | { |
146 | 47 | tooltip_text = _("Trash"); | 48 | tooltip_text = _("Trash"); |
147 | 48 | 49 | ||
148 | === modified file 'tests/test_filter_multirange.h' | |||
149 | --- tests/test_filter_multirange.h 2012-12-20 10:42:49 +0000 | |||
150 | +++ tests/test_filter_multirange.h 2013-07-18 23:02:25 +0000 | |||
151 | @@ -42,26 +42,22 @@ | |||
152 | 42 | 42 | ||
153 | 43 | GVariant* AddFilterOptions(std::vector<bool> option_active) | 43 | GVariant* AddFilterOptions(std::vector<bool> option_active) |
154 | 44 | { | 44 | { |
157 | 45 | GVariantBuilder* builder; | 45 | GVariantBuilder builder; |
158 | 46 | builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY); | 46 | g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY); |
159 | 47 | 47 | ||
162 | 48 | int i = 0; | 48 | for (unsigned i = 1; i <= option_active.size(); ++i) |
161 | 49 | for (auto iter = option_active.begin(), end = option_active.end(); iter != end; ++iter) | ||
163 | 50 | { | 49 | { |
170 | 51 | std::stringstream name; | 50 | auto pstr_name = std::to_string(i); |
171 | 52 | name << i++; | 51 | |
172 | 53 | 52 | g_variant_builder_add(&builder, "(sssb)", pstr_name.c_str(), pstr_name.c_str(), "", FALSE); | |
167 | 54 | const char* pstr_name = name.str().c_str(); | ||
168 | 55 | |||
169 | 56 | g_variant_builder_add (builder, "(sssb)", pstr_name, pstr_name, "", FALSE); | ||
173 | 57 | } | 53 | } |
175 | 58 | return g_variant_builder_end (builder); | 54 | return g_variant_builder_end(&builder); |
176 | 59 | } | 55 | } |
177 | 60 | 56 | ||
178 | 61 | void ExpectFilterRange(unity::dash::MultiRangeFilter::Ptr const& filter, int first, int last) | 57 | void ExpectFilterRange(unity::dash::MultiRangeFilter::Ptr const& filter, int first, int last) |
179 | 62 | { | 58 | { |
180 | 63 | int i = 0; | 59 | int i = 0; |
182 | 64 | for (auto option : filter->options()) | 60 | for (auto const& option : filter->options()) |
183 | 65 | { | 61 | { |
184 | 66 | bool should_be_active = i >= first && i <= last; | 62 | bool should_be_active = i >= first && i <= last; |
185 | 67 | EXPECT_EQ(option->active, should_be_active); | 63 | EXPECT_EQ(option->active, should_be_active); |
186 | 68 | 64 | ||
187 | === modified file 'tests/test_glib_signals.cpp' | |||
188 | --- tests/test_glib_signals.cpp 2012-08-15 16:58:14 +0000 | |||
189 | +++ tests/test_glib_signals.cpp 2013-07-18 23:02:25 +0000 | |||
190 | @@ -34,8 +34,7 @@ | |||
191 | 34 | 34 | ||
192 | 35 | virtual ~TestGLibSignals() | 35 | virtual ~TestGLibSignals() |
193 | 36 | { | 36 | { |
196 | 37 | if (G_IS_OBJECT(test_signals_)) | 37 | g_object_unref(test_signals_); |
195 | 38 | g_object_unref(test_signals_); | ||
197 | 39 | } | 38 | } |
198 | 40 | 39 | ||
199 | 41 | void Signal0Callback(TestSignals* signals) | 40 | void Signal0Callback(TestSignals* signals) |
200 | @@ -274,7 +273,7 @@ | |||
201 | 274 | Signal<void, TestSignals*> signal; | 273 | Signal<void, TestSignals*> signal; |
202 | 275 | signal.Connect(test_signals_, "signal0", | 274 | signal.Connect(test_signals_, "signal0", |
203 | 276 | sigc::mem_fun(this, &TestGLibSignals::Signal0Callback)); | 275 | sigc::mem_fun(this, &TestGLibSignals::Signal0Callback)); |
205 | 277 | g_object_unref(test_signals_); | 276 | g_clear_object(&test_signals_); |
206 | 278 | EXPECT_EQ(signal.object(), nullptr); | 277 | EXPECT_EQ(signal.object(), nullptr); |
207 | 279 | } | 278 | } |
208 | 280 | 279 | ||
209 | @@ -438,7 +437,7 @@ | |||
210 | 438 | sigc::mem_fun(this, &TestGLibSignals::Signal5Callback)); | 437 | sigc::mem_fun(this, &TestGLibSignals::Signal5Callback)); |
211 | 439 | manager.Add<gboolean, TestSignals*, const char*, int, float, double, gboolean, char>(test_signals_, "signal6", sigc::mem_fun(this, &TestGLibSignals::Signal6Callback)); | 438 | manager.Add<gboolean, TestSignals*, const char*, int, float, double, gboolean, char>(test_signals_, "signal6", sigc::mem_fun(this, &TestGLibSignals::Signal6Callback)); |
212 | 440 | 439 | ||
214 | 441 | g_object_unref(test_signals_); | 440 | g_clear_object(&test_signals_); |
215 | 442 | EXPECT_TRUE(manager.GetConnections().empty()); | 441 | EXPECT_TRUE(manager.GetConnections().empty()); |
216 | 443 | } | 442 | } |
217 | 444 | 443 | ||
218 | 445 | 444 | ||
219 | === modified file 'tests/test_grabhandle.cpp' | |||
220 | --- tests/test_grabhandle.cpp 2012-11-15 17:56:23 +0000 | |||
221 | +++ tests/test_grabhandle.cpp 2013-07-18 23:02:25 +0000 | |||
222 | @@ -147,14 +147,11 @@ | |||
223 | 147 | protected: | 147 | protected: |
224 | 148 | 148 | ||
225 | 149 | UnityMTGrabHandleTest() : | 149 | UnityMTGrabHandleTest() : |
231 | 150 | handlesMask (0), | 150 | handlesMask(0) |
232 | 151 | window (new MockGrabHandleWindow) | 151 | {} |
228 | 152 | { | ||
229 | 153 | |||
230 | 154 | } | ||
233 | 155 | 152 | ||
234 | 156 | unsigned int handlesMask; | 153 | unsigned int handlesMask; |
236 | 157 | MockGrabHandleWindow *window; | 154 | MockGrabHandleWindow window; |
237 | 158 | }; | 155 | }; |
238 | 159 | 156 | ||
239 | 160 | TEST_F(UnityMTGrabHandleTest, TestLayoutMasks) { | 157 | TEST_F(UnityMTGrabHandleTest, TestLayoutMasks) { |
240 | @@ -209,7 +206,7 @@ | |||
241 | 209 | for (unsigned int i = 0; i < unity::MT::NUM_HANDLES; i++) | 206 | for (unsigned int i = 0; i < unity::MT::NUM_HANDLES; i++) |
242 | 210 | textures.push_back (TextureSize (MockGrabHandleTextureFactory::Default ()->create (), nux::Geometry (0, 0, 100, 100))); | 207 | textures.push_back (TextureSize (MockGrabHandleTextureFactory::Default ()->create (), nux::Geometry (0, 0, 100, 100))); |
243 | 211 | 208 | ||
245 | 212 | GrabHandleGroup::Ptr group = GrabHandleGroup::create (window, textures); | 209 | GrabHandleGroup::Ptr group = GrabHandleGroup::create (&window, textures); |
246 | 213 | 210 | ||
247 | 214 | group->relayout (nux::Geometry (250, 250, 1000, 1000), true); | 211 | group->relayout (nux::Geometry (250, 250, 1000, 1000), true); |
248 | 215 | 212 | ||
249 | @@ -253,7 +250,7 @@ | |||
250 | 253 | for (unsigned int i = 0; i < unity::MT::NUM_HANDLES; i++) | 250 | for (unsigned int i = 0; i < unity::MT::NUM_HANDLES; i++) |
251 | 254 | textures.push_back (TextureSize (MockGrabHandleTextureFactory::Default ()->create (), nux::Geometry (0, 0, 100, 100))); | 251 | textures.push_back (TextureSize (MockGrabHandleTextureFactory::Default ()->create (), nux::Geometry (0, 0, 100, 100))); |
252 | 255 | 252 | ||
254 | 256 | GrabHandleGroup::Ptr group = GrabHandleGroup::create (window, textures); | 253 | GrabHandleGroup::Ptr group = GrabHandleGroup::create (&window, textures); |
255 | 257 | 254 | ||
256 | 258 | group->show (0); | 255 | group->show (0); |
257 | 259 | group->show (TopLeftHandle | TopHandle | TopRightHandle); | 256 | group->show (TopLeftHandle | TopHandle | TopRightHandle); |
258 | @@ -280,7 +277,7 @@ | |||
259 | 280 | for (unsigned int i = 0; i < unity::MT::NUM_HANDLES; i++) | 277 | for (unsigned int i = 0; i < unity::MT::NUM_HANDLES; i++) |
260 | 281 | textures.push_back (TextureSize (MockGrabHandleTextureFactory::Default ()->create (), nux::Geometry (0, 0, 100, 100))); | 278 | textures.push_back (TextureSize (MockGrabHandleTextureFactory::Default ()->create (), nux::Geometry (0, 0, 100, 100))); |
261 | 282 | 279 | ||
263 | 283 | GrabHandleGroup::Ptr group = GrabHandleGroup::create (window, textures); | 280 | GrabHandleGroup::Ptr group = GrabHandleGroup::create (&window, textures); |
264 | 284 | 281 | ||
265 | 285 | group->show (); | 282 | group->show (); |
266 | 286 | for (unsigned int i = 0; i < unity::MT::FADE_MSEC; i++) | 283 | for (unsigned int i = 0; i < unity::MT::FADE_MSEC; i++) |
267 | 287 | 284 | ||
268 | === modified file 'tests/test_icon_loader.cpp' | |||
269 | --- tests/test_icon_loader.cpp 2013-07-09 03:46:49 +0000 | |||
270 | +++ tests/test_icon_loader.cpp 2013-07-18 23:02:25 +0000 | |||
271 | @@ -87,47 +87,57 @@ | |||
272 | 87 | } | 87 | } |
273 | 88 | } | 88 | } |
274 | 89 | 89 | ||
312 | 90 | 90 | struct TestIconLoader : testing::Test | |
313 | 91 | TEST(TestIconLoader, TestGetDefault) | 91 | { |
314 | 92 | { | 92 | TestIconLoader() |
315 | 93 | // we need to initialize gtk | 93 | : icon_loader(IconLoader::GetDefault()) |
316 | 94 | int args_cnt = 0; | 94 | {} |
317 | 95 | gtk_init (&args_cnt, NULL); | 95 | |
318 | 96 | 96 | void TearDown() override | |
319 | 97 | IconLoader::GetDefault(); | 97 | { |
320 | 98 | } | 98 | for (int handle : handles_) |
321 | 99 | 99 | icon_loader.DisconnectHandle(handle); | |
322 | 100 | TEST(TestIconLoader, TestGetOneIcon) | 100 | } |
323 | 101 | { | 101 | |
324 | 102 | LoadResult load_result; | 102 | IconLoader& icon_loader; |
325 | 103 | IconLoader& icon_loader = IconLoader::GetDefault(); | 103 | std::vector<int> handles_; |
326 | 104 | 104 | }; | |
327 | 105 | icon_loader.LoadFromIconName("python", -1, 48, sigc::mem_fun(load_result, | 105 | |
328 | 106 | &LoadResult::IconLoaded)); | 106 | TEST_F(TestIconLoader, TestGetDefault) |
329 | 107 | 107 | { | |
330 | 108 | Utils::WaitUntilMSec(load_result.got_callback); | 108 | EXPECT_EQ(&icon_loader, &IconLoader::GetDefault()); |
331 | 109 | EXPECT_TRUE(load_result.got_callback); | 109 | } |
332 | 110 | EXPECT_TRUE(IsValidPixbuf(load_result.pixbuf)); | 110 | |
333 | 111 | } | 111 | TEST_F(TestIconLoader, TestGetOneIcon) |
334 | 112 | 112 | { | |
335 | 113 | TEST(TestIconLoader, TestGetAnnotatedIcon) | 113 | LoadResult load_result; |
336 | 114 | { | 114 | |
337 | 115 | LoadResult load_result; | 115 | int handle = icon_loader.LoadFromIconName("python", -1, 48, sigc::mem_fun(load_result, |
338 | 116 | IconLoader& icon_loader = IconLoader::GetDefault(); | 116 | &LoadResult::IconLoaded)); |
339 | 117 | 117 | handles_.push_back(handle); | |
340 | 118 | icon_loader.LoadFromGIconString(". UnityProtocolAnnotatedIcon %7B'base-icon':%20%3C'cmake'%3E,%20'ribbon':%20%3C'foo'%3E%7D", -1, 48, sigc::mem_fun(load_result, | 118 | |
341 | 119 | &LoadResult::IconLoaded)); | 119 | Utils::WaitUntilMSec(load_result.got_callback); |
342 | 120 | 120 | EXPECT_TRUE(load_result.got_callback); | |
343 | 121 | Utils::WaitUntilMSec(load_result.got_callback); | 121 | EXPECT_TRUE(IsValidPixbuf(load_result.pixbuf)); |
344 | 122 | EXPECT_TRUE(load_result.got_callback); | 122 | } |
345 | 123 | EXPECT_TRUE(IsValidPixbuf(load_result.pixbuf)); | 123 | |
346 | 124 | } | 124 | TEST_F(TestIconLoader, TestGetAnnotatedIcon) |
347 | 125 | 125 | { | |
348 | 126 | TEST(TestIconLoader, TestGetOneIconManyTimes) | 126 | LoadResult load_result; |
349 | 127 | |||
350 | 128 | int handle = icon_loader.LoadFromGIconString(". UnityProtocolAnnotatedIcon %7B'base-icon':%20%3C'cmake'%3E,%20'ribbon':%20%3C'foo'%3E%7D", -1, 48, sigc::mem_fun(load_result, | ||
351 | 129 | &LoadResult::IconLoaded)); | ||
352 | 130 | handles_.push_back(handle); | ||
353 | 131 | |||
354 | 132 | Utils::WaitUntilMSec(load_result.got_callback); | ||
355 | 133 | EXPECT_TRUE(load_result.got_callback); | ||
356 | 134 | EXPECT_TRUE(IsValidPixbuf(load_result.pixbuf)); | ||
357 | 135 | } | ||
358 | 136 | |||
359 | 137 | TEST_F(TestIconLoader, TestGetOneIconManyTimes) | ||
360 | 127 | { | 138 | { |
361 | 128 | std::vector<LoadResult> results; | 139 | std::vector<LoadResult> results; |
362 | 129 | std::vector<int> handles; | 140 | std::vector<int> handles; |
363 | 130 | IconLoader& icon_loader = IconLoader::GetDefault(); | ||
364 | 131 | int i, load_count; | 141 | int i, load_count; |
365 | 132 | 142 | ||
366 | 133 | // 100 times should be good | 143 | // 100 times should be good |
367 | @@ -141,6 +151,7 @@ | |||
368 | 141 | { | 151 | { |
369 | 142 | handles[i] = icon_loader.LoadFromIconName("debian-logo", -1, 48, | 152 | handles[i] = icon_loader.LoadFromIconName("debian-logo", -1, 48, |
370 | 143 | sigc::mem_fun(results[i], &LoadResult::IconLoaded)); | 153 | sigc::mem_fun(results[i], &LoadResult::IconLoaded)); |
371 | 154 | handles_.push_back(handles[i]); | ||
372 | 144 | } | 155 | } |
373 | 145 | 156 | ||
374 | 146 | // disconnect every other handler (and especially the first one) | 157 | // disconnect every other handler (and especially the first one) |
375 | @@ -154,10 +165,9 @@ | |||
376 | 154 | } | 165 | } |
377 | 155 | 166 | ||
378 | 156 | // Disabled until we have the new thread safe lp:fontconfig | 167 | // Disabled until we have the new thread safe lp:fontconfig |
380 | 157 | TEST(TestIconLoader, DISABLED_TestGetManyIcons) | 168 | TEST_F(TestIconLoader, DISABLED_TestGetManyIcons) |
381 | 158 | { | 169 | { |
382 | 159 | std::vector<LoadResult> results; | 170 | std::vector<LoadResult> results; |
383 | 160 | IconLoader& icon_loader = IconLoader::GetDefault(); | ||
384 | 161 | int i = 0; | 171 | int i = 0; |
385 | 162 | int icon_count; | 172 | int icon_count; |
386 | 163 | 173 | ||
387 | @@ -169,19 +179,18 @@ | |||
388 | 169 | for (GList *it = icons; it != NULL; it = it->next) | 179 | for (GList *it = icons; it != NULL; it = it->next) |
389 | 170 | { | 180 | { |
390 | 171 | const char *icon_name = static_cast<char*>(it->data); | 181 | const char *icon_name = static_cast<char*>(it->data); |
393 | 172 | icon_loader.LoadFromIconName(icon_name, -1, 48, sigc::mem_fun(results[i++], | 182 | int handle = icon_loader.LoadFromIconName(icon_name, -1, 48, sigc::mem_fun(results[i++], &LoadResult::IconLoaded)); |
394 | 173 | &LoadResult::IconLoaded)); | 183 | handles_.push_back(handle); |
395 | 174 | if (i >= icon_count) break; | 184 | if (i >= icon_count) break; |
396 | 175 | } | 185 | } |
397 | 176 | 186 | ||
398 | 177 | CheckResults(results); | 187 | CheckResults(results); |
399 | 178 | } | 188 | } |
400 | 179 | 189 | ||
402 | 180 | TEST(TestIconLoader, TestCancelSome) | 190 | TEST_F(TestIconLoader, TestCancelSome) |
403 | 181 | { | 191 | { |
404 | 182 | std::vector<LoadResult> results; | 192 | std::vector<LoadResult> results; |
405 | 183 | std::vector<int> handles; | 193 | std::vector<int> handles; |
406 | 184 | IconLoader& icon_loader = IconLoader::GetDefault(); | ||
407 | 185 | int i = 0; | 194 | int i = 0; |
408 | 186 | int icon_count; | 195 | int icon_count; |
409 | 187 | 196 | ||
410 | @@ -197,6 +206,7 @@ | |||
411 | 197 | int handle = icon_loader.LoadFromIconName(icon_name, -1, 48, sigc::mem_fun( | 206 | int handle = icon_loader.LoadFromIconName(icon_name, -1, 48, sigc::mem_fun( |
412 | 198 | results[i], &LoadResult::IconLoaded)); | 207 | results[i], &LoadResult::IconLoaded)); |
413 | 199 | handles[i++] = handle; | 208 | handles[i++] = handle; |
414 | 209 | handles_.push_back(handle); | ||
415 | 200 | if (i >= icon_count) break; | 210 | if (i >= icon_count) break; |
416 | 201 | } | 211 | } |
417 | 202 | 212 | ||
418 | 203 | 213 | ||
419 | === modified file 'tests/test_launcher_entry_remote.cpp' | |||
420 | --- tests/test_launcher_entry_remote.cpp 2012-03-28 15:40:13 +0000 | |||
421 | +++ tests/test_launcher_entry_remote.cpp 2013-07-18 23:02:25 +0000 | |||
422 | @@ -153,6 +153,7 @@ | |||
423 | 153 | g_variant_get(parameters, "(&sa{sv})", &app_uri, &prop_iter); | 153 | g_variant_get(parameters, "(&sa{sv})", &app_uri, &prop_iter); |
424 | 154 | entry1.Update(prop_iter); | 154 | entry1.Update(prop_iter); |
425 | 155 | g_variant_iter_free(prop_iter); | 155 | g_variant_iter_free(prop_iter); |
426 | 156 | g_variant_unref(parameters); | ||
427 | 156 | 157 | ||
428 | 157 | EXPECT_EQ(entry1.DBusName(), "Entry1"); | 158 | EXPECT_EQ(entry1.DBusName(), "Entry1"); |
429 | 158 | EXPECT_EQ(entry1.AppUri(), "AppURI1"); | 159 | EXPECT_EQ(entry1.AppUri(), "AppURI1"); |
430 | 159 | 160 | ||
431 | === modified file 'tests/test_preview_player.cpp' | |||
432 | --- tests/test_preview_player.cpp 2013-07-09 18:10:15 +0000 | |||
433 | +++ tests/test_preview_player.cpp 2013-07-18 23:02:25 +0000 | |||
434 | @@ -150,7 +150,7 @@ | |||
435 | 150 | : server_(PLAYER_NAME) | 150 | : server_(PLAYER_NAME) |
436 | 151 | { | 151 | { |
437 | 152 | server_.AddObjects(PLAYER_INTERFACE, PLAYER_PATH); | 152 | server_.AddObjects(PLAYER_INTERFACE, PLAYER_PATH); |
439 | 153 | auto const& object = server_.GetObjects().front(); | 153 | auto object = server_.GetObjects().front(); |
440 | 154 | 154 | ||
441 | 155 | object->SetMethodsCallsHandler([this, object] (std::string const& method, GVariant* parameters) { | 155 | object->SetMethodsCallsHandler([this, object] (std::string const& method, GVariant* parameters) { |
442 | 156 | if (method == "Play") | 156 | if (method == "Play") |
443 | 157 | 157 | ||
444 | === modified file 'tests/test_previews.cpp' | |||
445 | --- tests/test_previews.cpp 2013-02-27 18:04:26 +0000 | |||
446 | +++ tests/test_previews.cpp 2013-07-18 23:02:25 +0000 | |||
447 | @@ -42,6 +42,11 @@ | |||
448 | 42 | return g_variant_get_type_string(variant) != NULL; | 42 | return g_variant_get_type_string(variant) != NULL; |
449 | 43 | } | 43 | } |
450 | 44 | 44 | ||
451 | 45 | static void g_variant_unref0(gpointer var) | ||
452 | 46 | { | ||
453 | 47 | if (var) g_variant_unref((GVariant*)var); | ||
454 | 48 | } | ||
455 | 49 | |||
456 | 45 | TEST(TestPreviews, DeserializeGeneric) | 50 | TEST(TestPreviews, DeserializeGeneric) |
457 | 46 | { | 51 | { |
458 | 47 | Object<GIcon> icon(g_icon_new_for_string("accessories", NULL)); | 52 | Object<GIcon> icon(g_icon_new_for_string("accessories", NULL)); |
459 | @@ -77,7 +82,7 @@ | |||
460 | 77 | unity_protocol_preview_set_image(proto_obj, icon); | 82 | unity_protocol_preview_set_image(proto_obj, icon); |
461 | 78 | unity_protocol_preview_set_image_source_uri(proto_obj, "Source"); | 83 | unity_protocol_preview_set_image_source_uri(proto_obj, "Source"); |
462 | 79 | 84 | ||
464 | 80 | GHashTable* hints = g_hash_table_new(g_str_hash, g_str_equal); | 85 | GHashTable* hints = g_hash_table_new_full(g_str_hash, g_direct_equal, g_free, g_variant_unref0); |
465 | 81 | g_hash_table_insert(hints, g_strdup("extra-text"), g_variant_new_string("Foo")); | 86 | g_hash_table_insert(hints, g_strdup("extra-text"), g_variant_new_string("Foo")); |
466 | 82 | unity_protocol_preview_add_action(proto_obj, "action1", "Action #1", NULL, 0); | 87 | unity_protocol_preview_add_action(proto_obj, "action1", "Action #1", NULL, 0); |
467 | 83 | unity_protocol_preview_add_action_with_hints(proto_obj, "action2", "Action #2", NULL, 0, hints); | 88 | unity_protocol_preview_add_action_with_hints(proto_obj, "action2", "Action #2", NULL, 0, hints); |
468 | 84 | 89 | ||
469 | === modified file 'tests/test_quicklist_menu_item.cpp' | |||
470 | --- tests/test_quicklist_menu_item.cpp 2013-03-19 18:47:01 +0000 | |||
471 | +++ tests/test_quicklist_menu_item.cpp 2013-07-18 23:02:25 +0000 | |||
472 | @@ -167,7 +167,9 @@ | |||
473 | 167 | XEvent xevent; | 167 | XEvent xevent; |
474 | 168 | xevent.type = ButtonPress; | 168 | xevent.type = ButtonPress; |
475 | 169 | xevent.xany.display = nux::GetGraphicsDisplay()->GetX11Display(); | 169 | xevent.xany.display = nux::GetGraphicsDisplay()->GetX11Display(); |
476 | 170 | xevent.xany.window = nux::GetGraphicsDisplay()->GetWindowHandle(); | ||
477 | 170 | xevent.xbutton.time = g_random_int(); | 171 | xevent.xbutton.time = g_random_int(); |
478 | 172 | xevent.xbutton.button = Button1; | ||
479 | 171 | nux::GetGraphicsDisplay()->ProcessXEvent(xevent, true); | 173 | nux::GetGraphicsDisplay()->ProcessXEvent(xevent, true); |
480 | 172 | 174 | ||
481 | 173 | auto event_time = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp; | 175 | auto event_time = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp; |
482 | 174 | 176 | ||
483 | === modified file 'tests/test_scope.cpp' | |||
484 | --- tests/test_scope.cpp 2013-07-09 18:56:00 +0000 | |||
485 | +++ tests/test_scope.cpp 2013-07-18 23:02:25 +0000 | |||
486 | @@ -18,7 +18,7 @@ | |||
487 | 18 | */ | 18 | */ |
488 | 19 | 19 | ||
489 | 20 | #include <boost/lexical_cast.hpp> | 20 | #include <boost/lexical_cast.hpp> |
491 | 21 | #include <gtest/gtest.h> | 21 | #include <gmock/gmock.h> |
492 | 22 | #include <glib-object.h> | 22 | #include <glib-object.h> |
493 | 23 | #include <unity-protocol.h> | 23 | #include <unity-protocol.h> |
494 | 24 | 24 | ||
495 | @@ -43,7 +43,9 @@ | |||
496 | 43 | const std::string SCOPE_NAME = "testscope1.scope"; | 43 | const std::string SCOPE_NAME = "testscope1.scope"; |
497 | 44 | } | 44 | } |
498 | 45 | 45 | ||
500 | 46 | class TestScope : public ::testing::Test | 46 | using namespace testing; |
501 | 47 | |||
502 | 48 | class TestScope : public Test | ||
503 | 47 | { | 49 | { |
504 | 48 | public: | 50 | public: |
505 | 49 | TestScope() { } | 51 | TestScope() { } |
506 | @@ -216,6 +218,10 @@ | |||
507 | 216 | Results::Ptr category_model1 = scope_->GetResultsForCategory(1); | 218 | Results::Ptr category_model1 = scope_->GetResultsForCategory(1); |
508 | 217 | Results::Ptr category_model2 = scope_->GetResultsForCategory(2); | 219 | Results::Ptr category_model2 = scope_->GetResultsForCategory(2); |
509 | 218 | 220 | ||
510 | 221 | ASSERT_THAT(category_model0, NotNull()); | ||
511 | 222 | ASSERT_THAT(category_model1, NotNull()); | ||
512 | 223 | ASSERT_THAT(category_model2, NotNull()); | ||
513 | 224 | |||
514 | 219 | EXPECT_EQ(category_model0->count(), 5) << "Category 0 result count not as expected (" << category_model0->count() << " != 5)"; | 225 | EXPECT_EQ(category_model0->count(), 5) << "Category 0 result count not as expected (" << category_model0->count() << " != 5)"; |
515 | 220 | EXPECT_EQ(category_model1->count(), 4) << "Category 1 result count not as expected (" << category_model1->count() << " != 4)"; | 226 | EXPECT_EQ(category_model1->count(), 4) << "Category 1 result count not as expected (" << category_model1->count() << " != 4)"; |
516 | 221 | EXPECT_EQ(category_model2->count(), 4) << "Category 2 result count not as expected (" << category_model2->count() << " != 4)"; | 227 | EXPECT_EQ(category_model2->count(), 4) << "Category 2 result count not as expected (" << category_model2->count() << " != 4)"; |
517 | 222 | 228 | ||
518 | === modified file 'tests/test_session_controller.cpp' | |||
519 | --- tests/test_session_controller.cpp 2013-03-19 18:47:01 +0000 | |||
520 | +++ tests/test_session_controller.cpp 2013-07-18 23:02:25 +0000 | |||
521 | @@ -54,7 +54,7 @@ | |||
522 | 54 | nux::NuxTimerTickSource tick_source; | 54 | nux::NuxTimerTickSource tick_source; |
523 | 55 | nux::animation::AnimationController animation_controller; | 55 | nux::animation::AnimationController animation_controller; |
524 | 56 | unity::Settings settings; | 56 | unity::Settings settings; |
526 | 57 | MockManager::Ptr manager; | 57 | MockManager::Ptr manager ; |
527 | 58 | ControllerWrap controller; | 58 | ControllerWrap controller; |
528 | 59 | }; | 59 | }; |
529 | 60 | 60 | ||
530 | 61 | 61 | ||
531 | === modified file 'tests/test_tabiterator.cpp' | |||
532 | --- tests/test_tabiterator.cpp 2013-01-22 11:54:25 +0000 | |||
533 | +++ tests/test_tabiterator.cpp 2013-07-18 23:02:25 +0000 | |||
534 | @@ -17,6 +17,7 @@ | |||
535 | 17 | * <http://www.gnu.org/licenses/> | 17 | * <http://www.gnu.org/licenses/> |
536 | 18 | * | 18 | * |
537 | 19 | * Authored by: Manuel de la Pena <manuel.delapena@canonical.com> | 19 | * Authored by: Manuel de la Pena <manuel.delapena@canonical.com> |
538 | 20 | * Marco Trevisan <marco.trevisan@canonical.com> | ||
539 | 20 | * | 21 | * |
540 | 21 | */ | 22 | */ |
541 | 22 | 23 | ||
542 | @@ -38,341 +39,359 @@ | |||
543 | 38 | namespace previews | 39 | namespace previews |
544 | 39 | { | 40 | { |
545 | 40 | 41 | ||
562 | 41 | class MockedTabIterator : public TabIterator | 42 | typedef nux::ObjectPtr<IMTextEntry> IMTextEntryPtr; |
563 | 42 | { | 43 | |
564 | 43 | public: | 44 | struct TestTabIterator : ::testing::Test |
565 | 44 | using TabIterator::areas_; | 45 | { |
566 | 45 | }; | 46 | struct MockedTabIterator : public TabIterator |
567 | 46 | 47 | { | |
568 | 47 | class TestTabIterator : public ::testing::Test | 48 | using TabIterator::areas_; |
569 | 48 | { | 49 | }; |
570 | 49 | protected: | 50 | |
571 | 50 | TestTabIterator() : Test(), | 51 | MockedTabIterator tab_iterator; |
556 | 51 | tab_iterator(new MockedTabIterator()) | ||
557 | 52 | { | ||
558 | 53 | } | ||
559 | 54 | |||
560 | 55 | |||
561 | 56 | std::unique_ptr<MockedTabIterator> tab_iterator; | ||
572 | 57 | }; | 52 | }; |
573 | 58 | 53 | ||
574 | 59 | TEST_F(TestTabIterator, DoRemove) | 54 | TEST_F(TestTabIterator, DoRemove) |
575 | 60 | { | 55 | { |
579 | 61 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 56 | auto entry = IMTextEntryPtr(new IMTextEntry); |
580 | 62 | tab_iterator->areas_.push_front(entry); | 57 | tab_iterator.areas_.push_back(entry.GetPointer()); |
581 | 63 | tab_iterator->Remove(entry); | 58 | tab_iterator.Remove(entry.GetPointer()); |
582 | 64 | 59 | ||
586 | 65 | std::list<nux::InputArea*>::iterator it = std::find(tab_iterator->areas_.begin(), | 60 | std::list<nux::InputArea*>::iterator it = std::find(tab_iterator.areas_.begin(), |
587 | 66 | tab_iterator->areas_.end(), entry); | 61 | tab_iterator.areas_.end(), entry.GetPointer()); |
588 | 67 | EXPECT_EQ(it, tab_iterator->areas_.end()); | 62 | EXPECT_EQ(it, tab_iterator.areas_.end()); |
589 | 68 | } | 63 | } |
590 | 69 | 64 | ||
591 | 70 | TEST_F(TestTabIterator, DoRemoveMissing) | 65 | TEST_F(TestTabIterator, DoRemoveMissing) |
592 | 71 | { | 66 | { |
595 | 72 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 67 | auto entry = IMTextEntryPtr(new IMTextEntry); |
596 | 73 | tab_iterator->Remove(entry); | 68 | tab_iterator.Remove(entry.GetPointer()); |
597 | 74 | 69 | ||
601 | 75 | std::list<nux::InputArea*>::iterator it = std::find(tab_iterator->areas_.begin(), | 70 | std::list<nux::InputArea*>::iterator it = std::find(tab_iterator.areas_.begin(), |
602 | 76 | tab_iterator->areas_.end(), entry); | 71 | tab_iterator.areas_.end(), entry.GetPointer()); |
603 | 77 | EXPECT_EQ(it, tab_iterator->areas_.end()); | 72 | EXPECT_EQ(it, tab_iterator.areas_.end()); |
604 | 78 | } | 73 | } |
605 | 79 | 74 | ||
606 | 80 | TEST_F(TestTabIterator, Prepend) | 75 | TEST_F(TestTabIterator, Prepend) |
607 | 81 | { | 76 | { |
608 | 77 | std::vector<IMTextEntryPtr> local_areas; | ||
609 | 78 | |||
610 | 82 | for(int index=0; index < 10; ++index) | 79 | for(int index=0; index < 10; ++index) |
611 | 83 | { | 80 | { |
614 | 84 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 81 | local_areas.push_back(IMTextEntryPtr(new IMTextEntry)); |
615 | 85 | tab_iterator->areas_.push_front(entry); | 82 | tab_iterator.areas_.push_back(local_areas.back().GetPointer()); |
616 | 86 | } | 83 | } |
617 | 87 | 84 | ||
625 | 88 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 85 | auto entry = IMTextEntryPtr(new IMTextEntry); |
626 | 89 | tab_iterator->Prepend(entry); | 86 | tab_iterator.Prepend(entry.GetPointer()); |
627 | 90 | 87 | ||
628 | 91 | std::list<nux::InputArea*>::iterator it = std::find(tab_iterator->areas_.begin(), | 88 | std::list<nux::InputArea*>::iterator it = std::find(tab_iterator.areas_.begin(), |
629 | 92 | tab_iterator->areas_.end(), entry); | 89 | tab_iterator.areas_.end(), entry.GetPointer()); |
630 | 93 | 90 | ||
631 | 94 | EXPECT_EQ(it, tab_iterator->areas_.begin()); | 91 | EXPECT_EQ(it, tab_iterator.areas_.begin()); |
632 | 95 | } | 92 | } |
633 | 96 | 93 | ||
634 | 97 | TEST_F(TestTabIterator, Append) | 94 | TEST_F(TestTabIterator, Append) |
635 | 98 | { | 95 | { |
636 | 96 | std::vector<IMTextEntryPtr> local_areas; | ||
637 | 97 | |||
638 | 99 | for(int index=0; index < 10; ++index) | 98 | for(int index=0; index < 10; ++index) |
639 | 100 | { | 99 | { |
642 | 101 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 100 | local_areas.push_back(IMTextEntryPtr(new IMTextEntry)); |
643 | 102 | tab_iterator->areas_.push_front(entry); | 101 | tab_iterator.areas_.push_back(local_areas.back().GetPointer()); |
644 | 103 | } | 102 | } |
645 | 104 | 103 | ||
649 | 105 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 104 | auto entry = IMTextEntryPtr(new IMTextEntry); |
650 | 106 | tab_iterator->Append(entry); | 105 | tab_iterator.Append(entry.GetPointer()); |
651 | 107 | nux::InputArea* last = tab_iterator->areas_.back(); | 106 | nux::InputArea* last = tab_iterator.areas_.back(); |
652 | 108 | 107 | ||
654 | 109 | EXPECT_TRUE(entry == last); // compare pointers | 108 | EXPECT_EQ(entry.GetPointer(), last); // compare pointers |
655 | 110 | } | 109 | } |
656 | 111 | 110 | ||
657 | 112 | TEST_F(TestTabIterator, InsertIndex) | 111 | TEST_F(TestTabIterator, InsertIndex) |
658 | 113 | { | 112 | { |
659 | 113 | std::vector<IMTextEntryPtr> local_areas; | ||
660 | 114 | |||
661 | 114 | for(int index=0; index < 10; ++index) | 115 | for(int index=0; index < 10; ++index) |
662 | 115 | { | 116 | { |
665 | 116 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 117 | local_areas.push_back(IMTextEntryPtr(new IMTextEntry)); |
666 | 117 | tab_iterator->areas_.push_front(entry); | 118 | tab_iterator.areas_.push_back(local_areas.back().GetPointer()); |
667 | 118 | } | 119 | } |
672 | 119 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 120 | |
673 | 120 | tab_iterator->Insert(entry, 5); | 121 | auto entry = IMTextEntryPtr(new IMTextEntry); |
674 | 121 | 122 | tab_iterator.Insert(entry.GetPointer(), 5); | |
675 | 122 | std::list<nux::InputArea*>::iterator it = tab_iterator->areas_.begin(); | 123 | |
676 | 124 | std::list<nux::InputArea*>::iterator it = tab_iterator.areas_.begin(); | ||
677 | 123 | std::advance(it, 5); | 125 | std::advance(it, 5); |
678 | 124 | 126 | ||
681 | 125 | EXPECT_NE(tab_iterator->areas_.end(), it); | 127 | EXPECT_NE(tab_iterator.areas_.end(), it); |
682 | 126 | EXPECT_TRUE(entry == (unity::IMTextEntry*)*it); | 128 | EXPECT_EQ(entry.GetPointer(), *it); |
683 | 127 | } | 129 | } |
684 | 128 | 130 | ||
685 | 129 | TEST_F(TestTabIterator, InsertIndexTooLarge) | 131 | TEST_F(TestTabIterator, InsertIndexTooLarge) |
686 | 130 | { | 132 | { |
687 | 133 | std::vector<IMTextEntryPtr> local_areas; | ||
688 | 134 | |||
689 | 131 | for(int index=0; index < 5; ++index) | 135 | for(int index=0; index < 5; ++index) |
690 | 132 | { | 136 | { |
693 | 133 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 137 | local_areas.push_back(IMTextEntryPtr(new IMTextEntry)); |
694 | 134 | tab_iterator->areas_.push_front(entry); | 138 | tab_iterator.areas_.push_back(local_areas.back().GetPointer()); |
695 | 135 | } | 139 | } |
696 | 136 | 140 | ||
703 | 137 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 141 | auto entry = IMTextEntryPtr(new IMTextEntry); |
704 | 138 | tab_iterator->Insert(entry, 7); | 142 | tab_iterator.Insert(entry.GetPointer(), 7); |
705 | 139 | 143 | ||
706 | 140 | nux::InputArea* last = tab_iterator->areas_.back(); | 144 | nux::InputArea* last = tab_iterator.areas_.back(); |
707 | 141 | 145 | ||
708 | 142 | EXPECT_TRUE(entry == last); // compare pointers | 146 | EXPECT_EQ(entry.GetPointer(), last); // compare pointers |
709 | 143 | } | 147 | } |
710 | 144 | 148 | ||
711 | 145 | TEST_F(TestTabIterator, InsertBefore) | 149 | TEST_F(TestTabIterator, InsertBefore) |
712 | 146 | { | 150 | { |
720 | 147 | unity::IMTextEntry* first_entry = new unity::IMTextEntry(); | 151 | auto first_entry = IMTextEntryPtr(new IMTextEntry); |
721 | 148 | tab_iterator->areas_.push_front(first_entry); | 152 | tab_iterator.areas_.push_back(first_entry.GetPointer()); |
722 | 149 | 153 | ||
723 | 150 | unity::IMTextEntry* second_entry = new unity::IMTextEntry(); | 154 | auto second_entry = IMTextEntryPtr(new IMTextEntry); |
724 | 151 | tab_iterator->InsertBefore(second_entry, first_entry); | 155 | tab_iterator.InsertBefore(second_entry.GetPointer(), first_entry.GetPointer()); |
725 | 152 | 156 | ||
726 | 153 | EXPECT_TRUE(second_entry == *tab_iterator->areas_.begin()); | 157 | EXPECT_EQ(second_entry.GetPointer(), *tab_iterator.areas_.begin()); |
727 | 154 | } | 158 | } |
728 | 155 | 159 | ||
729 | 156 | TEST_F(TestTabIterator, InsertBeforeMissing) | 160 | TEST_F(TestTabIterator, InsertBeforeMissing) |
730 | 157 | { | 161 | { |
731 | 162 | std::vector<IMTextEntryPtr> local_areas; | ||
732 | 163 | |||
733 | 158 | for(int index=0; index < 5; ++index) | 164 | for(int index=0; index < 5; ++index) |
734 | 159 | { | 165 | { |
737 | 160 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 166 | local_areas.push_back(IMTextEntryPtr(new IMTextEntry)); |
738 | 161 | tab_iterator->areas_.push_front(entry); | 167 | tab_iterator.areas_.push_back(local_areas.back().GetPointer()); |
739 | 162 | } | 168 | } |
740 | 163 | 169 | ||
751 | 164 | unity::IMTextEntry* first_entry = new unity::IMTextEntry(); | 170 | auto first_entry = IMTextEntryPtr(new IMTextEntry); |
752 | 165 | unity::IMTextEntry* second_entry = new unity::IMTextEntry(); | 171 | auto second_entry = IMTextEntryPtr(new IMTextEntry); |
753 | 166 | tab_iterator->InsertBefore(second_entry, first_entry); | 172 | tab_iterator.InsertBefore(second_entry.GetPointer(), first_entry.GetPointer()); |
754 | 167 | 173 | ||
755 | 168 | std::list<nux::InputArea*>::iterator it = std::find(tab_iterator->areas_.begin(), | 174 | std::list<nux::InputArea*>::iterator it = std::find(tab_iterator.areas_.begin(), |
756 | 169 | tab_iterator->areas_.end(), second_entry); | 175 | tab_iterator.areas_.end(), second_entry.GetPointer()); |
757 | 170 | 176 | ||
758 | 171 | nux::InputArea* last = tab_iterator->areas_.back(); | 177 | nux::InputArea* last = tab_iterator.areas_.back(); |
759 | 172 | 178 | ||
760 | 173 | EXPECT_TRUE(second_entry == last); | 179 | EXPECT_EQ(second_entry.GetPointer(), last); |
761 | 174 | } | 180 | } |
762 | 175 | 181 | ||
763 | 176 | TEST_F(TestTabIterator, InsertAfter) | 182 | TEST_F(TestTabIterator, InsertAfter) |
764 | 177 | { | 183 | { |
774 | 178 | unity::IMTextEntry* first_entry = new unity::IMTextEntry(); | 184 | auto first_entry = IMTextEntryPtr(new IMTextEntry); |
775 | 179 | tab_iterator->areas_.push_front(first_entry); | 185 | tab_iterator.areas_.push_back(first_entry.GetPointer()); |
776 | 180 | 186 | ||
777 | 181 | unity::IMTextEntry* second_entry = new unity::IMTextEntry(); | 187 | auto second_entry = IMTextEntryPtr(new IMTextEntry); |
778 | 182 | tab_iterator->InsertAfter(second_entry, first_entry); | 188 | tab_iterator.InsertAfter(second_entry.GetPointer(), first_entry.GetPointer()); |
779 | 183 | 189 | ||
780 | 184 | nux::InputArea* last = tab_iterator->areas_.back(); | 190 | nux::InputArea* last = tab_iterator.areas_.back(); |
781 | 185 | 191 | ||
782 | 186 | EXPECT_TRUE(second_entry == last); | 192 | EXPECT_EQ(second_entry.GetPointer(), last); |
783 | 187 | } | 193 | } |
784 | 188 | 194 | ||
785 | 189 | TEST_F(TestTabIterator, InsertAfterMissing) | 195 | TEST_F(TestTabIterator, InsertAfterMissing) |
786 | 190 | { | 196 | { |
787 | 197 | std::vector<IMTextEntryPtr> local_areas; | ||
788 | 198 | |||
789 | 191 | for(int index=0; index < 5; ++index) | 199 | for(int index=0; index < 5; ++index) |
790 | 192 | { | 200 | { |
793 | 193 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 201 | local_areas.push_back(IMTextEntryPtr(new IMTextEntry)); |
794 | 194 | tab_iterator->areas_.push_front(entry); | 202 | tab_iterator.areas_.push_back(local_areas.back().GetPointer()); |
795 | 195 | } | 203 | } |
796 | 196 | 204 | ||
807 | 197 | unity::IMTextEntry* first_entry = new unity::IMTextEntry(); | 205 | auto first_entry = IMTextEntryPtr(new IMTextEntry); |
808 | 198 | unity::IMTextEntry* second_entry = new unity::IMTextEntry(); | 206 | auto second_entry = IMTextEntryPtr(new IMTextEntry); |
809 | 199 | tab_iterator->InsertAfter(second_entry, first_entry); | 207 | tab_iterator.InsertAfter(second_entry.GetPointer(), first_entry.GetPointer()); |
810 | 200 | 208 | ||
811 | 201 | std::list<nux::InputArea*>::iterator it = std::find(tab_iterator->areas_.begin(), | 209 | std::list<nux::InputArea*>::iterator it = std::find(tab_iterator.areas_.begin(), |
812 | 202 | tab_iterator->areas_.end(), second_entry); | 210 | tab_iterator.areas_.end(), second_entry.GetPointer()); |
813 | 203 | 211 | ||
814 | 204 | nux::InputArea* last = tab_iterator->areas_.back(); | 212 | nux::InputArea* last = tab_iterator.areas_.back(); |
815 | 205 | 213 | ||
816 | 206 | EXPECT_TRUE(second_entry == last); | 214 | EXPECT_EQ(second_entry.GetPointer(), last); |
817 | 207 | } | 215 | } |
818 | 208 | 216 | ||
819 | 209 | TEST_F(TestTabIterator, GetDefaultFocus) | 217 | TEST_F(TestTabIterator, GetDefaultFocus) |
820 | 210 | { | 218 | { |
821 | 219 | std::vector<IMTextEntryPtr> local_areas; | ||
822 | 220 | |||
823 | 211 | for(int index=0; index < 10; ++index) | 221 | for(int index=0; index < 10; ++index) |
824 | 212 | { | 222 | { |
827 | 213 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 223 | local_areas.push_back(IMTextEntryPtr(new IMTextEntry)); |
828 | 214 | tab_iterator->areas_.push_front(entry); | 224 | tab_iterator.areas_.push_back(local_areas.back().GetPointer()); |
829 | 215 | } | 225 | } |
830 | 216 | 226 | ||
833 | 217 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 227 | auto entry = IMTextEntryPtr(new IMTextEntry); |
834 | 218 | tab_iterator->Prepend(entry); | 228 | tab_iterator.Prepend(entry.GetPointer()); |
835 | 219 | 229 | ||
837 | 220 | EXPECT_TRUE(tab_iterator->DefaultFocus() == entry); | 230 | EXPECT_EQ(tab_iterator.DefaultFocus(), entry.GetPointer()); |
838 | 221 | } | 231 | } |
839 | 222 | 232 | ||
840 | 223 | TEST_F(TestTabIterator, GetDefaultFocusEmpty) | 233 | TEST_F(TestTabIterator, GetDefaultFocusEmpty) |
841 | 224 | { | 234 | { |
843 | 225 | EXPECT_TRUE(tab_iterator->DefaultFocus() == nullptr); | 235 | EXPECT_EQ(tab_iterator.DefaultFocus(), nullptr); |
844 | 226 | } | 236 | } |
845 | 227 | 237 | ||
846 | 228 | TEST_F(TestTabIterator, FindKeyFocusAreaFromWindow) | 238 | TEST_F(TestTabIterator, FindKeyFocusAreaFromWindow) |
847 | 229 | { | 239 | { |
848 | 230 | nux::InputArea* current_focus_area = nux::GetWindowCompositor().GetKeyFocusArea(); | 240 | nux::InputArea* current_focus_area = nux::GetWindowCompositor().GetKeyFocusArea(); |
849 | 231 | // add the area to the iterator | 241 | // add the area to the iterator |
851 | 232 | tab_iterator->Prepend(current_focus_area); | 242 | tab_iterator.Prepend(current_focus_area); |
852 | 233 | 243 | ||
854 | 234 | EXPECT_TRUE(tab_iterator->FindKeyFocusArea(0, 0, 0) == current_focus_area); | 244 | EXPECT_EQ(tab_iterator.FindKeyFocusArea(0, 0, 0), current_focus_area); |
855 | 235 | } | 245 | } |
856 | 236 | 246 | ||
857 | 237 | TEST_F(TestTabIterator, FindKeyFocusFromIterator) | 247 | TEST_F(TestTabIterator, FindKeyFocusFromIterator) |
858 | 238 | { | 248 | { |
859 | 249 | std::vector<IMTextEntryPtr> local_areas; | ||
860 | 250 | |||
861 | 239 | for(int index=0; index < 10; ++index) | 251 | for(int index=0; index < 10; ++index) |
862 | 240 | { | 252 | { |
865 | 241 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 253 | local_areas.push_back(IMTextEntryPtr(new IMTextEntry)); |
866 | 242 | tab_iterator->areas_.push_front(entry); | 254 | tab_iterator.areas_.push_back(local_areas.back().GetPointer()); |
867 | 243 | } | 255 | } |
868 | 244 | 256 | ||
871 | 245 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 257 | auto entry = IMTextEntryPtr(new IMTextEntry); |
872 | 246 | tab_iterator->Prepend(entry); | 258 | tab_iterator.Prepend(entry.GetPointer()); |
873 | 247 | 259 | ||
875 | 248 | EXPECT_TRUE(tab_iterator->FindKeyFocusArea(0, 0, 0) == entry); | 260 | EXPECT_EQ(tab_iterator.FindKeyFocusArea(0, 0, 0), entry.GetPointer()); |
876 | 249 | } | 261 | } |
877 | 250 | 262 | ||
878 | 251 | TEST_F(TestTabIterator, FindKeyFocusAreaEmpty) | 263 | TEST_F(TestTabIterator, FindKeyFocusAreaEmpty) |
879 | 252 | { | 264 | { |
881 | 253 | EXPECT_TRUE(tab_iterator->FindKeyFocusArea(0, 0, 0) == nullptr); | 265 | EXPECT_EQ(tab_iterator.FindKeyFocusArea(0, 0, 0), nullptr); |
882 | 254 | } | 266 | } |
883 | 255 | 267 | ||
884 | 256 | TEST_F(TestTabIterator, KeyNavIterationEmpty) | 268 | TEST_F(TestTabIterator, KeyNavIterationEmpty) |
885 | 257 | { | 269 | { |
888 | 258 | nux::Area* area = tab_iterator->KeyNavIteration(nux::KEY_NAV_TAB_PREVIOUS); | 270 | nux::Area* area = tab_iterator.KeyNavIteration(nux::KEY_NAV_TAB_PREVIOUS); |
889 | 259 | EXPECT_TRUE(area == nullptr); | 271 | EXPECT_EQ(area, nullptr); |
890 | 260 | } | 272 | } |
891 | 261 | 273 | ||
892 | 262 | TEST_F(TestTabIterator, KeyNavIterationWrongDirection) | 274 | TEST_F(TestTabIterator, KeyNavIterationWrongDirection) |
893 | 263 | { | 275 | { |
896 | 264 | nux::Area* area = tab_iterator->KeyNavIteration(nux::KEY_NAV_NONE); | 276 | nux::Area* area = tab_iterator.KeyNavIteration(nux::KEY_NAV_NONE); |
897 | 265 | EXPECT_TRUE(area == nullptr); | 277 | EXPECT_EQ(area, nullptr); |
898 | 266 | } | 278 | } |
899 | 267 | 279 | ||
900 | 268 | TEST_F(TestTabIterator, KeyNavIterationWithNoCurrentSelectionAndPreviousMove) | 280 | TEST_F(TestTabIterator, KeyNavIterationWithNoCurrentSelectionAndPreviousMove) |
901 | 269 | { | 281 | { |
906 | 270 | unity::IMTextEntry* first_entry = new unity::IMTextEntry(); | 282 | auto first_entry = IMTextEntryPtr(new IMTextEntry); |
907 | 271 | unity::IMTextEntry* second_entry = new unity::IMTextEntry(); | 283 | auto second_entry = IMTextEntryPtr(new IMTextEntry); |
908 | 272 | tab_iterator->areas_.push_front(second_entry); | 284 | tab_iterator.areas_.push_back(first_entry.GetPointer()); |
909 | 273 | tab_iterator->areas_.push_front(first_entry); | 285 | tab_iterator.areas_.push_back(second_entry.GetPointer()); |
910 | 274 | 286 | ||
912 | 275 | unity::IMTextEntry* result = (unity::IMTextEntry*) tab_iterator->KeyNavIteration( | 287 | IMTextEntry* result = (IMTextEntry*) tab_iterator.KeyNavIteration( |
913 | 276 | nux::KEY_NAV_TAB_PREVIOUS); | 288 | nux::KEY_NAV_TAB_PREVIOUS); |
914 | 277 | 289 | ||
916 | 278 | EXPECT_TRUE(result == *tab_iterator->areas_.end()); | 290 | EXPECT_EQ(result, *tab_iterator.areas_.rbegin()); |
917 | 291 | EXPECT_EQ(result, second_entry.GetPointer()); | ||
918 | 279 | } | 292 | } |
919 | 280 | 293 | ||
920 | 281 | TEST_F(TestTabIterator, KeyNavIterationNoCurrentSelectionAndNextMove) | 294 | TEST_F(TestTabIterator, KeyNavIterationNoCurrentSelectionAndNextMove) |
921 | 282 | { | 295 | { |
926 | 283 | unity::IMTextEntry* first_entry = new unity::IMTextEntry(); | 296 | auto first_entry = IMTextEntryPtr(new IMTextEntry); |
927 | 284 | unity::IMTextEntry* second_entry = new unity::IMTextEntry(); | 297 | auto second_entry = IMTextEntryPtr(new IMTextEntry); |
928 | 285 | tab_iterator->areas_.push_front(second_entry); | 298 | tab_iterator.areas_.push_back(first_entry.GetPointer()); |
929 | 286 | tab_iterator->areas_.push_front(first_entry); | 299 | tab_iterator.areas_.push_back(second_entry.GetPointer()); |
930 | 287 | 300 | ||
932 | 288 | unity::IMTextEntry* result = (unity::IMTextEntry*) tab_iterator->KeyNavIteration( | 301 | IMTextEntry* result = (IMTextEntry*) tab_iterator.KeyNavIteration( |
933 | 289 | nux::KEY_NAV_TAB_NEXT); | 302 | nux::KEY_NAV_TAB_NEXT); |
934 | 290 | 303 | ||
936 | 291 | EXPECT_TRUE(result == *tab_iterator->areas_.begin()); | 304 | EXPECT_EQ(result, *tab_iterator.areas_.begin()); |
937 | 305 | EXPECT_EQ(result, first_entry.GetPointer()); | ||
938 | 292 | } | 306 | } |
939 | 293 | 307 | ||
940 | 294 | TEST_F(TestTabIterator, KeyNavIterationWithPreviousSelectionIsFirstArea) | 308 | TEST_F(TestTabIterator, KeyNavIterationWithPreviousSelectionIsFirstArea) |
941 | 295 | { | 309 | { |
950 | 296 | unity::IMTextEntry* first_entry = new unity::IMTextEntry(); | 310 | auto first_entry = IMTextEntryPtr(new IMTextEntry); |
951 | 297 | unity::IMTextEntry* second_entry = new unity::IMTextEntry(); | 311 | auto second_entry = IMTextEntryPtr(new IMTextEntry); |
952 | 298 | tab_iterator->areas_.push_front(second_entry); | 312 | tab_iterator.areas_.push_back(first_entry.GetPointer()); |
953 | 299 | tab_iterator->areas_.push_front(first_entry); | 313 | tab_iterator.areas_.push_back(second_entry.GetPointer()); |
954 | 300 | 314 | ||
955 | 301 | nux::GetWindowCompositor().SetKeyFocusArea(*tab_iterator->areas_.begin()); | 315 | nux::GetWindowCompositor().SetKeyFocusArea(first_entry.GetPointer()); |
956 | 302 | 316 | ||
957 | 303 | unity::IMTextEntry* result = (unity::IMTextEntry*) tab_iterator->KeyNavIteration( | 317 | IMTextEntry* result = (IMTextEntry*) tab_iterator.KeyNavIteration( |
958 | 304 | nux::KEY_NAV_TAB_PREVIOUS); | 318 | nux::KEY_NAV_TAB_PREVIOUS); |
959 | 305 | 319 | ||
961 | 306 | EXPECT_TRUE(result == *tab_iterator->areas_.end()); | 320 | EXPECT_EQ(result, *tab_iterator.areas_.rbegin()); |
962 | 321 | EXPECT_EQ(result, second_entry.GetPointer()); | ||
963 | 307 | } | 322 | } |
964 | 308 | 323 | ||
965 | 309 | TEST_F(TestTabIterator, KeyNavIterationWithPreviousSelectionIsNotFirst) | 324 | TEST_F(TestTabIterator, KeyNavIterationWithPreviousSelectionIsNotFirst) |
966 | 310 | { | 325 | { |
987 | 311 | for(int index=0; index < 10; ++index) | 326 | std::vector<IMTextEntryPtr> local_areas; |
988 | 312 | { | 327 | |
989 | 313 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 328 | for(int index=0; index < 10; ++index) |
990 | 314 | tab_iterator->areas_.push_front(entry); | 329 | { |
991 | 315 | } | 330 | local_areas.push_back(IMTextEntryPtr(new IMTextEntry)); |
992 | 316 | 331 | tab_iterator.areas_.push_back(local_areas.back().GetPointer()); | |
993 | 317 | unity::IMTextEntry* first_entry = new unity::IMTextEntry(); | 332 | } |
994 | 318 | unity::IMTextEntry* second_entry = new unity::IMTextEntry(); | 333 | |
995 | 319 | tab_iterator->areas_.push_front(second_entry); | 334 | auto first_entry = IMTextEntryPtr(new IMTextEntry); |
996 | 320 | tab_iterator->areas_.push_front(first_entry); | 335 | auto second_entry = IMTextEntryPtr(new IMTextEntry); |
997 | 321 | 336 | tab_iterator.areas_.push_back(first_entry.GetPointer()); | |
998 | 322 | for(int index=0; index < 10; ++index) | 337 | tab_iterator.areas_.push_back(second_entry.GetPointer()); |
999 | 323 | { | 338 | |
1000 | 324 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 339 | for(int index=0; index < 10; ++index) |
1001 | 325 | tab_iterator->areas_.push_front(entry); | 340 | { |
1002 | 326 | } | 341 | local_areas.push_back(IMTextEntryPtr(new IMTextEntry)); |
1003 | 327 | 342 | tab_iterator.areas_.push_back(local_areas.back().GetPointer()); | |
1004 | 328 | nux::GetWindowCompositor().SetKeyFocusArea(second_entry); | 343 | } |
1005 | 329 | 344 | ||
1006 | 330 | unity::IMTextEntry* result = (unity::IMTextEntry*) tab_iterator->KeyNavIteration( | 345 | nux::GetWindowCompositor().SetKeyFocusArea(second_entry.GetPointer()); |
1007 | 346 | |||
1008 | 347 | IMTextEntry* result = (IMTextEntry*) tab_iterator.KeyNavIteration( | ||
1009 | 331 | nux::KEY_NAV_TAB_PREVIOUS); | 348 | nux::KEY_NAV_TAB_PREVIOUS); |
1011 | 332 | EXPECT_TRUE(result == first_entry); | 349 | EXPECT_EQ(result, first_entry.GetPointer()); |
1012 | 333 | } | 350 | } |
1013 | 334 | 351 | ||
1014 | 335 | TEST_F(TestTabIterator, KeyNavIterationWithNextSelectionIsLast) | 352 | TEST_F(TestTabIterator, KeyNavIterationWithNextSelectionIsLast) |
1015 | 336 | { | 353 | { |
1026 | 337 | unity::IMTextEntry* first_entry = new unity::IMTextEntry(); | 354 | auto first_entry = IMTextEntryPtr(new IMTextEntry); |
1027 | 338 | unity::IMTextEntry* second_entry = new unity::IMTextEntry(); | 355 | auto second_entry = IMTextEntryPtr(new IMTextEntry); |
1028 | 339 | unity::IMTextEntry* not_in_areas = new unity::IMTextEntry(); | 356 | auto not_in_areas = IMTextEntryPtr(new IMTextEntry); |
1029 | 340 | 357 | ||
1030 | 341 | tab_iterator->areas_.push_front(second_entry); | 358 | tab_iterator.areas_.push_back(first_entry.GetPointer()); |
1031 | 342 | tab_iterator->areas_.push_front(first_entry); | 359 | tab_iterator.areas_.push_back(second_entry.GetPointer()); |
1032 | 343 | 360 | ||
1033 | 344 | nux::GetWindowCompositor().SetKeyFocusArea(not_in_areas); | 361 | nux::GetWindowCompositor().SetKeyFocusArea(not_in_areas.GetPointer()); |
1034 | 345 | 362 | ||
1035 | 346 | unity::IMTextEntry* result = (unity::IMTextEntry*) tab_iterator->KeyNavIteration( | 363 | IMTextEntry* result = (IMTextEntry*) tab_iterator.KeyNavIteration( |
1036 | 347 | nux::KEY_NAV_TAB_NEXT); | 364 | nux::KEY_NAV_TAB_NEXT); |
1037 | 348 | 365 | ||
1039 | 349 | EXPECT_TRUE(result == *tab_iterator->areas_.begin()); | 366 | EXPECT_EQ(result, *tab_iterator.areas_.begin()); |
1040 | 367 | EXPECT_EQ(result, first_entry.GetPointer()); | ||
1041 | 350 | } | 368 | } |
1042 | 351 | 369 | ||
1043 | 352 | TEST_F(TestTabIterator, KeyNavIterationWithNextSelectionIsNotLast) | 370 | TEST_F(TestTabIterator, KeyNavIterationWithNextSelectionIsNotLast) |
1044 | 353 | { | 371 | { |
1065 | 354 | for(int index=0; index < 10; ++index) | 372 | std::vector<IMTextEntryPtr> local_areas; |
1066 | 355 | { | 373 | |
1067 | 356 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 374 | for(int index=0; index < 10; ++index) |
1068 | 357 | tab_iterator->areas_.push_front(entry); | 375 | { |
1069 | 358 | } | 376 | local_areas.push_back(IMTextEntryPtr(new IMTextEntry)); |
1070 | 359 | 377 | tab_iterator.areas_.push_back(local_areas.back().GetPointer()); | |
1071 | 360 | unity::IMTextEntry* first_entry = new unity::IMTextEntry(); | 378 | } |
1072 | 361 | unity::IMTextEntry* second_entry = new unity::IMTextEntry(); | 379 | |
1073 | 362 | tab_iterator->areas_.push_front(second_entry); | 380 | auto first_entry = IMTextEntryPtr(new IMTextEntry); |
1074 | 363 | tab_iterator->areas_.push_front(first_entry); | 381 | auto second_entry = IMTextEntryPtr(new IMTextEntry); |
1075 | 364 | 382 | tab_iterator.areas_.push_back(first_entry.GetPointer()); | |
1076 | 365 | for(int index=0; index < 10; ++index) | 383 | tab_iterator.areas_.push_back(second_entry.GetPointer()); |
1077 | 366 | { | 384 | |
1078 | 367 | unity::IMTextEntry* entry = new unity::IMTextEntry(); | 385 | for(int index=0; index < 10; ++index) |
1079 | 368 | tab_iterator->areas_.push_front(entry); | 386 | { |
1080 | 369 | } | 387 | local_areas.push_back(IMTextEntryPtr(new IMTextEntry)); |
1081 | 370 | 388 | tab_iterator.areas_.push_back(local_areas.back().GetPointer()); | |
1082 | 371 | nux::GetWindowCompositor().SetKeyFocusArea(first_entry); | 389 | } |
1083 | 372 | 390 | nux::GetWindowCompositor().SetKeyFocusArea(first_entry.GetPointer()); | |
1084 | 373 | unity::IMTextEntry* result = (unity::IMTextEntry*) tab_iterator->KeyNavIteration( | 391 | |
1085 | 392 | IMTextEntry* result = (IMTextEntry*) tab_iterator.KeyNavIteration( | ||
1086 | 374 | nux::KEY_NAV_TAB_NEXT); | 393 | nux::KEY_NAV_TAB_NEXT); |
1088 | 375 | EXPECT_TRUE(result == second_entry); | 394 | EXPECT_EQ(result, second_entry.GetPointer()); |
1089 | 376 | } | 395 | } |
1090 | 377 | 396 | ||
1091 | 378 | } // previews | 397 | } // previews |
1092 | 379 | 398 | ||
1093 | === modified file 'tests/test_time_util.cpp' | |||
1094 | --- tests/test_time_util.cpp 2012-12-01 03:51:10 +0000 | |||
1095 | +++ tests/test_time_util.cpp 2013-07-18 23:02:25 +0000 | |||
1096 | @@ -26,7 +26,7 @@ | |||
1097 | 26 | 26 | ||
1098 | 27 | TEST(TestTimeUtil, Testin32BufferOverflow) | 27 | TEST(TestTimeUtil, Testin32BufferOverflow) |
1099 | 28 | { | 28 | { |
1101 | 29 | struct timespec start, end; | 29 | struct timespec start {0, 0}, end {0, 0}; |
1102 | 30 | unity::TimeUtil::SetTimeStruct(&start, &end); | 30 | unity::TimeUtil::SetTimeStruct(&start, &end); |
1103 | 31 | 31 | ||
1104 | 32 | end.tv_sec = start.tv_sec + INT32_MAX; | 32 | end.tv_sec = start.tv_sec + INT32_MAX; |
1105 | 33 | 33 | ||
1106 | === modified file 'tests/test_xdnd_manager_imp.cpp' | |||
1107 | --- tests/test_xdnd_manager_imp.cpp 2012-11-20 13:11:53 +0000 | |||
1108 | +++ tests/test_xdnd_manager_imp.cpp 2013-07-18 23:02:25 +0000 | |||
1109 | @@ -59,6 +59,7 @@ | |||
1110 | 59 | xevent.type = ClientMessage; | 59 | xevent.type = ClientMessage; |
1111 | 60 | xevent.xany.display = nux::GetGraphicsDisplay()->GetX11Display(); | 60 | xevent.xany.display = nux::GetGraphicsDisplay()->GetX11Display(); |
1112 | 61 | xevent.xclient.message_type = XInternAtom(xevent.xany.display, "XdndEnter", false); | 61 | xevent.xclient.message_type = XInternAtom(xevent.xany.display, "XdndEnter", false); |
1113 | 62 | xevent.xclient.format = 0; | ||
1114 | 62 | xevent.xclient.data.l[1] = 5 >> 24; | 63 | xevent.xclient.data.l[1] = 5 >> 24; |
1115 | 63 | 64 | ||
1116 | 64 | nux::GetGraphicsDisplay()->ProcessXEvent(xevent, true); | 65 | nux::GetGraphicsDisplay()->ProcessXEvent(xevent, true); |
1117 | 65 | 66 | ||
1118 | === modified file 'unity-shared/PlacesOverlayVScrollBar.cpp' | |||
1119 | --- unity-shared/PlacesOverlayVScrollBar.cpp 2013-04-02 23:38:31 +0000 | |||
1120 | +++ unity-shared/PlacesOverlayVScrollBar.cpp 2013-07-18 23:02:25 +0000 | |||
1121 | @@ -91,7 +91,7 @@ | |||
1122 | 91 | 91 | ||
1123 | 92 | void PlacesOverlayVScrollBar::SetupAnimation(int start, int stop, int milliseconds) | 92 | void PlacesOverlayVScrollBar::SetupAnimation(int start, int stop, int milliseconds) |
1124 | 93 | { | 93 | { |
1126 | 94 | tweening_connection_.disconnect(); | 94 | tweening_connection_->disconnect(); |
1127 | 95 | delta_update_ = 0; | 95 | delta_update_ = 0; |
1128 | 96 | 96 | ||
1129 | 97 | animation_.SetDuration(milliseconds); | 97 | animation_.SetDuration(milliseconds); |
1130 | 98 | 98 | ||
1131 | === modified file 'unity-shared/PlacesOverlayVScrollBar.h' | |||
1132 | --- unity-shared/PlacesOverlayVScrollBar.h 2012-12-13 14:26:56 +0000 | |||
1133 | +++ unity-shared/PlacesOverlayVScrollBar.h 2013-07-18 23:02:25 +0000 | |||
1134 | @@ -23,6 +23,7 @@ | |||
1135 | 23 | #include <Nux/Nux.h> | 23 | #include <Nux/Nux.h> |
1136 | 24 | #include <Nux/InputAreaProximity.h> | 24 | #include <Nux/InputAreaProximity.h> |
1137 | 25 | #include <NuxCore/Animation.h> | 25 | #include <NuxCore/Animation.h> |
1138 | 26 | #include <UnityCore/ConnectionManager.h> | ||
1139 | 26 | #include <memory> | 27 | #include <memory> |
1140 | 27 | 28 | ||
1141 | 28 | #include "unity-shared/PlacesVScrollBar.h" | 29 | #include "unity-shared/PlacesVScrollBar.h" |
1142 | @@ -94,7 +95,7 @@ | |||
1143 | 94 | nux::InputAreaProximity area_prox_; | 95 | nux::InputAreaProximity area_prox_; |
1144 | 95 | 96 | ||
1145 | 96 | nux::animation::AnimateValue<int> animation_; | 97 | nux::animation::AnimateValue<int> animation_; |
1147 | 97 | sigc::connection tweening_connection_; | 98 | connection::Wrapper tweening_connection_; |
1148 | 98 | 99 | ||
1149 | 99 | nux::ObjectPtr<nux::BaseTexture> connector_texture_; | 100 | nux::ObjectPtr<nux::BaseTexture> connector_texture_; |
1150 | 100 | 101 |
LGTM