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

Side by Side Diff: ash/system/web_notification/web_notification_tray_unittest.cc

Issue 2075953003: mash: Convert WebNotificationTray to wm common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@statusarea
Patch Set: rebase Created 4 years, 6 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
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/system/web_notification/web_notification_tray.h" 5 #include "ash/system/web_notification/web_notification_tray.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/common/shell_window_ids.h" 10 #include "ash/common/shell_window_ids.h"
11 #include "ash/common/system/tray/system_tray_item.h" 11 #include "ash/common/system/tray/system_tray_item.h"
12 #include "ash/common/wm/window_state.h" 12 #include "ash/common/wm/window_state.h"
13 #include "ash/common/wm_lookup.h" 13 #include "ash/common/wm_lookup.h"
14 #include "ash/common/wm_root_window_controller.h" 14 #include "ash/common/wm_root_window_controller.h"
15 #include "ash/common/wm_shell.h" 15 #include "ash/common/wm_shell.h"
16 #include "ash/common/wm_window.h" 16 #include "ash/common/wm_window.h"
17 #include "ash/display/display_manager.h" 17 #include "ash/display/display_manager.h"
18 #include "ash/root_window_controller.h"
19 #include "ash/shelf/shelf_layout_manager.h" 18 #include "ash/shelf/shelf_layout_manager.h"
20 #include "ash/shell.h" 19 #include "ash/shell.h"
21 #include "ash/system/status_area_widget.h" 20 #include "ash/system/status_area_widget.h"
22 #include "ash/system/tray/system_tray.h" 21 #include "ash/system/tray/system_tray.h"
23 #include "ash/system/web_notification/ash_popup_alignment_delegate.h" 22 #include "ash/system/web_notification/ash_popup_alignment_delegate.h"
24 #include "ash/test/ash_test_base.h" 23 #include "ash/test/ash_test_base.h"
25 #include "ash/test/status_area_widget_test_helper.h" 24 #include "ash/test/status_area_widget_test_helper.h"
26 #include "ash/test/test_system_tray_delegate.h" 25 #include "ash/test/test_system_tray_delegate.h"
27 #include "base/strings/stringprintf.h" 26 #include "base/strings/stringprintf.h"
28 #include "base/strings/utf_string_conversions.h" 27 #include "base/strings/utf_string_conversions.h"
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 widget->SetFullscreen(true); 441 widget->SetFullscreen(true);
443 RunAllPendingInMessageLoop(); 442 RunAllPendingInMessageLoop();
444 443
445 // The work area for auto-hidden status of fullscreen is a bit larger 444 // The work area for auto-hidden status of fullscreen is a bit larger
446 // since it doesn't even have the 3-pixel width. 445 // since it doesn't even have the 3-pixel width.
447 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 446 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
448 int bottom_fullscreen_hidden = GetPopupWorkAreaBottom(); 447 int bottom_fullscreen_hidden = GetPopupWorkAreaBottom();
449 EXPECT_EQ(bottom_auto_hidden, bottom_fullscreen_hidden); 448 EXPECT_EQ(bottom_auto_hidden, bottom_fullscreen_hidden);
450 449
451 // Move the mouse cursor at the bottom, which shows the shelf. 450 // Move the mouse cursor at the bottom, which shows the shelf.
452 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 451 ui::test::EventGenerator& generator = GetEventGenerator();
453 gfx::Point bottom_right = 452 gfx::Point bottom_right =
454 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom_right(); 453 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom_right();
455 bottom_right.Offset(-1, -1); 454 bottom_right.Offset(-1, -1);
456 generator.MoveMouseTo(bottom_right); 455 generator.MoveMouseTo(bottom_right);
457 shelf->shelf_layout_manager()->UpdateAutoHideStateNow(); 456 shelf->shelf_layout_manager()->UpdateAutoHideStateNow();
458 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); 457 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
459 EXPECT_EQ(bottom, GetPopupWorkAreaBottom()); 458 EXPECT_EQ(bottom, GetPopupWorkAreaBottom());
460 459
461 generator.MoveMouseTo( 460 generator.MoveMouseTo(
462 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint()); 461 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint());
(...skipping 20 matching lines...) Expand all
483 // EventGenerator.PressTouch/ReleaseTouch. Currently they set a width on the 482 // EventGenerator.PressTouch/ReleaseTouch. Currently they set a width on the
484 // touch event causing the gesture recognizer to target a different view. 483 // touch event causing the gesture recognizer to target a different view.
485 #if defined(OS_CHROMEOS) 484 #if defined(OS_CHROMEOS)
486 // Tests that there is visual feedback for touch presses. 485 // Tests that there is visual feedback for touch presses.
487 TEST_F(WebNotificationTrayTest, TouchFeedback) { 486 TEST_F(WebNotificationTrayTest, TouchFeedback) {
488 AddNotification("test_id"); 487 AddNotification("test_id");
489 RunAllPendingInMessageLoop(); 488 RunAllPendingInMessageLoop();
490 WebNotificationTray* tray = GetTray(); 489 WebNotificationTray* tray = GetTray();
491 EXPECT_TRUE(tray->visible()); 490 EXPECT_TRUE(tray->visible());
492 491
493 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 492 ui::test::EventGenerator& generator = GetEventGenerator();
494 const int touch_id = 0; 493 const int touch_id = 0;
495 gfx::Point center_point = tray->GetBoundsInScreen().CenterPoint(); 494 gfx::Point center_point = tray->GetBoundsInScreen().CenterPoint();
496 495
497 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, center_point, touch_id, 496 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, center_point, touch_id,
498 generator.Now()); 497 generator.Now());
499 generator.Dispatch(&press); 498 generator.Dispatch(&press);
500 EXPECT_TRUE(tray->draw_background_as_active()); 499 EXPECT_TRUE(tray->draw_background_as_active());
501 500
502 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, center_point, touch_id, 501 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, center_point, touch_id,
503 press.time_stamp() + base::TimeDelta::FromMilliseconds(50)); 502 press.time_stamp() + base::TimeDelta::FromMilliseconds(50));
504 generator.Dispatch(&release); 503 generator.Dispatch(&release);
505 EXPECT_TRUE(tray->draw_background_as_active()); 504 EXPECT_TRUE(tray->draw_background_as_active());
506 EXPECT_TRUE(tray->IsMessageCenterBubbleVisible()); 505 EXPECT_TRUE(tray->IsMessageCenterBubbleVisible());
507 506
508 generator.GestureTapAt(center_point); 507 generator.GestureTapAt(center_point);
509 EXPECT_FALSE(tray->draw_background_as_active()); 508 EXPECT_FALSE(tray->draw_background_as_active());
510 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible()); 509 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible());
511 } 510 }
512 511
513 // Tests that while touch presses trigger visual feedback, that subsequent non 512 // Tests that while touch presses trigger visual feedback, that subsequent non
514 // tap gestures cancel the feedback without triggering the message center. 513 // tap gestures cancel the feedback without triggering the message center.
515 TEST_F(WebNotificationTrayTest, TouchFeedbackCancellation) { 514 TEST_F(WebNotificationTrayTest, TouchFeedbackCancellation) {
516 AddNotification("test_id"); 515 AddNotification("test_id");
517 RunAllPendingInMessageLoop(); 516 RunAllPendingInMessageLoop();
518 WebNotificationTray* tray = GetTray(); 517 WebNotificationTray* tray = GetTray();
519 EXPECT_TRUE(tray->visible()); 518 EXPECT_TRUE(tray->visible());
520 519
521 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 520 ui::test::EventGenerator& generator = GetEventGenerator();
522 const int touch_id = 0; 521 const int touch_id = 0;
523 gfx::Rect bounds = tray->GetBoundsInScreen(); 522 gfx::Rect bounds = tray->GetBoundsInScreen();
524 gfx::Point center_point = bounds.CenterPoint(); 523 gfx::Point center_point = bounds.CenterPoint();
525 524
526 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, center_point, touch_id, 525 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, center_point, touch_id,
527 generator.Now()); 526 generator.Now());
528 generator.Dispatch(&press); 527 generator.Dispatch(&press);
529 EXPECT_TRUE(tray->draw_background_as_active()); 528 EXPECT_TRUE(tray->draw_background_as_active());
530 529
531 gfx::Point out_of_bounds(bounds.x() - 1, center_point.y()); 530 gfx::Point out_of_bounds(bounds.x() - 1, center_point.y());
532 ui::TouchEvent move(ui::ET_TOUCH_MOVED, out_of_bounds, touch_id, 531 ui::TouchEvent move(ui::ET_TOUCH_MOVED, out_of_bounds, touch_id,
533 press.time_stamp()+base::TimeDelta::FromMilliseconds(50)); 532 press.time_stamp()+base::TimeDelta::FromMilliseconds(50));
534 generator.Dispatch(&move); 533 generator.Dispatch(&move);
535 EXPECT_FALSE(tray->draw_background_as_active()); 534 EXPECT_FALSE(tray->draw_background_as_active());
536 535
537 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id, 536 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id,
538 move.time_stamp()+base::TimeDelta::FromMilliseconds(50)); 537 move.time_stamp()+base::TimeDelta::FromMilliseconds(50));
539 generator.Dispatch(&release); 538 generator.Dispatch(&release);
540 EXPECT_FALSE(tray->draw_background_as_active()); 539 EXPECT_FALSE(tray->draw_background_as_active());
541 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible()); 540 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible());
542 } 541 }
543 542
544 #endif // OS_CHROMEOS 543 #endif // OS_CHROMEOS
545 544
546 } // namespace ash 545 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/web_notification/web_notification_tray.cc ('k') | chrome/browser/ui/views/message_center/web_notification_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698