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

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

Issue 2100453002: Remove unnecessary mocking of TickClock for events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@614409-confirm-timestamp-timebase
Patch Set: Fix touch_unittests Created 4 years, 5 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
« no previous file with comments | « no previous file | components/exo/touch_unittest.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/common/system/web_notification/web_notification_tray.h" 5 #include "ash/common/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/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
11 #include "ash/common/shell_window_ids.h" 11 #include "ash/common/shell_window_ids.h"
12 #include "ash/common/system/tray/system_tray_item.h" 12 #include "ash/common/system/tray/system_tray_item.h"
13 #include "ash/common/system/web_notification/ash_popup_alignment_delegate.h" 13 #include "ash/common/system/web_notification/ash_popup_alignment_delegate.h"
14 #include "ash/common/wm/window_state.h" 14 #include "ash/common/wm/window_state.h"
15 #include "ash/common/wm_lookup.h" 15 #include "ash/common/wm_lookup.h"
16 #include "ash/common/wm_root_window_controller.h" 16 #include "ash/common/wm_root_window_controller.h"
17 #include "ash/common/wm_shell.h" 17 #include "ash/common/wm_shell.h"
18 #include "ash/common/wm_window.h" 18 #include "ash/common/wm_window.h"
19 #include "ash/display/display_manager.h" 19 #include "ash/display/display_manager.h"
20 #include "ash/shell.h" 20 #include "ash/shell.h"
21 #include "ash/system/status_area_widget.h" 21 #include "ash/system/status_area_widget.h"
22 #include "ash/system/tray/system_tray.h" 22 #include "ash/system/tray/system_tray.h"
23 #include "ash/test/ash_test_base.h" 23 #include "ash/test/ash_test_base.h"
24 #include "ash/test/status_area_widget_test_helper.h" 24 #include "ash/test/status_area_widget_test_helper.h"
25 #include "ash/test/test_system_tray_delegate.h" 25 #include "ash/test/test_system_tray_delegate.h"
26 #include "base/strings/stringprintf.h" 26 #include "base/strings/stringprintf.h"
27 #include "base/strings/utf_string_conversions.h" 27 #include "base/strings/utf_string_conversions.h"
28 #include "ui/display/display.h" 28 #include "ui/display/display.h"
29 #include "ui/display/screen.h" 29 #include "ui/display/screen.h"
30 #include "ui/events/base_event_utils.h"
30 #include "ui/events/event.h" 31 #include "ui/events/event.h"
31 #include "ui/events/test/event_generator.h" 32 #include "ui/events/test/event_generator.h"
32 #include "ui/gfx/geometry/point.h" 33 #include "ui/gfx/geometry/point.h"
33 #include "ui/gfx/geometry/rect.h" 34 #include "ui/gfx/geometry/rect.h"
34 #include "ui/message_center/message_center_style.h" 35 #include "ui/message_center/message_center_style.h"
35 #include "ui/message_center/message_center_tray.h" 36 #include "ui/message_center/message_center_tray.h"
36 #include "ui/message_center/notification_list.h" 37 #include "ui/message_center/notification_list.h"
37 #include "ui/message_center/notification_types.h" 38 #include "ui/message_center/notification_types.h"
38 #include "ui/message_center/views/message_center_bubble.h" 39 #include "ui/message_center/views/message_center_bubble.h"
39 #include "ui/message_center/views/message_popup_collection.h" 40 #include "ui/message_center/views/message_popup_collection.h"
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 AddNotification("test_id"); 482 AddNotification("test_id");
482 RunAllPendingInMessageLoop(); 483 RunAllPendingInMessageLoop();
483 WebNotificationTray* tray = GetTray(); 484 WebNotificationTray* tray = GetTray();
484 EXPECT_TRUE(tray->visible()); 485 EXPECT_TRUE(tray->visible());
485 486
486 ui::test::EventGenerator& generator = GetEventGenerator(); 487 ui::test::EventGenerator& generator = GetEventGenerator();
487 const int touch_id = 0; 488 const int touch_id = 0;
488 gfx::Point center_point = tray->GetBoundsInScreen().CenterPoint(); 489 gfx::Point center_point = tray->GetBoundsInScreen().CenterPoint();
489 490
490 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, center_point, touch_id, 491 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, center_point, touch_id,
491 generator.Now()); 492 ui::EventTimeForNow());
492 generator.Dispatch(&press); 493 generator.Dispatch(&press);
493 EXPECT_TRUE(tray->draw_background_as_active()); 494 EXPECT_TRUE(tray->draw_background_as_active());
494 495
495 ui::TouchEvent release( 496 ui::TouchEvent release(
496 ui::ET_TOUCH_RELEASED, center_point, touch_id, 497 ui::ET_TOUCH_RELEASED, center_point, touch_id,
497 press.time_stamp() + base::TimeDelta::FromMilliseconds(50)); 498 press.time_stamp() + base::TimeDelta::FromMilliseconds(50));
498 generator.Dispatch(&release); 499 generator.Dispatch(&release);
499 EXPECT_TRUE(tray->draw_background_as_active()); 500 EXPECT_TRUE(tray->draw_background_as_active());
500 EXPECT_TRUE(tray->IsMessageCenterBubbleVisible()); 501 EXPECT_TRUE(tray->IsMessageCenterBubbleVisible());
501 502
502 generator.GestureTapAt(center_point); 503 generator.GestureTapAt(center_point);
503 EXPECT_FALSE(tray->draw_background_as_active()); 504 EXPECT_FALSE(tray->draw_background_as_active());
504 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible()); 505 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible());
505 } 506 }
506 507
507 // Tests that while touch presses trigger visual feedback, that subsequent non 508 // Tests that while touch presses trigger visual feedback, that subsequent non
508 // tap gestures cancel the feedback without triggering the message center. 509 // tap gestures cancel the feedback without triggering the message center.
509 TEST_F(WebNotificationTrayTest, TouchFeedbackCancellation) { 510 TEST_F(WebNotificationTrayTest, TouchFeedbackCancellation) {
510 AddNotification("test_id"); 511 AddNotification("test_id");
511 RunAllPendingInMessageLoop(); 512 RunAllPendingInMessageLoop();
512 WebNotificationTray* tray = GetTray(); 513 WebNotificationTray* tray = GetTray();
513 EXPECT_TRUE(tray->visible()); 514 EXPECT_TRUE(tray->visible());
514 515
515 ui::test::EventGenerator& generator = GetEventGenerator(); 516 ui::test::EventGenerator& generator = GetEventGenerator();
516 const int touch_id = 0; 517 const int touch_id = 0;
517 gfx::Rect bounds = tray->GetBoundsInScreen(); 518 gfx::Rect bounds = tray->GetBoundsInScreen();
518 gfx::Point center_point = bounds.CenterPoint(); 519 gfx::Point center_point = bounds.CenterPoint();
519 520
520 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, center_point, touch_id, 521 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, center_point, touch_id,
521 generator.Now()); 522 ui::EventTimeForNow());
522 generator.Dispatch(&press); 523 generator.Dispatch(&press);
523 EXPECT_TRUE(tray->draw_background_as_active()); 524 EXPECT_TRUE(tray->draw_background_as_active());
524 525
525 gfx::Point out_of_bounds(bounds.x() - 1, center_point.y()); 526 gfx::Point out_of_bounds(bounds.x() - 1, center_point.y());
526 ui::TouchEvent move( 527 ui::TouchEvent move(
527 ui::ET_TOUCH_MOVED, out_of_bounds, touch_id, 528 ui::ET_TOUCH_MOVED, out_of_bounds, touch_id,
528 press.time_stamp() + base::TimeDelta::FromMilliseconds(50)); 529 press.time_stamp() + base::TimeDelta::FromMilliseconds(50));
529 generator.Dispatch(&move); 530 generator.Dispatch(&move);
530 EXPECT_FALSE(tray->draw_background_as_active()); 531 EXPECT_FALSE(tray->draw_background_as_active());
531 532
532 ui::TouchEvent release( 533 ui::TouchEvent release(
533 ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id, 534 ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id,
534 move.time_stamp() + base::TimeDelta::FromMilliseconds(50)); 535 move.time_stamp() + base::TimeDelta::FromMilliseconds(50));
535 generator.Dispatch(&release); 536 generator.Dispatch(&release);
536 EXPECT_FALSE(tray->draw_background_as_active()); 537 EXPECT_FALSE(tray->draw_background_as_active());
537 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible()); 538 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible());
538 } 539 }
539 540
540 #endif // OS_CHROMEOS 541 #endif // OS_CHROMEOS
541 542
542 } // namespace ash 543 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | components/exo/touch_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698