Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: ash/wm/maximize_mode/maximize_mode_controller_unittest.cc

Issue 269633005: Only block internal touchpad and allow external mice to continue working in maximize mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 5 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
6 6
7 #include "ash/accelerometer/accelerometer_controller.h" 7 #include "ash/accelerometer/accelerometer_controller.h"
8 #include "ash/display/display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/system/tray/system_tray_delegate.h" 10 #include "ash/system/tray/system_tray_delegate.h"
11 #include "ash/test/ash_test_base.h" 11 #include "ash/test/ash_test_base.h"
12 #include "ash/test/display_manager_test_api.h" 12 #include "ash/test/display_manager_test_api.h"
13 #include "ash/test/test_lock_state_controller_delegate.h" 13 #include "ash/test/test_lock_state_controller_delegate.h"
14 #include "ash/test/test_screenshot_delegate.h" 14 #include "ash/test/test_screenshot_delegate.h"
15 #include "ash/test/test_system_tray_delegate.h" 15 #include "ash/test/test_system_tray_delegate.h"
16 #include "ash/test/test_volume_control_delegate.h" 16 #include "ash/test/test_volume_control_delegate.h"
17 #include "ash/wm/maximize_mode/internal_input_device_list.h"
18 #include "ash/wm/maximize_mode/maximize_mode_event_blocker.h"
17 #include "ui/aura/test/event_generator.h" 19 #include "ui/aura/test/event_generator.h"
18 #include "ui/events/event_handler.h" 20 #include "ui/events/event_handler.h"
19 #include "ui/gfx/vector3d_f.h" 21 #include "ui/gfx/vector3d_f.h"
20 #include "ui/message_center/message_center.h" 22 #include "ui/message_center/message_center.h"
21 23
22 namespace ash { 24 namespace ash {
23 25
24 namespace { 26 namespace {
25 27
26 const float kDegreesToRadians = 3.14159265f / 180.0f; 28 const float kDegreesToRadians = 3.14159265f / 180.0f;
(...skipping 24 matching lines...) Expand all
51 } 53 }
52 54
53 EventCounter::~EventCounter() { 55 EventCounter::~EventCounter() {
54 Shell::GetInstance()->RemovePreTargetHandler(this); 56 Shell::GetInstance()->RemovePreTargetHandler(this);
55 } 57 }
56 58
57 void EventCounter::OnEvent(ui::Event* event) { 59 void EventCounter::OnEvent(ui::Event* event) {
58 event_count_++; 60 event_count_++;
59 } 61 }
60 62
63 // A test internal input device list which pretends that all events are from
64 // internal devices to allow verifying that the event blocking works.
65 class TestInternalInputDeviceList : public InternalInputDeviceList {
66 public:
67 TestInternalInputDeviceList() {}
68 virtual ~TestInternalInputDeviceList() {}
69
70 virtual bool IsEventFromInternalDevice(const ui::Event* event) OVERRIDE {
71 return true;
72 }
73
74 private:
75 DISALLOW_COPY_AND_ASSIGN(TestInternalInputDeviceList);
76 };
77
61 } // namespace 78 } // namespace
62 79
63 // Test accelerometer data taken with the lid at less than 180 degrees while 80 // Test accelerometer data taken with the lid at less than 180 degrees while
64 // shaking the device around. The data is to be interpreted in groups of 6 where 81 // shaking the device around. The data is to be interpreted in groups of 6 where
65 // each 6 values corresponds to the X, Y, and Z readings from the base and lid 82 // each 6 values corresponds to the X, Y, and Z readings from the base and lid
66 // accelerometers in this order. 83 // accelerometers in this order.
67 extern const float kAccelerometerLaptopModeTestData[]; 84 extern const float kAccelerometerLaptopModeTestData[];
68 extern const size_t kAccelerometerLaptopModeTestDataLength; 85 extern const size_t kAccelerometerLaptopModeTestDataLength;
69 86
70 // Test accelerometer data taken with the lid open 360 degrees while 87 // Test accelerometer data taken with the lid open 360 degrees while
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 119
103 void TriggerAccelerometerUpdate(const gfx::Vector3dF& base, 120 void TriggerAccelerometerUpdate(const gfx::Vector3dF& base,
104 const gfx::Vector3dF& lid) { 121 const gfx::Vector3dF& lid) {
105 maximize_mode_controller()->OnAccelerometerUpdated(base, lid); 122 maximize_mode_controller()->OnAccelerometerUpdated(base, lid);
106 } 123 }
107 124
108 bool IsMaximizeModeStarted() const { 125 bool IsMaximizeModeStarted() const {
109 return Shell::GetInstance()->IsMaximizeModeWindowManagerEnabled(); 126 return Shell::GetInstance()->IsMaximizeModeWindowManagerEnabled();
110 } 127 }
111 128
129 // Overrides the internal input device list for the current event targeters
130 // with one which always returns true.
131 void InstallTestInternalDeviceList() {
132 maximize_mode_controller()->event_blocker_->internal_devices_.reset(
133 new TestInternalInputDeviceList);
134 }
135
112 gfx::Display::Rotation GetInternalDisplayRotation() const { 136 gfx::Display::Rotation GetInternalDisplayRotation() const {
113 return Shell::GetInstance()->display_manager()->GetDisplayInfo( 137 return Shell::GetInstance()->display_manager()->GetDisplayInfo(
114 gfx::Display::InternalDisplayId()).rotation(); 138 gfx::Display::InternalDisplayId()).rotation();
115 } 139 }
116 140
117 void SetInternalDisplayRotation(gfx::Display::Rotation rotation) const { 141 void SetInternalDisplayRotation(gfx::Display::Rotation rotation) const {
118 Shell::GetInstance()->display_manager()-> 142 Shell::GetInstance()->display_manager()->
119 SetDisplayRotation(gfx::Display::InternalDisplayId(), rotation); 143 SetDisplayRotation(gfx::Display::InternalDisplayId(), rotation);
120 } 144 }
121 145
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 343
320 event_generator.PressTouch(); 344 event_generator.PressTouch();
321 event_generator.ReleaseTouch(); 345 event_generator.ReleaseTouch();
322 EXPECT_GT(counter.event_count(), 0u); 346 EXPECT_GT(counter.event_count(), 0u);
323 counter.reset(); 347 counter.reset();
324 348
325 // Open up 270 degrees. 349 // Open up 270 degrees.
326 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), 350 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f),
327 gfx::Vector3dF(1.0f, 0.0f, 0.0f)); 351 gfx::Vector3dF(1.0f, 0.0f, 0.0f));
328 ASSERT_TRUE(IsMaximizeModeStarted()); 352 ASSERT_TRUE(IsMaximizeModeStarted());
353 InstallTestInternalDeviceList();
329 354
330 event_generator.PressKey(ui::VKEY_ESCAPE, 0); 355 event_generator.PressKey(ui::VKEY_ESCAPE, 0);
331 event_generator.ReleaseKey(ui::VKEY_ESCAPE, 0); 356 event_generator.ReleaseKey(ui::VKEY_ESCAPE, 0);
332 EXPECT_EQ(0u, counter.event_count()); 357 EXPECT_EQ(0u, counter.event_count());
333 counter.reset(); 358 counter.reset();
334 359
335 event_generator.ClickLeftButton(); 360 event_generator.ClickLeftButton();
336 EXPECT_EQ(0u, counter.event_count()); 361 EXPECT_EQ(0u, counter.event_count());
337 counter.reset(); 362 counter.reset();
338 363
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 ASSERT_NE(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); 590 ASSERT_NE(gfx::Display::ROTATE_90, GetInternalDisplayRotation());
566 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 1.0f, 0.0f), 591 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 1.0f, 0.0f),
567 gfx::Vector3dF(0.0f, 1.0f, 0.0f)); 592 gfx::Vector3dF(0.0f, 1.0f, 0.0f));
568 ASSERT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); 593 ASSERT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation());
569 EXPECT_EQ(0u, message_center->NotificationCount()); 594 EXPECT_EQ(0u, message_center->NotificationCount());
570 EXPECT_FALSE(message_center->HasPopupNotifications()); 595 EXPECT_FALSE(message_center->HasPopupNotifications());
571 } 596 }
572 #endif 597 #endif
573 598
574 } // namespace ash 599 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/maximize_mode/maximize_mode_controller.h ('k') | ash/wm/maximize_mode/maximize_mode_event_blocker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698