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

Side by Side Diff: ash/wm/user_activity_detector_unittest.cc

Issue 12391004: chromeos: Add DisplayPowerServiceProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ugh, TrayDisplay was including output_configurator.h on windows Created 7 years, 9 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
« no previous file with comments | « ash/wm/user_activity_detector.cc ('k') | chrome/browser/chromeos/dbus/cros_dbus_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/user_activity_detector.h" 5 #include "ash/wm/user_activity_detector.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "ash/wm/user_activity_observer.h" 9 #include "ash/wm/user_activity_observer.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 TEST_F(UserActivityDetectorTest, Basic) { 90 TEST_F(UserActivityDetectorTest, Basic) {
91 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(12345)); 91 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(12345));
92 92
93 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE, false); 93 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE, false);
94 SetEventTarget(window.get(), &key_event); 94 SetEventTarget(window.get(), &key_event);
95 detector_->OnKeyEvent(&key_event); 95 detector_->OnKeyEvent(&key_event);
96 EXPECT_FALSE(key_event.handled()); 96 EXPECT_FALSE(key_event.handled());
97 EXPECT_EQ(1, observer_->num_invocations()); 97 EXPECT_EQ(1, observer_->num_invocations());
98 observer_->reset_stats(); 98 observer_->reset_stats();
99 99
100 base::TimeDelta advance_delta = 100 base::TimeDelta advance_delta = base::TimeDelta::FromMilliseconds(
101 base::TimeDelta::FromSeconds(UserActivityDetector::kNotifyIntervalMs); 101 UserActivityDetector::kNotifyIntervalMs);
102 AdvanceTime(advance_delta); 102 AdvanceTime(advance_delta);
103 ui::MouseEvent mouse_event( 103 ui::MouseEvent mouse_event(
104 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EF_NONE); 104 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EF_NONE);
105 SetEventTarget(window.get(), &mouse_event); 105 SetEventTarget(window.get(), &mouse_event);
106 detector_->OnMouseEvent(&mouse_event); 106 detector_->OnMouseEvent(&mouse_event);
107 EXPECT_FALSE(mouse_event.handled()); 107 EXPECT_FALSE(mouse_event.handled());
108 EXPECT_EQ(1, observer_->num_invocations()); 108 EXPECT_EQ(1, observer_->num_invocations());
109 observer_->reset_stats(); 109 observer_->reset_stats();
110 110
111 // Ignore one mouse event when all displays are turned off. 111 // Temporarily ignore mouse events when displays are turned on or off.
112 detector_->OnAllOutputsTurnedOff(); 112 detector_->OnDisplayPowerChanging();
113 AdvanceTime(advance_delta);
114 detector_->OnMouseEvent(&mouse_event); 113 detector_->OnMouseEvent(&mouse_event);
115 EXPECT_FALSE(mouse_event.handled()); 114 EXPECT_FALSE(mouse_event.handled());
116 EXPECT_EQ(0, observer_->num_invocations()); 115 EXPECT_EQ(0, observer_->num_invocations());
117 observer_->reset_stats(); 116 observer_->reset_stats();
118 117
118 const base::TimeDelta kIgnoreMouseTime =
119 base::TimeDelta::FromMilliseconds(
120 UserActivityDetector::kDisplayPowerChangeIgnoreMouseMs);
121 AdvanceTime(kIgnoreMouseTime / 2);
122 detector_->OnMouseEvent(&mouse_event);
123 EXPECT_FALSE(mouse_event.handled());
124 EXPECT_EQ(0, observer_->num_invocations());
125 observer_->reset_stats();
126
127 // After enough time has passed, mouse events should be reported again.
128 AdvanceTime(std::max(kIgnoreMouseTime, advance_delta));
129 detector_->OnMouseEvent(&mouse_event);
130 EXPECT_FALSE(mouse_event.handled());
131 EXPECT_EQ(1, observer_->num_invocations());
132 observer_->reset_stats();
133
119 AdvanceTime(advance_delta); 134 AdvanceTime(advance_delta);
120 ui::TouchEvent touch_event( 135 ui::TouchEvent touch_event(
121 ui::ET_TOUCH_PRESSED, gfx::Point(), 0, base::TimeDelta()); 136 ui::ET_TOUCH_PRESSED, gfx::Point(), 0, base::TimeDelta());
122 SetEventTarget(window.get(), &touch_event); 137 SetEventTarget(window.get(), &touch_event);
123 detector_->OnTouchEvent(&touch_event); 138 detector_->OnTouchEvent(&touch_event);
124 EXPECT_FALSE(touch_event.handled()); 139 EXPECT_FALSE(touch_event.handled());
125 EXPECT_EQ(1, observer_->num_invocations()); 140 EXPECT_EQ(1, observer_->num_invocations());
126 observer_->reset_stats(); 141 observer_->reset_stats();
127 142
128 AdvanceTime(advance_delta); 143 AdvanceTime(advance_delta);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 ui::MouseEvent mouse_event( 196 ui::MouseEvent mouse_event(
182 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EF_IS_SYNTHESIZED); 197 ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EF_IS_SYNTHESIZED);
183 SetEventTarget(window.get(), &mouse_event); 198 SetEventTarget(window.get(), &mouse_event);
184 detector_->OnMouseEvent(&mouse_event); 199 detector_->OnMouseEvent(&mouse_event);
185 EXPECT_FALSE(mouse_event.handled()); 200 EXPECT_FALSE(mouse_event.handled());
186 EXPECT_EQ(0, observer_->num_invocations()); 201 EXPECT_EQ(0, observer_->num_invocations());
187 } 202 }
188 203
189 } // namespace test 204 } // namespace test
190 } // namespace ash 205 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/user_activity_detector.cc ('k') | chrome/browser/chromeos/dbus/cros_dbus_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698