Merge lp:~azzar1/unity/lp-1238063 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Stephen M. Webb
Approved revision: no longer in the source branch.
Merged at revision: 3904
Proposed branch: lp:~azzar1/unity/lp-1238063
Merge into: lp:unity
Diff against target: 977 lines (+197/-192)
13 files modified
launcher/EdgeBarrierController.cpp (+11/-6)
launcher/EdgeBarrierController.h (+1/-1)
launcher/EdgeBarrierControllerPrivate.h (+3/-3)
launcher/Launcher.cpp (+1/-1)
launcher/Launcher.h (+1/-1)
launcher/PointerBarrier.cpp (+1/-1)
launcher/PointerBarrier.h (+2/-2)
panel/PanelView.cpp (+1/-1)
panel/PanelView.h (+1/-1)
tests/test_edge_barrier_controller.cpp (+134/-134)
tests/test_launcher.cpp (+7/-7)
tests/test_panel_view.cpp (+2/-2)
tests/test_pointer_barrier.cpp (+32/-32)
To merge this branch: bzr merge lp:~azzar1/unity/lp-1238063
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Stephen M. Webb (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+244236@code.launchpad.net

Commit message

Use std::weak_ptr to avoid referencing an invalid barrier.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Looks very nice, check my comments.

Revision history for this message
Andrea Azzarone (azzar1) wrote :

Done

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Stephen M. Webb (bregma) wrote :

OK.

review: Approve
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'launcher/EdgeBarrierController.cpp'
--- launcher/EdgeBarrierController.cpp 2014-02-27 05:30:25 +0000
+++ launcher/EdgeBarrierController.cpp 2015-01-14 02:47:10 +0000
@@ -318,7 +318,7 @@
318 decaymulator_.value = 0;318 decaymulator_.value = 0;
319}319}
320320
321void EdgeBarrierController::Impl::BarrierPush(PointerBarrierWrapper* owner, BarrierEvent::Ptr const& event)321void EdgeBarrierController::Impl::BarrierPush(PointerBarrierWrapper::Ptr const& owner, BarrierEvent::Ptr const& event)
322{322{
323 if ((owner->orientation == VERTICAL and EventIsInsideYBreakZone(event)) or323 if ((owner->orientation == VERTICAL and EventIsInsideYBreakZone(event)) or
324 (owner->orientation == HORIZONTAL and EventIsInsideXBreakZone(event)))324 (owner->orientation == HORIZONTAL and EventIsInsideXBreakZone(event)))
@@ -368,7 +368,7 @@
368 return false;368 return false;
369}369}
370370
371void EdgeBarrierController::Impl::OnPointerBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr const& event)371void EdgeBarrierController::Impl::OnPointerBarrierEvent(PointerBarrierWrapper::Ptr const& owner, BarrierEvent::Ptr const& event)
372{372{
373 if (owner->released)373 if (owner->released)
374 {374 {
@@ -418,7 +418,7 @@
418 }418 }
419}419}
420420
421void EdgeBarrierController::Impl::BarrierRelease(PointerBarrierWrapper* owner, int event)421void EdgeBarrierController::Impl::BarrierRelease(PointerBarrierWrapper::Ptr const& owner, int event)
422{422{
423 owner->ReleaseBarrier(event);423 owner->ReleaseBarrier(event);
424 owner->released = true;424 owner->released = true;
@@ -428,9 +428,14 @@
428 (owner->release_once() && (!release_timeout_ || !release_timeout_->IsRunning())))428 (owner->release_once() && (!release_timeout_ || !release_timeout_->IsRunning())))
429 {429 {
430 unsigned duration = parent_->options()->edge_passed_disabled_ms;430 unsigned duration = parent_->options()->edge_passed_disabled_ms;
431 release_timeout_.reset(new glib::Timeout(duration, [owner] {431
432 owner->released = false;432 std::weak_ptr<PointerBarrierWrapper> owner_weak(owner);
433 owner->release_once = false;433 release_timeout_.reset(new glib::Timeout(duration, [owner_weak] {
434 if (PointerBarrierWrapper::Ptr const& owner = owner_weak.lock())
435 {
436 owner->released = false;
437 owner->release_once = false;
438 }
434 return false;439 return false;
435 }));440 }));
436 }441 }
437442
=== modified file 'launcher/EdgeBarrierController.h'
--- launcher/EdgeBarrierController.h 2013-11-06 11:21:43 +0000
+++ launcher/EdgeBarrierController.h 2015-01-14 02:47:10 +0000
@@ -37,7 +37,7 @@
37 };37 };
3838
39 virtual ~EdgeBarrierSubscriber() {}39 virtual ~EdgeBarrierSubscriber() {}
40 virtual Result HandleBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event) = 0;40 virtual Result HandleBarrierEvent(PointerBarrierWrapper::Ptr const& owner, BarrierEvent::Ptr event) = 0;
41};41};
4242
43class EdgeBarrierController : public sigc::trackable43class EdgeBarrierController : public sigc::trackable
4444
=== modified file 'launcher/EdgeBarrierControllerPrivate.h'
--- launcher/EdgeBarrierControllerPrivate.h 2014-02-27 05:30:25 +0000
+++ launcher/EdgeBarrierControllerPrivate.h 2015-01-14 02:47:10 +0000
@@ -44,9 +44,9 @@
44 void OnUScreenChanged(int primary, std::vector<nux::Geometry> const& layout);44 void OnUScreenChanged(int primary, std::vector<nux::Geometry> const& layout);
45 void OnOptionsChanged();45 void OnOptionsChanged();
4646
47 void OnPointerBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr const& event);47 void OnPointerBarrierEvent(PointerBarrierWrapper::Ptr const& owner, BarrierEvent::Ptr const& event);
48 void BarrierPush(PointerBarrierWrapper* owner, BarrierEvent::Ptr const& event);48 void BarrierPush(PointerBarrierWrapper::Ptr const& owner, BarrierEvent::Ptr const& event);
49 void BarrierRelease(PointerBarrierWrapper* owner, int event);49 void BarrierRelease(PointerBarrierWrapper::Ptr const& owner, int event);
50 void BarrierReset();50 void BarrierReset();
5151
52 bool EventIsInsideYBreakZone(BarrierEvent::Ptr const& event);52 bool EventIsInsideYBreakZone(BarrierEvent::Ptr const& event);
5353
=== modified file 'launcher/Launcher.cpp'
--- launcher/Launcher.cpp 2014-09-04 22:11:33 +0000
+++ launcher/Launcher.cpp 2015-01-14 02:47:10 +0000
@@ -2224,7 +2224,7 @@
22242224
2225#ifdef USE_X112225#ifdef USE_X11
22262226
2227ui::EdgeBarrierSubscriber::Result Launcher::HandleBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event)2227ui::EdgeBarrierSubscriber::Result Launcher::HandleBarrierEvent(ui::PointerBarrierWrapper::Ptr const& owner, ui::BarrierEvent::Ptr event)
2228{2228{
2229 if (hide_machine_.GetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE))2229 if (hide_machine_.GetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE))
2230 {2230 {
22312231
=== modified file 'launcher/Launcher.h'
--- launcher/Launcher.h 2014-03-17 20:58:25 +0000
+++ launcher/Launcher.h 2015-01-14 02:47:10 +0000
@@ -200,7 +200,7 @@
200#endif200#endif
201201
202#ifdef USE_X11202#ifdef USE_X11
203 ui::EdgeBarrierSubscriber::Result HandleBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event);203 ui::EdgeBarrierSubscriber::Result HandleBarrierEvent(ui::PointerBarrierWrapper::Ptr const& owner, ui::BarrierEvent::Ptr event);
204#endif204#endif
205205
206 void OnExpoChanged();206 void OnExpoChanged();
207207
=== modified file 'launcher/PointerBarrier.cpp'
--- launcher/PointerBarrier.cpp 2013-08-07 18:50:10 +0000
+++ launcher/PointerBarrier.cpp 2015-01-14 02:47:10 +0000
@@ -101,7 +101,7 @@
101{101{
102 auto event = std::make_shared<BarrierEvent>(x, y, velocity, event_id);102 auto event = std::make_shared<BarrierEvent>(x, y, velocity, event_id);
103103
104 barrier_event.emit(this, event);104 barrier_event.emit(shared_from_this(), event);
105}105}
106106
107bool PointerBarrierWrapper::IsFirstEvent() const107bool PointerBarrierWrapper::IsFirstEvent() const
108108
=== modified file 'launcher/PointerBarrier.h'
--- launcher/PointerBarrier.h 2013-08-08 14:43:50 +0000
+++ launcher/PointerBarrier.h 2015-01-14 02:47:10 +0000
@@ -62,7 +62,7 @@
62 HORIZONTAL62 HORIZONTAL
63};63};
6464
65class PointerBarrierWrapper : public sigc::trackable65class PointerBarrierWrapper : public sigc::trackable, public std::enable_shared_from_this<PointerBarrierWrapper>
66{66{
67public:67public:
68 typedef std::shared_ptr<PointerBarrierWrapper> Ptr;68 typedef std::shared_ptr<PointerBarrierWrapper> Ptr;
@@ -94,7 +94,7 @@
94 virtual void DestroyBarrier();94 virtual void DestroyBarrier();
95 virtual void ReleaseBarrier(int event_id);95 virtual void ReleaseBarrier(int event_id);
9696
97 sigc::signal<void, PointerBarrierWrapper*, BarrierEvent::Ptr> barrier_event;97 sigc::signal<void, PointerBarrierWrapper::Ptr const&, BarrierEvent::Ptr> barrier_event;
9898
99 bool IsFirstEvent() const;99 bool IsFirstEvent() const;
100100
101101
=== modified file 'panel/PanelView.cpp'
--- panel/PanelView.cpp 2014-07-30 00:49:35 +0000
+++ panel/PanelView.cpp 2015-01-14 02:47:10 +0000
@@ -811,7 +811,7 @@
811 return stored_dash_width_;811 return stored_dash_width_;
812}812}
813813
814ui::EdgeBarrierSubscriber::Result PanelView::HandleBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event)814ui::EdgeBarrierSubscriber::Result PanelView::HandleBarrierEvent(ui::PointerBarrierWrapper::Ptr const& owner, ui::BarrierEvent::Ptr event)
815{815{
816 if (WindowManager::Default().IsAnyWindowMoving())816 if (WindowManager::Default().IsAnyWindowMoving())
817 return ui::EdgeBarrierSubscriber::Result::IGNORED;817 return ui::EdgeBarrierSubscriber::Result::IGNORED;
818818
=== modified file 'panel/PanelView.h'
--- panel/PanelView.h 2014-03-06 16:26:34 +0000
+++ panel/PanelView.h 2015-01-14 02:47:10 +0000
@@ -73,7 +73,7 @@
7373
74 bool IsMouseInsideIndicator(nux::Point const& mouse_position) const;74 bool IsMouseInsideIndicator(nux::Point const& mouse_position) const;
7575
76 ui::EdgeBarrierSubscriber::Result HandleBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event) override;76 ui::EdgeBarrierSubscriber::Result HandleBarrierEvent(ui::PointerBarrierWrapper::Ptr const& owner, ui::BarrierEvent::Ptr event) override;
7777
78protected:78protected:
79 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);79 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
8080
=== modified file 'tests/test_edge_barrier_controller.cpp'
--- tests/test_edge_barrier_controller.cpp 2013-11-06 11:21:43 +0000
+++ tests/test_edge_barrier_controller.cpp 2015-01-14 02:47:10 +0000
@@ -56,7 +56,7 @@
56 : handle_result_(result)56 : handle_result_(result)
57 {}57 {}
5858
59 EdgeBarrierSubscriber::Result HandleBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event)59 EdgeBarrierSubscriber::Result HandleBarrierEvent(PointerBarrierWrapper::Ptr const& owner, BarrierEvent::Ptr event)
60 {60 {
61 return handle_result_;61 return handle_result_;
62 }62 }
@@ -89,7 +89,7 @@
89 }89 }
90 }90 }
9191
92 void ProcessBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event)92 void ProcessBarrierEvent(PointerBarrierWrapper::Ptr const& owner, BarrierEvent::Ptr event)
93 {93 {
94 GetPrivateImpl()->OnPointerBarrierEvent(owner, event);94 GetPrivateImpl()->OnPointerBarrierEvent(owner, event);
95 }95 }
@@ -203,11 +203,11 @@
203 TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED);203 TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED);
204 bc.AddVerticalSubscriber(&handling_subscriber, monitor);204 bc.AddVerticalSubscriber(&handling_subscriber, monitor);
205205
206 MockPointerBarrierWrapper owner(monitor, false, VERTICAL);206 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, VERTICAL);
207 auto breaking_barrier_event = MakeBarrierEvent(0, true);207 auto breaking_barrier_event = MakeBarrierEvent(0, true);
208208
209 EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0);209 EXPECT_CALL(*owner, ReleaseBarrier(_)).Times(0);
210 ProcessBarrierEvent(&owner, breaking_barrier_event);210 ProcessBarrierEvent(owner, breaking_barrier_event);
211 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);211 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);
212}212}
213213
@@ -218,11 +218,11 @@
218 TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED);218 TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED);
219 bc.AddHorizontalSubscriber(&handling_subscriber, monitor);219 bc.AddHorizontalSubscriber(&handling_subscriber, monitor);
220220
221 MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);221 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, HORIZONTAL);
222 auto breaking_barrier_event = MakeBarrierEvent(0, true);222 auto breaking_barrier_event = MakeBarrierEvent(0, true);
223223
224 EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0);224 EXPECT_CALL(*owner, ReleaseBarrier(_)).Times(0);
225 ProcessBarrierEvent(&owner, breaking_barrier_event);225 ProcessBarrierEvent(owner, breaking_barrier_event);
226 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);226 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);
227}227}
228228
@@ -233,11 +233,11 @@
233 TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED);233 TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED);
234 bc.AddVerticalSubscriber(&handling_subscriber, monitor);234 bc.AddVerticalSubscriber(&handling_subscriber, monitor);
235235
236 MockPointerBarrierWrapper owner(monitor, true, VERTICAL);236 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, true, VERTICAL);
237 auto breaking_barrier_event = MakeBarrierEvent(5, true);237 auto breaking_barrier_event = MakeBarrierEvent(5, true);
238238
239 EXPECT_CALL(owner, ReleaseBarrier(5)).Times(1);239 EXPECT_CALL(*owner, ReleaseBarrier(5)).Times(1);
240 ProcessBarrierEvent(&owner, breaking_barrier_event);240 ProcessBarrierEvent(owner, breaking_barrier_event);
241}241}
242242
243TEST_F(TestEdgeBarrierController, ProcessHandledEventOnReleasedBarrierForHorizontalSubscriber)243TEST_F(TestEdgeBarrierController, ProcessHandledEventOnReleasedBarrierForHorizontalSubscriber)
@@ -247,118 +247,118 @@
247 TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED);247 TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED);
248 bc.AddHorizontalSubscriber(&handling_subscriber, monitor);248 bc.AddHorizontalSubscriber(&handling_subscriber, monitor);
249249
250 MockPointerBarrierWrapper owner(monitor, true, HORIZONTAL);250 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, true, HORIZONTAL);
251 auto breaking_barrier_event = MakeBarrierEvent(5, true);251 auto breaking_barrier_event = MakeBarrierEvent(5, true);
252252
253 EXPECT_CALL(owner, ReleaseBarrier(5)).Times(1);253 EXPECT_CALL(*owner, ReleaseBarrier(5)).Times(1);
254 ProcessBarrierEvent(&owner, breaking_barrier_event);254 ProcessBarrierEvent(owner, breaking_barrier_event);
255}255}
256256
257TEST_F(TestEdgeBarrierController, ProcessUnHandledEventBreakingBarrierForVerticalSubscriber)257TEST_F(TestEdgeBarrierController, ProcessUnHandledEventBreakingBarrierForVerticalSubscriber)
258{258{
259 int monitor = 1;259 int monitor = 1;
260260
261 MockPointerBarrierWrapper owner(monitor, false, VERTICAL);261 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, VERTICAL);
262 int breaking_id = 12345;262 int breaking_id = 12345;
263 auto breaking_barrier_event = MakeBarrierEvent(breaking_id, true);263 auto breaking_barrier_event = MakeBarrierEvent(breaking_id, true);
264264
265 EXPECT_CALL(owner, ReleaseBarrier(breaking_id));265 EXPECT_CALL(*owner, ReleaseBarrier(breaking_id));
266 ProcessBarrierEvent(&owner, breaking_barrier_event);266 ProcessBarrierEvent(owner, breaking_barrier_event);
267}267}
268268
269TEST_F(TestEdgeBarrierController, ProcessUnHandledEventBreakingBarrierForHorizontalSubscriber)269TEST_F(TestEdgeBarrierController, ProcessUnHandledEventBreakingBarrierForHorizontalSubscriber)
270{270{
271 int monitor = 1;271 int monitor = 1;
272272
273 MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);273 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, HORIZONTAL);
274 int breaking_id = 12345;274 int breaking_id = 12345;
275 auto breaking_barrier_event = MakeBarrierEvent(breaking_id, true);275 auto breaking_barrier_event = MakeBarrierEvent(breaking_id, true);
276276
277 EXPECT_CALL(owner, ReleaseBarrier(breaking_id));277 EXPECT_CALL(*owner, ReleaseBarrier(breaking_id));
278 ProcessBarrierEvent(&owner, breaking_barrier_event);278 ProcessBarrierEvent(owner, breaking_barrier_event);
279}279}
280280
281TEST_F(TestEdgeBarrierController, ProcessUnHandledEventBreakingBarrierOnMaxMonitorForVerticalSubscriber)281TEST_F(TestEdgeBarrierController, ProcessUnHandledEventBreakingBarrierOnMaxMonitorForVerticalSubscriber)
282{282{
283 int monitor = monitors::MAX;283 int monitor = monitors::MAX;
284284
285 MockPointerBarrierWrapper owner(monitor, false, VERTICAL);285 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, VERTICAL);
286 auto breaking_barrier_event = MakeBarrierEvent(0, true);286 auto breaking_barrier_event = MakeBarrierEvent(0, true);
287287
288 EXPECT_CALL(owner, ReleaseBarrier(_));288 EXPECT_CALL(*owner, ReleaseBarrier(_));
289 ProcessBarrierEvent(&owner, breaking_barrier_event);289 ProcessBarrierEvent(owner, breaking_barrier_event);
290}290}
291291
292TEST_F(TestEdgeBarrierController, ProcessUnHandledEventBreakingBarrierOnMaxMonitorForHorizontalSubscriber)292TEST_F(TestEdgeBarrierController, ProcessUnHandledEventBreakingBarrierOnMaxMonitorForHorizontalSubscriber)
293{293{
294 int monitor = monitors::MAX;294 int monitor = monitors::MAX;
295295
296 MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);296 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, HORIZONTAL);
297 auto breaking_barrier_event = MakeBarrierEvent(0, true);297 auto breaking_barrier_event = MakeBarrierEvent(0, true);
298298
299 EXPECT_CALL(owner, ReleaseBarrier(_));299 EXPECT_CALL(*owner, ReleaseBarrier(_));
300 ProcessBarrierEvent(&owner, breaking_barrier_event);300 ProcessBarrierEvent(owner, breaking_barrier_event);
301}301}
302302
303TEST_F(TestEdgeBarrierController, ProcessUnHandledEventNotBreakingBarrierForVerticalSubscriber)303TEST_F(TestEdgeBarrierController, ProcessUnHandledEventNotBreakingBarrierForVerticalSubscriber)
304{304{
305 int monitor = 2;305 int monitor = 2;
306306
307 MockPointerBarrierWrapper owner(monitor, false, VERTICAL);307 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, VERTICAL);
308 int not_breaking_id = 54321;308 int not_breaking_id = 54321;
309 auto not_breaking_barrier_event = MakeBarrierEvent(not_breaking_id, false);309 auto not_breaking_barrier_event = MakeBarrierEvent(not_breaking_id, false);
310310
311 EXPECT_CALL(owner, ReleaseBarrier(not_breaking_id)).Times(0);311 EXPECT_CALL(*owner, ReleaseBarrier(not_breaking_id)).Times(0);
312 ProcessBarrierEvent(&owner, not_breaking_barrier_event);312 ProcessBarrierEvent(owner, not_breaking_barrier_event);
313}313}
314314
315TEST_F(TestEdgeBarrierController, ProcessUnHandledEventNotBreakingBarrierForHorizontalSubscriber)315TEST_F(TestEdgeBarrierController, ProcessUnHandledEventNotBreakingBarrierForHorizontalSubscriber)
316{316{
317 int monitor = 2;317 int monitor = 2;
318318
319 MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);319 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, HORIZONTAL);
320 int not_breaking_id = 54321;320 int not_breaking_id = 54321;
321 auto not_breaking_barrier_event = MakeBarrierEvent(not_breaking_id, false);321 auto not_breaking_barrier_event = MakeBarrierEvent(not_breaking_id, false);
322322
323 EXPECT_CALL(owner, ReleaseBarrier(not_breaking_id)).Times(0);323 EXPECT_CALL(*owner, ReleaseBarrier(not_breaking_id)).Times(0);
324 ProcessBarrierEvent(&owner, not_breaking_barrier_event);324 ProcessBarrierEvent(owner, not_breaking_barrier_event);
325}325}
326326
327TEST_F(TestEdgeBarrierController, ProcessUnHandledEventOnReleasedBarrierForVerticalSubscriber)327TEST_F(TestEdgeBarrierController, ProcessUnHandledEventOnReleasedBarrierForVerticalSubscriber)
328{328{
329 int monitor = 2;329 int monitor = 2;
330330
331 MockPointerBarrierWrapper owner(monitor, true, VERTICAL);331 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, true, VERTICAL);
332 int not_breaking_id = 345678;332 int not_breaking_id = 345678;
333 auto not_breaking_barrier_event = MakeBarrierEvent(not_breaking_id, false);333 auto not_breaking_barrier_event = MakeBarrierEvent(not_breaking_id, false);
334334
335 EXPECT_CALL(owner, ReleaseBarrier(not_breaking_id));335 EXPECT_CALL(*owner, ReleaseBarrier(not_breaking_id));
336 ProcessBarrierEvent(&owner, not_breaking_barrier_event);336 ProcessBarrierEvent(owner, not_breaking_barrier_event);
337}337}
338338
339TEST_F(TestEdgeBarrierController, ProcessUnHandledEventOnReleasedBarrierForHorizontalSubscriber)339TEST_F(TestEdgeBarrierController, ProcessUnHandledEventOnReleasedBarrierForHorizontalSubscriber)
340{340{
341 int monitor = 2;341 int monitor = 2;
342342
343 MockPointerBarrierWrapper owner(monitor, true, HORIZONTAL);343 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, true, HORIZONTAL);
344 int not_breaking_id = 345678;344 int not_breaking_id = 345678;
345 auto not_breaking_barrier_event = MakeBarrierEvent(not_breaking_id, false);345 auto not_breaking_barrier_event = MakeBarrierEvent(not_breaking_id, false);
346346
347 EXPECT_CALL(owner, ReleaseBarrier(not_breaking_id));347 EXPECT_CALL(*owner, ReleaseBarrier(not_breaking_id));
348 ProcessBarrierEvent(&owner, not_breaking_barrier_event);348 ProcessBarrierEvent(owner, not_breaking_barrier_event);
349}349}
350350
351TEST_F(TestEdgeBarrierController, ProcessAlreadyHandledEventForVerticalSubscriber)351TEST_F(TestEdgeBarrierController, ProcessAlreadyHandledEventForVerticalSubscriber)
352{352{
353 int monitor = g_random_int_range(0, monitors::MAX);353 int monitor = g_random_int_range(0, monitors::MAX);
354354
355 MockPointerBarrierWrapper owner(monitor, false, VERTICAL);355 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, VERTICAL);
356 vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::ALREADY_HANDLED;356 vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::ALREADY_HANDLED;
357357
358 auto event = MakeBarrierEvent(g_random_int(), false);358 auto event = MakeBarrierEvent(g_random_int(), false);
359359
360 EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0);360 EXPECT_CALL(*owner, ReleaseBarrier(_)).Times(0);
361 ProcessBarrierEvent(&owner, event);361 ProcessBarrierEvent(owner, event);
362 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), event->velocity);362 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), event->velocity);
363}363}
364364
@@ -366,13 +366,13 @@
366{366{
367 int monitor = g_random_int_range(0, monitors::MAX);367 int monitor = g_random_int_range(0, monitors::MAX);
368368
369 MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);369 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, HORIZONTAL);
370 horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::ALREADY_HANDLED;370 horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::ALREADY_HANDLED;
371371
372 auto event = MakeBarrierEvent(g_random_int(), false);372 auto event = MakeBarrierEvent(g_random_int(), false);
373373
374 EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0);374 EXPECT_CALL(*owner, ReleaseBarrier(_)).Times(0);
375 ProcessBarrierEvent(&owner, event);375 ProcessBarrierEvent(owner, event);
376 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), event->velocity);376 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), event->velocity);
377}377}
378378
@@ -381,15 +381,15 @@
381 int monitor = g_random_int_range(0, monitors::MAX);381 int monitor = g_random_int_range(0, monitors::MAX);
382382
383 bc.sticky_edges = true;383 bc.sticky_edges = true;
384 MockPointerBarrierWrapper owner(monitor, false, VERTICAL);384 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, VERTICAL);
385 vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;385 vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
386386
387 auto event = MakeBarrierEvent(g_random_int(), false);387 auto event = MakeBarrierEvent(g_random_int(), false);
388388
389 EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0);389 EXPECT_CALL(*owner, ReleaseBarrier(_)).Times(0);
390 ProcessBarrierEvent(&owner, event);390 ProcessBarrierEvent(owner, event);
391 EXPECT_FALSE(owner.released());391 EXPECT_FALSE(owner->released());
392 EXPECT_FALSE(owner.release_once());392 EXPECT_FALSE(owner->release_once());
393 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), event->velocity);393 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), event->velocity);
394}394}
395395
@@ -398,15 +398,15 @@
398 int monitor = g_random_int_range(0, monitors::MAX);398 int monitor = g_random_int_range(0, monitors::MAX);
399399
400 bc.sticky_edges = true;400 bc.sticky_edges = true;
401 MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);401 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, HORIZONTAL);
402 horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;402 horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
403403
404 auto event = MakeBarrierEvent(g_random_int(), false);404 auto event = MakeBarrierEvent(g_random_int(), false);
405405
406 EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0);406 EXPECT_CALL(*owner, ReleaseBarrier(_)).Times(0);
407 ProcessBarrierEvent(&owner, event);407 ProcessBarrierEvent(owner, event);
408 EXPECT_FALSE(owner.released());408 EXPECT_FALSE(owner->released());
409 EXPECT_FALSE(owner.release_once());409 EXPECT_FALSE(owner->release_once());
410 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), event->velocity);410 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), event->velocity);
411}411}
412412
@@ -415,15 +415,15 @@
415 int monitor = g_random_int_range(0, monitors::MAX);415 int monitor = g_random_int_range(0, monitors::MAX);
416416
417 bc.sticky_edges = false;417 bc.sticky_edges = false;
418 MockPointerBarrierWrapper owner(monitor, false, VERTICAL);418 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, VERTICAL);
419 vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;419 vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
420420
421 auto event = MakeBarrierEvent(g_random_int(), false);421 auto event = MakeBarrierEvent(g_random_int(), false);
422422
423 EXPECT_CALL(owner, ReleaseBarrier(event->event_id));423 EXPECT_CALL(*owner, ReleaseBarrier(event->event_id));
424 ProcessBarrierEvent(&owner, event);424 ProcessBarrierEvent(owner, event);
425 EXPECT_TRUE(owner.released());425 EXPECT_TRUE(owner->released());
426 EXPECT_TRUE(owner.release_once());426 EXPECT_TRUE(owner->release_once());
427 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);427 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);
428}428}
429429
@@ -432,15 +432,15 @@
432 int monitor = g_random_int_range(0, monitors::MAX);432 int monitor = g_random_int_range(0, monitors::MAX);
433433
434 bc.sticky_edges = false;434 bc.sticky_edges = false;
435 MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);435 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, HORIZONTAL);
436 horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;436 horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
437437
438 auto event = MakeBarrierEvent(g_random_int(), false);438 auto event = MakeBarrierEvent(g_random_int(), false);
439439
440 EXPECT_CALL(owner, ReleaseBarrier(event->event_id));440 EXPECT_CALL(*owner, ReleaseBarrier(event->event_id));
441 ProcessBarrierEvent(&owner, event);441 ProcessBarrierEvent(owner, event);
442 EXPECT_TRUE(owner.released());442 EXPECT_TRUE(owner->released());
443 EXPECT_TRUE(owner.release_once());443 EXPECT_TRUE(owner->release_once());
444 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);444 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);
445}445}
446446
@@ -448,13 +448,13 @@
448{448{
449 int monitor = g_random_int_range(0, monitors::MAX);449 int monitor = g_random_int_range(0, monitors::MAX);
450450
451 MockPointerBarrierWrapper owner(monitor, false, VERTICAL);451 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, VERTICAL);
452 vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::NEEDS_RELEASE;452 vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::NEEDS_RELEASE;
453453
454 auto event = MakeBarrierEvent(g_random_int(), false);454 auto event = MakeBarrierEvent(g_random_int(), false);
455455
456 EXPECT_CALL(owner, ReleaseBarrier(event->event_id));456 EXPECT_CALL(*owner, ReleaseBarrier(event->event_id));
457 ProcessBarrierEvent(&owner, event);457 ProcessBarrierEvent(owner, event);
458 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);458 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);
459}459}
460460
@@ -462,100 +462,100 @@
462{462{
463 int monitor = g_random_int_range(0, monitors::MAX);463 int monitor = g_random_int_range(0, monitors::MAX);
464464
465 MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);465 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, HORIZONTAL);
466 horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::NEEDS_RELEASE;466 horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::NEEDS_RELEASE;
467467
468 auto event = MakeBarrierEvent(g_random_int(), false);468 auto event = MakeBarrierEvent(g_random_int(), false);
469469
470 EXPECT_CALL(owner, ReleaseBarrier(event->event_id));470 EXPECT_CALL(*owner, ReleaseBarrier(event->event_id));
471 ProcessBarrierEvent(&owner, event);471 ProcessBarrierEvent(owner, event);
472 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);472 EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);
473}473}
474474
475TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForVerticalSubscriber)475TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForVerticalSubscriber)
476{476{
477 int monitor = g_random_int_range(0, monitors::MAX);477 int monitor = g_random_int_range(0, monitors::MAX);
478 MockPointerBarrierWrapper owner(monitor, false, VERTICAL);478 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, VERTICAL);
479479
480 EXPECT_CALL(owner, ReleaseBarrier(1));480 EXPECT_CALL(*owner, ReleaseBarrier(1));
481 ProcessBarrierEvent(&owner, MakeBarrierEvent(1, true));481 ProcessBarrierEvent(owner, MakeBarrierEvent(1, true));
482 ASSERT_TRUE(owner.released());482 ASSERT_TRUE(owner->released());
483483
484 Utils::WaitForTimeoutMSec(bc.options()->edge_passed_disabled_ms);484 Utils::WaitForTimeoutMSec(bc.options()->edge_passed_disabled_ms);
485 EXPECT_FALSE(owner.released());485 EXPECT_FALSE(owner->released());
486}486}
487487
488TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForHoriziontalSubscriber)488TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForHoriziontalSubscriber)
489{489{
490 int monitor = g_random_int_range(0, monitors::MAX);490 int monitor = g_random_int_range(0, monitors::MAX);
491 MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);491 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, HORIZONTAL);
492492
493 EXPECT_CALL(owner, ReleaseBarrier(1));493 EXPECT_CALL(*owner, ReleaseBarrier(1));
494 ProcessBarrierEvent(&owner, MakeBarrierEvent(1, true));494 ProcessBarrierEvent(owner, MakeBarrierEvent(1, true));
495 ASSERT_TRUE(owner.released());495 ASSERT_TRUE(owner->released());
496496
497 Utils::WaitForTimeoutMSec(bc.options()->edge_passed_disabled_ms);497 Utils::WaitForTimeoutMSec(bc.options()->edge_passed_disabled_ms);
498 EXPECT_FALSE(owner.released());498 EXPECT_FALSE(owner->released());
499}499}
500500
501TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForNotHandledEventsForVerticalSubscriber)501TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForNotHandledEventsForVerticalSubscriber)
502{502{
503 int monitor = 0;503 int monitor = 0;
504 MockPointerBarrierWrapper owner(monitor, false, VERTICAL);504 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, VERTICAL);
505 vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;505 vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
506506
507 EXPECT_CALL(owner, ReleaseBarrier(5));507 EXPECT_CALL(*owner, ReleaseBarrier(5));
508 ProcessBarrierEvent(&owner, MakeBarrierEvent(5, true));508 ProcessBarrierEvent(owner, MakeBarrierEvent(5, true));
509 ASSERT_TRUE(owner.released());509 ASSERT_TRUE(owner->released());
510510
511 vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;511 vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
512 EXPECT_CALL(owner, ReleaseBarrier(6));512 EXPECT_CALL(*owner, ReleaseBarrier(6));
513 ProcessBarrierEvent(&owner, MakeBarrierEvent(6, false));513 ProcessBarrierEvent(owner, MakeBarrierEvent(6, false));
514}514}
515515
516TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForNotHandledEventsForHorizontalSubscriber)516TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForNotHandledEventsForHorizontalSubscriber)
517{517{
518 int monitor = 0;518 int monitor = 0;
519 MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);519 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, HORIZONTAL);
520 horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;520 horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
521521
522 EXPECT_CALL(owner, ReleaseBarrier(5));522 EXPECT_CALL(*owner, ReleaseBarrier(5));
523 ProcessBarrierEvent(&owner, MakeBarrierEvent(5, true));523 ProcessBarrierEvent(owner, MakeBarrierEvent(5, true));
524 ASSERT_TRUE(owner.released());524 ASSERT_TRUE(owner->released());
525525
526 horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;526 horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
527 EXPECT_CALL(owner, ReleaseBarrier(6));527 EXPECT_CALL(*owner, ReleaseBarrier(6));
528 ProcessBarrierEvent(&owner, MakeBarrierEvent(6, false));528 ProcessBarrierEvent(owner, MakeBarrierEvent(6, false));
529}529}
530530
531TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForHandledEventsForVerticalSubscriber)531TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForHandledEventsForVerticalSubscriber)
532{532{
533 int monitor = 0;533 int monitor = 0;
534 MockPointerBarrierWrapper owner(monitor, false, VERTICAL);534 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, VERTICAL);
535 vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;535 vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
536536
537 EXPECT_CALL(owner, ReleaseBarrier(5));537 EXPECT_CALL(*owner, ReleaseBarrier(5));
538 ProcessBarrierEvent(&owner, MakeBarrierEvent(5, true));538 ProcessBarrierEvent(owner, MakeBarrierEvent(5, true));
539 ASSERT_TRUE(owner.released());539 ASSERT_TRUE(owner->released());
540540
541 vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::HANDLED;541 vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::HANDLED;
542 EXPECT_CALL(owner, ReleaseBarrier(6)).Times(1);542 EXPECT_CALL(*owner, ReleaseBarrier(6)).Times(1);
543 ProcessBarrierEvent(&owner, MakeBarrierEvent(6, true));543 ProcessBarrierEvent(owner, MakeBarrierEvent(6, true));
544}544}
545545
546TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForHandledEventsForHoriziontalSubscriber)546TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForHandledEventsForHoriziontalSubscriber)
547{547{
548 int monitor = 0;548 int monitor = 0;
549 MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);549 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitor, false, HORIZONTAL);
550 horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;550 horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
551551
552 EXPECT_CALL(owner, ReleaseBarrier(5));552 EXPECT_CALL(*owner, ReleaseBarrier(5));
553 ProcessBarrierEvent(&owner, MakeBarrierEvent(5, true));553 ProcessBarrierEvent(owner, MakeBarrierEvent(5, true));
554 ASSERT_TRUE(owner.released());554 ASSERT_TRUE(owner->released());
555555
556 horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::HANDLED;556 horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::HANDLED;
557 EXPECT_CALL(owner, ReleaseBarrier(6)).Times(1);557 EXPECT_CALL(*owner, ReleaseBarrier(6)).Times(1);
558 ProcessBarrierEvent(&owner, MakeBarrierEvent(6, true));558 ProcessBarrierEvent(owner, MakeBarrierEvent(6, true));
559}559}
560560
561TEST_F(TestEdgeBarrierController, StickyEdgePropertyProxiesLauncherOption)561TEST_F(TestEdgeBarrierController, StickyEdgePropertyProxiesLauncherOption)
@@ -587,70 +587,70 @@
587587
588TEST_F(TestEdgeBarrierController, VerticalBarrierDoesNotBreakIfYEventToFarApart)588TEST_F(TestEdgeBarrierController, VerticalBarrierDoesNotBreakIfYEventToFarApart)
589{589{
590 MockPointerBarrierWrapper owner(0, false, VERTICAL);590 auto owner = std::make_shared<MockPointerBarrierWrapper>(0, false, VERTICAL);
591591
592 int velocity = bc.options()->edge_overcome_pressure() * bc.options()->edge_responsiveness();592 int velocity = bc.options()->edge_overcome_pressure() * bc.options()->edge_responsiveness();
593 auto firstEvent = std::make_shared<BarrierEvent>(0, 50, velocity, 10);593 auto firstEvent = std::make_shared<BarrierEvent>(0, 50, velocity, 10);
594 auto secondEvent = std::make_shared<BarrierEvent>(0, 150, velocity, 11);594 auto secondEvent = std::make_shared<BarrierEvent>(0, 150, velocity, 11);
595595
596 EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0);596 EXPECT_CALL(*owner, ReleaseBarrier(_)).Times(0);
597 ProcessBarrierEvent(&owner, firstEvent);597 ProcessBarrierEvent(owner, firstEvent);
598 ProcessBarrierEvent(&owner, secondEvent);598 ProcessBarrierEvent(owner, secondEvent);
599}599}
600600
601TEST_F(TestEdgeBarrierController, HorizontalBarrierDoesNotBreakIfXEventToFarApart)601TEST_F(TestEdgeBarrierController, HorizontalBarrierDoesNotBreakIfXEventToFarApart)
602{602{
603 MockPointerBarrierWrapper owner(0, false, HORIZONTAL);603 auto owner = std::make_shared<MockPointerBarrierWrapper>(0, false, HORIZONTAL);
604604
605 int velocity = bc.options()->edge_overcome_pressure() * bc.options()->edge_responsiveness();605 int velocity = bc.options()->edge_overcome_pressure() * bc.options()->edge_responsiveness();
606 auto firstEvent = std::make_shared<BarrierEvent>(50, 0, velocity, 10);606 auto firstEvent = std::make_shared<BarrierEvent>(50, 0, velocity, 10);
607 auto secondEvent = std::make_shared<BarrierEvent>(150, 0, velocity, 11);607 auto secondEvent = std::make_shared<BarrierEvent>(150, 0, velocity, 11);
608608
609 EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0);609 EXPECT_CALL(*owner, ReleaseBarrier(_)).Times(0);
610 ProcessBarrierEvent(&owner, firstEvent);610 ProcessBarrierEvent(owner, firstEvent);
611 ProcessBarrierEvent(&owner, secondEvent);611 ProcessBarrierEvent(owner, secondEvent);
612}612}
613613
614TEST_F(TestEdgeBarrierController, VerticalBarrierBreaksInYBreakZone)614TEST_F(TestEdgeBarrierController, VerticalBarrierBreaksInYBreakZone)
615{615{
616 MockPointerBarrierWrapper owner(0, false, VERTICAL);616 auto owner = std::make_shared<MockPointerBarrierWrapper>(0, false, VERTICAL);
617617
618 int velocity = bc.options()->edge_overcome_pressure() * bc.options()->edge_responsiveness();618 int velocity = bc.options()->edge_overcome_pressure() * bc.options()->edge_responsiveness();
619 auto firstEvent = std::make_shared<BarrierEvent>(0, 50, velocity, 10);619 auto firstEvent = std::make_shared<BarrierEvent>(0, 50, velocity, 10);
620620
621 EXPECT_CALL(owner, ReleaseBarrier(_)).Times(1);621 EXPECT_CALL(*owner, ReleaseBarrier(_)).Times(1);
622 ProcessBarrierEvent(&owner, firstEvent);622 ProcessBarrierEvent(owner, firstEvent);
623 ProcessBarrierEvent(&owner, firstEvent);623 ProcessBarrierEvent(owner, firstEvent);
624}624}
625625
626TEST_F(TestEdgeBarrierController, HorizontalBarrierBreaksInXBreakZone)626TEST_F(TestEdgeBarrierController, HorizontalBarrierBreaksInXBreakZone)
627{627{
628 MockPointerBarrierWrapper owner(0, false, HORIZONTAL);628 auto owner = std::make_shared<MockPointerBarrierWrapper>(0, false, HORIZONTAL);
629629
630 int velocity = bc.options()->edge_overcome_pressure() * bc.options()->edge_responsiveness();630 int velocity = bc.options()->edge_overcome_pressure() * bc.options()->edge_responsiveness();
631 auto firstEvent = std::make_shared<BarrierEvent>(50, 0, velocity, 10);631 auto firstEvent = std::make_shared<BarrierEvent>(50, 0, velocity, 10);
632632
633 EXPECT_CALL(owner, ReleaseBarrier(_)).Times(1);633 EXPECT_CALL(*owner, ReleaseBarrier(_)).Times(1);
634 ProcessBarrierEvent(&owner, firstEvent);634 ProcessBarrierEvent(owner, firstEvent);
635 ProcessBarrierEvent(&owner, firstEvent);635 ProcessBarrierEvent(owner, firstEvent);
636}636}
637637
638TEST_F(TestEdgeBarrierController, VerticalBarrierReleaseIfNoSubscriberForMonitor)638TEST_F(TestEdgeBarrierController, VerticalBarrierReleaseIfNoSubscriberForMonitor)
639{639{
640 MockPointerBarrierWrapper owner(monitors::MAX, false, VERTICAL);640 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitors::MAX, false, VERTICAL);
641 auto firstEvent = std::make_shared<BarrierEvent>(0, 50, 1, 10);641 auto firstEvent = std::make_shared<BarrierEvent>(0, 50, 1, 10);
642642
643 EXPECT_CALL(owner, ReleaseBarrier(_)).Times(1);643 EXPECT_CALL(*owner, ReleaseBarrier(_)).Times(1);
644 ProcessBarrierEvent(&owner, firstEvent);644 ProcessBarrierEvent(owner, firstEvent);
645}645}
646646
647TEST_F(TestEdgeBarrierController, HorizontalBarrierReleaseIfNoSubscriberForMonitor)647TEST_F(TestEdgeBarrierController, HorizontalBarrierReleaseIfNoSubscriberForMonitor)
648{648{
649 MockPointerBarrierWrapper owner(monitors::MAX, false, HORIZONTAL);649 auto owner = std::make_shared<MockPointerBarrierWrapper>(monitors::MAX, false, HORIZONTAL);
650 auto firstEvent = std::make_shared<BarrierEvent>(50, 0, 1, 10);650 auto firstEvent = std::make_shared<BarrierEvent>(50, 0, 1, 10);
651651
652 EXPECT_CALL(owner, ReleaseBarrier(_)).Times(1);652 EXPECT_CALL(*owner, ReleaseBarrier(_)).Times(1);
653 ProcessBarrierEvent(&owner, firstEvent);653 ProcessBarrierEvent(owner, firstEvent);
654}654}
655655
656}656}
657657
=== modified file 'tests/test_launcher.cpp'
--- tests/test_launcher.cpp 2014-03-21 04:40:12 +0000
+++ tests/test_launcher.cpp 2015-01-14 02:47:10 +0000
@@ -502,7 +502,7 @@
502502
503 launcher_->DndStarted("");503 launcher_->DndStarted("");
504504
505 EXPECT_EQ(launcher_->HandleBarrierEvent(barrier.get(), event),505 EXPECT_EQ(launcher_->HandleBarrierEvent(barrier, event),
506 ui::EdgeBarrierSubscriber::Result::NEEDS_RELEASE);506 ui::EdgeBarrierSubscriber::Result::NEEDS_RELEASE);
507}507}
508508
@@ -515,24 +515,24 @@
515515
516 event->x = launcher_geo.x-1;516 event->x = launcher_geo.x-1;
517 event->y = launcher_geo.y;517 event->y = launcher_geo.y;
518 EXPECT_EQ(launcher_->HandleBarrierEvent(barrier.get(), event),518 EXPECT_EQ(launcher_->HandleBarrierEvent(barrier, event),
519 ui::EdgeBarrierSubscriber::Result::IGNORED);519 ui::EdgeBarrierSubscriber::Result::IGNORED);
520520
521 event->x = launcher_geo.x+launcher_geo.width+1;521 event->x = launcher_geo.x+launcher_geo.width+1;
522 event->y = launcher_geo.y;522 event->y = launcher_geo.y;
523 EXPECT_EQ(launcher_->HandleBarrierEvent(barrier.get(), event),523 EXPECT_EQ(launcher_->HandleBarrierEvent(barrier, event),
524 ui::EdgeBarrierSubscriber::Result::IGNORED);524 ui::EdgeBarrierSubscriber::Result::IGNORED);
525525
526 options_->reveal_trigger = RevealTrigger::EDGE;526 options_->reveal_trigger = RevealTrigger::EDGE;
527 event->x = launcher_geo.x+launcher_geo.width/2;527 event->x = launcher_geo.x+launcher_geo.width/2;
528 event->y = launcher_geo.y - 1;528 event->y = launcher_geo.y - 1;
529 EXPECT_EQ(launcher_->HandleBarrierEvent(barrier.get(), event),529 EXPECT_EQ(launcher_->HandleBarrierEvent(barrier, event),
530 ui::EdgeBarrierSubscriber::Result::IGNORED);530 ui::EdgeBarrierSubscriber::Result::IGNORED);
531531
532 options_->reveal_trigger = RevealTrigger::CORNER;532 options_->reveal_trigger = RevealTrigger::CORNER;
533 event->x = launcher_geo.x+launcher_geo.width/2;533 event->x = launcher_geo.x+launcher_geo.width/2;
534 event->y = launcher_geo.y;534 event->y = launcher_geo.y;
535 EXPECT_EQ(launcher_->HandleBarrierEvent(barrier.get(), event),535 EXPECT_EQ(launcher_->HandleBarrierEvent(barrier, event),
536 ui::EdgeBarrierSubscriber::Result::IGNORED);536 ui::EdgeBarrierSubscriber::Result::IGNORED);
537}537}
538538
@@ -551,7 +551,7 @@
551 {551 {
552 event->x = x;552 event->x = x;
553 event->y = y;553 event->y = y;
554 ASSERT_EQ(launcher_->HandleBarrierEvent(barrier.get(), event),554 ASSERT_EQ(launcher_->HandleBarrierEvent(barrier, event),
555 ui::EdgeBarrierSubscriber::Result::HANDLED);555 ui::EdgeBarrierSubscriber::Result::HANDLED);
556 }556 }
557 }557 }
@@ -564,7 +564,7 @@
564 {564 {
565 event->x = x;565 event->x = x;
566 event->y = y;566 event->y = y;
567 ASSERT_EQ(launcher_->HandleBarrierEvent(barrier.get(), event),567 ASSERT_EQ(launcher_->HandleBarrierEvent(barrier, event),
568 ui::EdgeBarrierSubscriber::Result::HANDLED);568 ui::EdgeBarrierSubscriber::Result::HANDLED);
569 }569 }
570 }570 }
571571
=== modified file 'tests/test_panel_view.cpp'
--- tests/test_panel_view.cpp 2014-03-21 04:40:12 +0000
+++ tests/test_panel_view.cpp 2015-01-14 02:47:10 +0000
@@ -80,11 +80,11 @@
80 auto event = std::make_shared<ui::BarrierEvent>(0, 0, 0, 100);80 auto event = std::make_shared<ui::BarrierEvent>(0, 0, 0, 100);
8181
82 WM->SetIsAnyWindowMoving(false);82 WM->SetIsAnyWindowMoving(false);
83 EXPECT_EQ(panel_view_->HandleBarrierEvent(barrier.get(), event),83 EXPECT_EQ(panel_view_->HandleBarrierEvent(barrier, event),
84 ui::EdgeBarrierSubscriber::Result::NEEDS_RELEASE);84 ui::EdgeBarrierSubscriber::Result::NEEDS_RELEASE);
8585
86 WM->SetIsAnyWindowMoving(true);86 WM->SetIsAnyWindowMoving(true);
87 EXPECT_EQ(panel_view_->HandleBarrierEvent(barrier.get(), event),87 EXPECT_EQ(panel_view_->HandleBarrierEvent(barrier, event),
88 ui::EdgeBarrierSubscriber::Result::IGNORED);88 ui::EdgeBarrierSubscriber::Result::IGNORED);
89}89}
9090
9191
=== modified file 'tests/test_pointer_barrier.cpp'
--- tests/test_pointer_barrier.cpp 2013-07-09 23:18:29 +0000
+++ tests/test_pointer_barrier.cpp 2015-01-14 02:47:10 +0000
@@ -79,79 +79,79 @@
7979
80TEST(TestPointerBarrier, HandleHitNotifyEvents)80TEST(TestPointerBarrier, HandleHitNotifyEvents)
81{81{
82 MockPointerBarrier pb;82 auto pb = std::make_shared<MockPointerBarrier>();
83 pb.threshold = 1000;83 pb->threshold = 1000;
84 XIBarrierEvent ev = GetGenericEvent(0xdeadbeef);84 XIBarrierEvent ev = GetGenericEvent(0xdeadbeef);
8585
86 bool got_event = false;86 bool got_event = false;
8787
88 pb.barrier_event.connect([&] (PointerBarrierWrapper* pbw, BarrierEvent::Ptr bev) {88 pb->barrier_event.connect([&] (PointerBarrierWrapper::Ptr const& pbw, BarrierEvent::Ptr bev) {
89 if (!pbw->IsFirstEvent())89 if (!pbw->IsFirstEvent())
90 {90 {
91 got_event = true;91 got_event = true;
9292
93 EXPECT_EQ(pbw, &pb);93 EXPECT_EQ(pbw.get(), pb.get());
94 EXPECT_EQ(bev->x, ev.root_x);94 EXPECT_EQ(bev->x, ev.root_x);
95 EXPECT_EQ(bev->y, ev.root_y);95 EXPECT_EQ(bev->y, ev.root_y);
96 EXPECT_EQ(bev->velocity, 600 * pb.max_velocity_multiplier);96 EXPECT_EQ(bev->velocity, 600 * pb->max_velocity_multiplier);
97 EXPECT_EQ(bev->event_id, ev.eventid);97 EXPECT_EQ(bev->event_id, ev.eventid);
98 }98 }
99 });99 });
100100
101 EXPECT_TRUE(pb.HandleBarrierEvent(&ev));101 EXPECT_TRUE(pb->HandleBarrierEvent(&ev));
102 EXPECT_FALSE(got_event);102 EXPECT_FALSE(got_event);
103103
104 Utils::WaitForTimeoutMSec(pb.smoothing());104 Utils::WaitForTimeoutMSec(pb->smoothing());
105105
106 EXPECT_TRUE(got_event);106 EXPECT_TRUE(got_event);
107}107}
108108
109TEST(TestPointerBarrier, HandleHitNotifyReleasedEvents)109TEST(TestPointerBarrier, HandleHitNotifyReleasedEvents)
110{110{
111 MockPointerBarrier pb;111 auto pb = std::make_shared<MockPointerBarrier>();
112 pb.threshold = 1000;112 pb->threshold = 1000;
113 XIBarrierEvent ev = GetGenericEvent(0xabba);113 XIBarrierEvent ev = GetGenericEvent(0xabba);
114 bool got_event = false;114 bool got_event = false;
115115
116 pb.barrier_event.connect([&] (PointerBarrierWrapper* pbw, BarrierEvent::Ptr bev) {116 pb->barrier_event.connect([&] (PointerBarrierWrapper::Ptr const& pbw, BarrierEvent::Ptr bev) {
117 got_event = true;117 got_event = true;
118118
119 EXPECT_EQ(pbw, &pb);119 EXPECT_EQ(pbw.get(), pb.get());
120 EXPECT_EQ(bev->x, ev.root_x);120 EXPECT_EQ(bev->x, ev.root_x);
121 EXPECT_EQ(bev->y, ev.root_y);121 EXPECT_EQ(bev->y, ev.root_y);
122 EXPECT_GT(bev->velocity, 0);122 EXPECT_GT(bev->velocity, 0);
123 EXPECT_EQ(bev->event_id, ev.eventid);123 EXPECT_EQ(bev->event_id, ev.eventid);
124 });124 });
125125
126 pb.released = true;126 pb->released = true;
127 EXPECT_TRUE(pb.HandleBarrierEvent(&ev));127 EXPECT_TRUE(pb->HandleBarrierEvent(&ev));
128 EXPECT_TRUE(got_event);128 EXPECT_TRUE(got_event);
129}129}
130130
131TEST(TestPointerBarrier, ReciveFirstEvent)131TEST(TestPointerBarrier, ReciveFirstEvent)
132{132{
133 MockPointerBarrier pb;133 auto pb = std::make_shared<MockPointerBarrier>();
134 pb.threshold = 1000;134 pb->threshold = 1000;
135 XIBarrierEvent ev = GetGenericEvent(0xabba);135 XIBarrierEvent ev = GetGenericEvent(0xabba);
136136
137 bool first_is_true = false;137 bool first_is_true = false;
138138
139 pb.barrier_event.connect([&] (PointerBarrierWrapper* pbw, BarrierEvent::Ptr bev) {139 pb->barrier_event.connect([&] (PointerBarrierWrapper::Ptr const& pbw, BarrierEvent::Ptr bev) {
140 first_is_true = true;140 first_is_true = true;
141 });141 });
142142
143 EXPECT_TRUE(pb.HandleBarrierEvent(&ev));143 EXPECT_TRUE(pb->HandleBarrierEvent(&ev));
144 EXPECT_TRUE(first_is_true);144 EXPECT_TRUE(first_is_true);
145}145}
146146
147TEST(TestPointerBarrier, ReciveSecondEventFirstFalse)147TEST(TestPointerBarrier, ReciveSecondEventFirstFalse)
148{148{
149 MockPointerBarrier pb;149 auto pb = std::make_shared<MockPointerBarrier>();
150 pb.threshold = 1000;150 pb->threshold = 1000;
151 XIBarrierEvent ev = GetGenericEvent(0xabba);151 XIBarrierEvent ev = GetGenericEvent(0xabba);
152 int events_recived = 0;152 int events_recived = 0;
153153
154 pb.barrier_event.connect([&] (PointerBarrierWrapper* pbw, BarrierEvent::Ptr bev) {154 pb->barrier_event.connect([&] (PointerBarrierWrapper::Ptr const& pbw, BarrierEvent::Ptr bev) {
155 events_recived++;155 events_recived++;
156156
157 if (events_recived == 1)157 if (events_recived == 1)
@@ -160,44 +160,44 @@
160 EXPECT_FALSE(pbw->IsFirstEvent());160 EXPECT_FALSE(pbw->IsFirstEvent());
161 });161 });
162162
163 EXPECT_TRUE(pb.HandleBarrierEvent(&ev));163 EXPECT_TRUE(pb->HandleBarrierEvent(&ev));
164164
165 Utils::WaitForTimeoutMSec(pb.smoothing());165 Utils::WaitForTimeoutMSec(pb->smoothing());
166166
167 EXPECT_EQ(events_recived, 2);167 EXPECT_EQ(events_recived, 2);
168}168}
169169
170TEST(TestPointerBarrier, DontReleaseBarrierOnEmptyDTime)170TEST(TestPointerBarrier, DontReleaseBarrierOnEmptyDTime)
171{171{
172 MockPointerBarrier pb;172 auto pb = std::make_shared<MockPointerBarrier>();
173 pb.threshold = 1000;173 pb->threshold = 1000;
174 XIBarrierEvent ev = GetGenericEvent(0xabba);174 XIBarrierEvent ev = GetGenericEvent(0xabba);
175 ev.dtime = 0;175 ev.dtime = 0;
176176
177 {177 {
178 InSequence sequence;178 InSequence sequence;
179 EXPECT_CALL(pb, ReleaseBarrier(0xabba)).Times(0);179 EXPECT_CALL(*pb, ReleaseBarrier(0xabba)).Times(0);
180 }180 }
181181
182 EXPECT_TRUE(pb.HandleBarrierEvent(&ev));182 EXPECT_TRUE(pb->HandleBarrierEvent(&ev));
183183
184 Utils::WaitForTimeoutMSec(pb.smoothing());184 Utils::WaitForTimeoutMSec(pb->smoothing());
185}185}
186186
187TEST(TestPointerBarrier, ReleaseBarrierIfOverThreshold)187TEST(TestPointerBarrier, ReleaseBarrierIfOverThreshold)
188{188{
189 MockPointerBarrier pb;189 auto pb = std::make_shared<MockPointerBarrier>();
190 pb.threshold = 500;190 pb->threshold = 500;
191 XIBarrierEvent ev = GetGenericEvent(0xabba);191 XIBarrierEvent ev = GetGenericEvent(0xabba);
192192
193 {193 {
194 InSequence sequence;194 InSequence sequence;
195 EXPECT_CALL(pb, ReleaseBarrier(0xabba)).Times(1);195 EXPECT_CALL(*pb, ReleaseBarrier(0xabba)).Times(1);
196 }196 }
197197
198 EXPECT_TRUE(pb.HandleBarrierEvent(&ev));198 EXPECT_TRUE(pb->HandleBarrierEvent(&ev));
199199
200 Utils::WaitForTimeoutMSec(pb.smoothing());200 Utils::WaitForTimeoutMSec(pb->smoothing());
201}201}
202202
203}203}