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

Side by Side Diff: ash/touch/touch_observer_hud_unittest.cc

Issue 224113005: Eliminate ash::internal namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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/touch/touch_observer_hud.cc ('k') | ash/wm/always_on_top_controller.h » ('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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/touch/touch_observer_hud.h" 5 #include "ash/touch/touch_observer_hud.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/display/display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/screen_util.h" 10 #include "ash/screen_util.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/test/ash_test_base.h" 12 #include "ash/test/ash_test_base.h"
13 #include "ash/test/display_manager_test_api.h" 13 #include "ash/test/display_manager_test_api.h"
14 #include "ash/touch/touch_hud_debug.h" 14 #include "ash/touch/touch_hud_debug.h"
15 #include "ash/touch/touch_hud_projection.h" 15 #include "ash/touch/touch_hud_projection.h"
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/format_macros.h" 17 #include "base/format_macros.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "ui/aura/window.h" 19 #include "ui/aura/window.h"
20 20
21 namespace ash { 21 namespace ash {
22 namespace internal {
23 22
24 class TouchHudTestBase : public test::AshTestBase { 23 class TouchHudTestBase : public test::AshTestBase {
25 public: 24 public:
26 TouchHudTestBase() {} 25 TouchHudTestBase() {}
27 virtual ~TouchHudTestBase() {} 26 virtual ~TouchHudTestBase() {}
28 27
29 virtual void SetUp() OVERRIDE { 28 virtual void SetUp() OVERRIDE {
30 test::AshTestBase::SetUp(); 29 test::AshTestBase::SetUp();
31 30
32 // Initialize display infos. They should be initialized after Ash 31 // Initialize display infos. They should be initialized after Ash
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 aura::Window* GetPrimaryRootWindow() { 155 aura::Window* GetPrimaryRootWindow() {
157 const gfx::Display& display = GetPrimaryDisplay(); 156 const gfx::Display& display = GetPrimaryDisplay();
158 return GetDisplayController()->GetRootWindowForDisplayId(display.id()); 157 return GetDisplayController()->GetRootWindowForDisplayId(display.id());
159 } 158 }
160 159
161 aura::Window* GetSecondaryRootWindow() { 160 aura::Window* GetSecondaryRootWindow() {
162 const gfx::Display& display = GetSecondaryDisplay(); 161 const gfx::Display& display = GetSecondaryDisplay();
163 return GetDisplayController()->GetRootWindowForDisplayId(display.id()); 162 return GetDisplayController()->GetRootWindowForDisplayId(display.id());
164 } 163 }
165 164
166 internal::RootWindowController* GetInternalRootController() { 165 RootWindowController* GetInternalRootController() {
167 aura::Window* root = GetInternalRootWindow(); 166 aura::Window* root = GetInternalRootWindow();
168 return GetRootWindowController(root); 167 return GetRootWindowController(root);
169 } 168 }
170 169
171 internal::RootWindowController* GetExternalRootController() { 170 RootWindowController* GetExternalRootController() {
172 aura::Window* root = GetExternalRootWindow(); 171 aura::Window* root = GetExternalRootWindow();
173 return GetRootWindowController(root); 172 return GetRootWindowController(root);
174 } 173 }
175 174
176 internal::RootWindowController* GetPrimaryRootController() { 175 RootWindowController* GetPrimaryRootController() {
177 aura::Window* root = GetPrimaryRootWindow(); 176 aura::Window* root = GetPrimaryRootWindow();
178 return GetRootWindowController(root); 177 return GetRootWindowController(root);
179 } 178 }
180 179
181 internal::RootWindowController* GetSecondaryRootController() { 180 RootWindowController* GetSecondaryRootController() {
182 aura::Window* root = GetSecondaryRootWindow(); 181 aura::Window* root = GetSecondaryRootWindow();
183 return GetRootWindowController(root); 182 return GetRootWindowController(root);
184 } 183 }
185 184
186 DisplayInfo CreateDisplayInfo(int64 id, const gfx::Rect& bounds) { 185 DisplayInfo CreateDisplayInfo(int64 id, const gfx::Rect& bounds) {
187 DisplayInfo info(id, base::StringPrintf("x-%" PRId64, id), false); 186 DisplayInfo info(id, base::StringPrintf("x-%" PRId64, id), false);
188 info.SetBounds(bounds); 187 info.SetBounds(bounds);
189 return info; 188 return info;
190 } 189 }
191 190
192 aura::Window* GetRootWindowForTouchHud(internal::TouchObserverHUD* hud) { 191 aura::Window* GetRootWindowForTouchHud(TouchObserverHUD* hud) {
193 return hud->root_window_; 192 return hud->root_window_;
194 } 193 }
195 194
196 views::Widget* GetWidgetForTouchHud(internal::TouchObserverHUD* hud) { 195 views::Widget* GetWidgetForTouchHud(TouchObserverHUD* hud) {
197 return hud->widget_; 196 return hud->widget_;
198 } 197 }
199 198
200 int64 internal_display_id_; 199 int64 internal_display_id_;
201 int64 external_display_id_; 200 int64 external_display_id_;
202 int64 mirrored_display_id_; 201 int64 mirrored_display_id_;
203 DisplayInfo internal_display_info_; 202 DisplayInfo internal_display_info_;
204 DisplayInfo external_display_info_; 203 DisplayInfo external_display_info_;
205 DisplayInfo mirrored_display_info_; 204 DisplayInfo mirrored_display_info_;
206 205
(...skipping 10 matching lines...) Expand all
217 virtual void SetUp() OVERRIDE { 216 virtual void SetUp() OVERRIDE {
218 // Add ash-touch-hud flag to enable debug touch HUD. This flag should be set 217 // Add ash-touch-hud flag to enable debug touch HUD. This flag should be set
219 // before Ash environment is set up, i.e., before TouchHudTestBase::SetUp(). 218 // before Ash environment is set up, i.e., before TouchHudTestBase::SetUp().
220 CommandLine::ForCurrentProcess()->AppendSwitch( 219 CommandLine::ForCurrentProcess()->AppendSwitch(
221 ash::switches::kAshTouchHud); 220 ash::switches::kAshTouchHud);
222 221
223 TouchHudTestBase::SetUp(); 222 TouchHudTestBase::SetUp();
224 } 223 }
225 224
226 void CheckInternalDisplay() { 225 void CheckInternalDisplay() {
227 EXPECT_NE(static_cast<internal::TouchObserverHUD*>(NULL), 226 EXPECT_NE(static_cast<TouchObserverHUD*>(NULL), GetInternalTouchHudDebug());
228 GetInternalTouchHudDebug());
229 EXPECT_EQ(internal_display_id(), GetInternalTouchHudDebug()->display_id()); 227 EXPECT_EQ(internal_display_id(), GetInternalTouchHudDebug()->display_id());
230 EXPECT_EQ(GetInternalRootWindow(), 228 EXPECT_EQ(GetInternalRootWindow(),
231 GetRootWindowForTouchHud(GetInternalTouchHudDebug())); 229 GetRootWindowForTouchHud(GetInternalTouchHudDebug()));
232 EXPECT_EQ(GetInternalRootWindow(), 230 EXPECT_EQ(GetInternalRootWindow(),
233 GetWidgetForTouchHud(GetInternalTouchHudDebug())-> 231 GetWidgetForTouchHud(GetInternalTouchHudDebug())->
234 GetNativeView()->GetRootWindow()); 232 GetNativeView()->GetRootWindow());
235 EXPECT_EQ(GetInternalDisplay().size(), 233 EXPECT_EQ(GetInternalDisplay().size(),
236 GetWidgetForTouchHud(GetInternalTouchHudDebug())-> 234 GetWidgetForTouchHud(GetInternalTouchHudDebug())->
237 GetWindowBoundsInScreen().size()); 235 GetWindowBoundsInScreen().size());
238 } 236 }
239 237
240 void CheckExternalDisplay() { 238 void CheckExternalDisplay() {
241 EXPECT_NE(static_cast<internal::TouchHudDebug*>(NULL), 239 EXPECT_NE(static_cast<TouchHudDebug*>(NULL), GetExternalTouchHudDebug());
242 GetExternalTouchHudDebug());
243 EXPECT_EQ(external_display_id(), GetExternalTouchHudDebug()->display_id()); 240 EXPECT_EQ(external_display_id(), GetExternalTouchHudDebug()->display_id());
244 EXPECT_EQ(GetExternalRootWindow(), 241 EXPECT_EQ(GetExternalRootWindow(),
245 GetRootWindowForTouchHud(GetExternalTouchHudDebug())); 242 GetRootWindowForTouchHud(GetExternalTouchHudDebug()));
246 EXPECT_EQ(GetExternalRootWindow(), 243 EXPECT_EQ(GetExternalRootWindow(),
247 GetWidgetForTouchHud(GetExternalTouchHudDebug())-> 244 GetWidgetForTouchHud(GetExternalTouchHudDebug())->
248 GetNativeView()->GetRootWindow()); 245 GetNativeView()->GetRootWindow());
249 EXPECT_EQ(GetExternalDisplay().size(), 246 EXPECT_EQ(GetExternalDisplay().size(),
250 GetWidgetForTouchHud(GetExternalTouchHudDebug())-> 247 GetWidgetForTouchHud(GetExternalTouchHudDebug())->
251 GetWindowBoundsInScreen().size()); 248 GetWindowBoundsInScreen().size());
252 } 249 }
253 250
254 private: 251 private:
255 internal::TouchHudDebug* GetInternalTouchHudDebug() { 252 TouchHudDebug* GetInternalTouchHudDebug() {
256 return GetInternalRootController()->touch_hud_debug(); 253 return GetInternalRootController()->touch_hud_debug();
257 } 254 }
258 255
259 internal::TouchHudDebug* GetExternalTouchHudDebug() { 256 TouchHudDebug* GetExternalTouchHudDebug() {
260 return GetExternalRootController()->touch_hud_debug(); 257 return GetExternalRootController()->touch_hud_debug();
261 } 258 }
262 259
263 internal::TouchHudDebug* GetPrimaryTouchHudDebug() { 260 TouchHudDebug* GetPrimaryTouchHudDebug() {
264 return GetPrimaryRootController()->touch_hud_debug(); 261 return GetPrimaryRootController()->touch_hud_debug();
265 } 262 }
266 263
267 internal::TouchHudDebug* GetSecondaryTouchHudDebug() { 264 TouchHudDebug* GetSecondaryTouchHudDebug() {
268 return GetSecondaryRootController()->touch_hud_debug(); 265 return GetSecondaryRootController()->touch_hud_debug();
269 } 266 }
270 267
271 DISALLOW_COPY_AND_ASSIGN(TouchHudDebugTest); 268 DISALLOW_COPY_AND_ASSIGN(TouchHudDebugTest);
272 }; 269 };
273 270
274 class TouchHudProjectionTest : public TouchHudTestBase { 271 class TouchHudProjectionTest : public TouchHudTestBase {
275 public: 272 public:
276 TouchHudProjectionTest() {} 273 TouchHudProjectionTest() {}
277 virtual ~TouchHudProjectionTest() {} 274 virtual ~TouchHudProjectionTest() {}
278 275
279 void EnableTouchHudProjection() { 276 void EnableTouchHudProjection() {
280 Shell::GetInstance()->SetTouchHudProjectionEnabled(true); 277 Shell::GetInstance()->SetTouchHudProjectionEnabled(true);
281 } 278 }
282 279
283 void DisableTouchHudProjection() { 280 void DisableTouchHudProjection() {
284 Shell::GetInstance()->SetTouchHudProjectionEnabled(false); 281 Shell::GetInstance()->SetTouchHudProjectionEnabled(false);
285 } 282 }
286 283
287 internal::TouchHudProjection* GetInternalTouchHudProjection() { 284 TouchHudProjection* GetInternalTouchHudProjection() {
288 return GetInternalRootController()->touch_hud_projection(); 285 return GetInternalRootController()->touch_hud_projection();
289 } 286 }
290 287
291 int GetInternalTouchPointsCount() { 288 int GetInternalTouchPointsCount() {
292 return GetInternalTouchHudProjection()->points_.size(); 289 return GetInternalTouchHudProjection()->points_.size();
293 } 290 }
294 291
295 void SendTouchEventToInternalHud(ui::EventType type, 292 void SendTouchEventToInternalHud(ui::EventType type,
296 const gfx::Point& location, 293 const gfx::Point& location,
297 int touch_id) { 294 int touch_id) {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 CheckInternalDisplay(); 488 CheckInternalDisplay();
492 } 489 }
493 490
494 // Checks projection touch HUD with a sequence of touch-pressed, touch-moved, 491 // Checks projection touch HUD with a sequence of touch-pressed, touch-moved,
495 // and touch-released events. 492 // and touch-released events.
496 TEST_F(TouchHudProjectionTest, TouchMoveRelease) { 493 TEST_F(TouchHudProjectionTest, TouchMoveRelease) {
497 SetupSingleDisplay(); 494 SetupSingleDisplay();
498 EXPECT_EQ(NULL, GetInternalTouchHudProjection()); 495 EXPECT_EQ(NULL, GetInternalTouchHudProjection());
499 496
500 EnableTouchHudProjection(); 497 EnableTouchHudProjection();
501 EXPECT_NE(static_cast<internal::TouchHudProjection*>(NULL), 498 EXPECT_NE(static_cast<TouchHudProjection*>(NULL),
502 GetInternalTouchHudProjection()); 499 GetInternalTouchHudProjection());
503 EXPECT_EQ(0, GetInternalTouchPointsCount()); 500 EXPECT_EQ(0, GetInternalTouchPointsCount());
504 501
505 SendTouchEventToInternalHud(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1); 502 SendTouchEventToInternalHud(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1);
506 EXPECT_EQ(1, GetInternalTouchPointsCount()); 503 EXPECT_EQ(1, GetInternalTouchPointsCount());
507 504
508 SendTouchEventToInternalHud(ui::ET_TOUCH_MOVED, gfx::Point(10, 20), 1); 505 SendTouchEventToInternalHud(ui::ET_TOUCH_MOVED, gfx::Point(10, 20), 1);
509 EXPECT_EQ(1, GetInternalTouchPointsCount()); 506 EXPECT_EQ(1, GetInternalTouchPointsCount());
510 507
511 SendTouchEventToInternalHud(ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), 1); 508 SendTouchEventToInternalHud(ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), 1);
512 EXPECT_EQ(0, GetInternalTouchPointsCount()); 509 EXPECT_EQ(0, GetInternalTouchPointsCount());
513 510
514 // Disabling projection touch HUD shoud remove it without crashing. 511 // Disabling projection touch HUD shoud remove it without crashing.
515 DisableTouchHudProjection(); 512 DisableTouchHudProjection();
516 EXPECT_EQ(NULL, GetInternalTouchHudProjection()); 513 EXPECT_EQ(NULL, GetInternalTouchHudProjection());
517 } 514 }
518 515
519 // Checks projection touch HUD with a sequence of touch-pressed, touch-moved, 516 // Checks projection touch HUD with a sequence of touch-pressed, touch-moved,
520 // and touch-cancelled events. 517 // and touch-cancelled events.
521 TEST_F(TouchHudProjectionTest, TouchMoveCancel) { 518 TEST_F(TouchHudProjectionTest, TouchMoveCancel) {
522 SetupSingleDisplay(); 519 SetupSingleDisplay();
523 EXPECT_EQ(NULL, GetInternalTouchHudProjection()); 520 EXPECT_EQ(NULL, GetInternalTouchHudProjection());
524 521
525 EnableTouchHudProjection(); 522 EnableTouchHudProjection();
526 EXPECT_NE(static_cast<internal::TouchHudProjection*>(NULL), 523 EXPECT_NE(static_cast<TouchHudProjection*>(NULL),
527 GetInternalTouchHudProjection()); 524 GetInternalTouchHudProjection());
528 EXPECT_EQ(0, GetInternalTouchPointsCount()); 525 EXPECT_EQ(0, GetInternalTouchPointsCount());
529 526
530 SendTouchEventToInternalHud(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1); 527 SendTouchEventToInternalHud(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1);
531 EXPECT_EQ(1, GetInternalTouchPointsCount()); 528 EXPECT_EQ(1, GetInternalTouchPointsCount());
532 529
533 SendTouchEventToInternalHud(ui::ET_TOUCH_MOVED, gfx::Point(10, 20), 1); 530 SendTouchEventToInternalHud(ui::ET_TOUCH_MOVED, gfx::Point(10, 20), 1);
534 EXPECT_EQ(1, GetInternalTouchPointsCount()); 531 EXPECT_EQ(1, GetInternalTouchPointsCount());
535 532
536 SendTouchEventToInternalHud(ui::ET_TOUCH_CANCELLED, gfx::Point(10, 20), 1); 533 SendTouchEventToInternalHud(ui::ET_TOUCH_CANCELLED, gfx::Point(10, 20), 1);
537 EXPECT_EQ(0, GetInternalTouchPointsCount()); 534 EXPECT_EQ(0, GetInternalTouchPointsCount());
538 535
539 // Disabling projection touch HUD shoud remove it without crashing. 536 // Disabling projection touch HUD shoud remove it without crashing.
540 DisableTouchHudProjection(); 537 DisableTouchHudProjection();
541 EXPECT_EQ(NULL, GetInternalTouchHudProjection()); 538 EXPECT_EQ(NULL, GetInternalTouchHudProjection());
542 } 539 }
543 540
544 // Checks projection touch HUD with two simultaneous touches. 541 // Checks projection touch HUD with two simultaneous touches.
545 TEST_F(TouchHudProjectionTest, DoubleTouch) { 542 TEST_F(TouchHudProjectionTest, DoubleTouch) {
546 SetupSingleDisplay(); 543 SetupSingleDisplay();
547 EXPECT_EQ(NULL, GetInternalTouchHudProjection()); 544 EXPECT_EQ(NULL, GetInternalTouchHudProjection());
548 545
549 EnableTouchHudProjection(); 546 EnableTouchHudProjection();
550 EXPECT_NE(static_cast<internal::TouchHudProjection*>(NULL), 547 EXPECT_NE(static_cast<TouchHudProjection*>(NULL),
551 GetInternalTouchHudProjection()); 548 GetInternalTouchHudProjection());
552 EXPECT_EQ(0, GetInternalTouchPointsCount()); 549 EXPECT_EQ(0, GetInternalTouchPointsCount());
553 550
554 SendTouchEventToInternalHud(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1); 551 SendTouchEventToInternalHud(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1);
555 EXPECT_EQ(1, GetInternalTouchPointsCount()); 552 EXPECT_EQ(1, GetInternalTouchPointsCount());
556 553
557 SendTouchEventToInternalHud(ui::ET_TOUCH_PRESSED, gfx::Point(20, 10), 2); 554 SendTouchEventToInternalHud(ui::ET_TOUCH_PRESSED, gfx::Point(20, 10), 2);
558 EXPECT_EQ(2, GetInternalTouchPointsCount()); 555 EXPECT_EQ(2, GetInternalTouchPointsCount());
559 556
560 SendTouchEventToInternalHud(ui::ET_TOUCH_MOVED, gfx::Point(10, 20), 1); 557 SendTouchEventToInternalHud(ui::ET_TOUCH_MOVED, gfx::Point(10, 20), 1);
(...skipping 13 matching lines...) Expand all
574 EXPECT_EQ(NULL, GetInternalTouchHudProjection()); 571 EXPECT_EQ(NULL, GetInternalTouchHudProjection());
575 } 572 }
576 573
577 // Checks if turning off touch HUD projection while touching the screen is 574 // Checks if turning off touch HUD projection while touching the screen is
578 // handled correctly. 575 // handled correctly.
579 TEST_F(TouchHudProjectionTest, DisableWhileTouching) { 576 TEST_F(TouchHudProjectionTest, DisableWhileTouching) {
580 SetupSingleDisplay(); 577 SetupSingleDisplay();
581 EXPECT_EQ(NULL, GetInternalTouchHudProjection()); 578 EXPECT_EQ(NULL, GetInternalTouchHudProjection());
582 579
583 EnableTouchHudProjection(); 580 EnableTouchHudProjection();
584 EXPECT_NE(static_cast<internal::TouchHudProjection*>(NULL), 581 EXPECT_NE(static_cast<TouchHudProjection*>(NULL),
585 GetInternalTouchHudProjection()); 582 GetInternalTouchHudProjection());
586 EXPECT_EQ(0, GetInternalTouchPointsCount()); 583 EXPECT_EQ(0, GetInternalTouchPointsCount());
587 584
588 SendTouchEventToInternalHud(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1); 585 SendTouchEventToInternalHud(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1);
589 EXPECT_EQ(1, GetInternalTouchPointsCount()); 586 EXPECT_EQ(1, GetInternalTouchPointsCount());
590 587
591 // Disabling projection touch HUD shoud remove it without crashing. 588 // Disabling projection touch HUD shoud remove it without crashing.
592 DisableTouchHudProjection(); 589 DisableTouchHudProjection();
593 EXPECT_EQ(NULL, GetInternalTouchHudProjection()); 590 EXPECT_EQ(NULL, GetInternalTouchHudProjection());
594 } 591 }
595 592
596 } // namespace internal
597 } // namespace ash 593 } // namespace ash
OLDNEW
« no previous file with comments | « ash/touch/touch_observer_hud.cc ('k') | ash/wm/always_on_top_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698