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

Side by Side Diff: ash/common/system/tray/system_tray_unittest.cc

Issue 2678343006: Remove non-MD test coverage from SystemTrayTest (Closed)
Patch Set: Created 3 years, 10 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 | no next file » | 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/tray/system_tray.h" 5 #include "ash/common/system/tray/system_tray.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/common/accelerators/accelerator_controller.h" 10 #include "ash/common/accelerators/accelerator_controller.h"
11 #include "ash/common/accessibility_delegate.h" 11 #include "ash/common/accessibility_delegate.h"
12 #include "ash/common/material_design/material_design_controller.h"
13 #include "ash/common/shelf/wm_shelf.h" 12 #include "ash/common/shelf/wm_shelf.h"
14 #include "ash/common/system/status_area_widget.h" 13 #include "ash/common/system/status_area_widget.h"
15 #include "ash/common/system/tray/system_tray_bubble.h" 14 #include "ash/common/system/tray/system_tray_bubble.h"
16 #include "ash/common/system/tray/system_tray_item.h" 15 #include "ash/common/system/tray/system_tray_item.h"
17 #include "ash/common/system/tray/tray_constants.h" 16 #include "ash/common/system/tray/tray_constants.h"
18 #include "ash/common/system/tray/tray_popup_item_container.h" 17 #include "ash/common/system/tray/tray_popup_item_container.h"
19 #include "ash/common/system/web_notification/web_notification_tray.h" 18 #include "ash/common/system/web_notification/web_notification_tray.h"
20 #include "ash/common/wm_shell.h" 19 #include "ash/common/wm_shell.h"
21 #include "ash/common/wm_window.h" 20 #include "ash/common/wm_window.h"
22 #include "ash/public/cpp/shell_window_ids.h" 21 #include "ash/public/cpp/shell_window_ids.h"
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 // Close the modal dialog. 530 // Close the modal dialog.
532 widget.reset(); 531 widget.reset();
533 532
534 tray->ShowDefaultView(BUBBLE_CREATE_NEW); 533 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
535 // System modal is gone. The bubble should now contains settings 534 // System modal is gone. The bubble should now contains settings
536 // as well. 535 // as well.
537 accessibility = tray->GetSystemBubble()->bubble_view()->GetViewByID( 536 accessibility = tray->GetSystemBubble()->bubble_view()->GetViewByID(
538 test::kAccessibilityTrayItemViewId); 537 test::kAccessibilityTrayItemViewId);
539 ASSERT_TRUE(accessibility); 538 ASSERT_TRUE(accessibility);
540 EXPECT_TRUE(accessibility->visible()); 539 EXPECT_TRUE(accessibility->visible());
541
542 // Settings row is not present in material design.
543 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) {
544 const views::View* settings =
545 tray->GetSystemBubble()->bubble_view()->GetViewByID(
546 test::kSettingsTrayItemViewId);
547 ASSERT_TRUE(settings);
548 EXPECT_TRUE(settings->visible());
549 }
550 } 540 }
551 541
552 // Tests that if SetVisible(true) is called while animating to hidden that the 542 // Tests that if SetVisible(true) is called while animating to hidden that the
553 // tray becomes visible, and stops animating to hidden. 543 // tray becomes visible, and stops animating to hidden.
554 TEST_F(SystemTrayTest, SetVisibleDuringHideAnimation) { 544 TEST_F(SystemTrayTest, SetVisibleDuringHideAnimation) {
555 SystemTray* tray = GetPrimarySystemTray(); 545 SystemTray* tray = GetPrimarySystemTray();
556 ASSERT_TRUE(tray->visible()); 546 ASSERT_TRUE(tray->visible());
557 547
558 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> animation_duration; 548 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> animation_duration;
559 animation_duration.reset(new ui::ScopedAnimationDurationScaleMode( 549 animation_duration.reset(new ui::ScopedAnimationDurationScaleMode(
560 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); 550 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION));
561 tray->SetVisible(false); 551 tray->SetVisible(false);
562 EXPECT_TRUE(tray->visible()); 552 EXPECT_TRUE(tray->visible());
563 EXPECT_EQ(0.0f, tray->layer()->GetTargetOpacity()); 553 EXPECT_EQ(0.0f, tray->layer()->GetTargetOpacity());
564 554
565 tray->SetVisible(true); 555 tray->SetVisible(true);
566 animation_duration.reset(); 556 animation_duration.reset();
567 tray->layer()->GetAnimator()->StopAnimating(); 557 tray->layer()->GetAnimator()->StopAnimating();
568 EXPECT_TRUE(tray->visible()); 558 EXPECT_TRUE(tray->visible());
569 EXPECT_EQ(1.0f, tray->layer()->GetTargetOpacity()); 559 EXPECT_EQ(1.0f, tray->layer()->GetTargetOpacity());
570 } 560 }
571 561
572 // Tests that touch on an item in the system bubble triggers it to become
573 // active.
574 TEST_F(SystemTrayTest, TrayPopupItemContainerTouchFeedback) {
575 // Material design will use the ink drop ripple framework to show
576 // active states.
577 if (MaterialDesignController::IsSystemTrayMenuMaterial())
578 return;
579
580 SystemTray* tray = GetPrimarySystemTray();
581 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
582
583 TrayPopupItemContainer* view = static_cast<TrayPopupItemContainer*>(
584 tray->GetSystemBubble()->bubble_view()->child_at(0));
585 EXPECT_FALSE(view->active());
586
587 ui::test::EventGenerator& generator = GetEventGenerator();
588 generator.set_current_location(view->GetBoundsInScreen().CenterPoint());
589 generator.PressTouch();
590 EXPECT_TRUE(view->active());
591
592 generator.ReleaseTouch();
593 EXPECT_FALSE(view->active());
594 }
595
596 // Tests that touch events on an item in the system bubble cause it to stop
597 // being active.
598 TEST_F(SystemTrayTest, TrayPopupItemContainerTouchFeedbackCancellation) {
599 // Material design will use the ink drop ripple framework to show
600 // active states.
601 if (MaterialDesignController::IsSystemTrayMenuMaterial())
602 return;
603
604 SystemTray* tray = GetPrimarySystemTray();
605 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
606
607 TrayPopupItemContainer* view = static_cast<TrayPopupItemContainer*>(
608 tray->GetSystemBubble()->bubble_view()->child_at(0));
609 EXPECT_FALSE(view->active());
610
611 gfx::Rect view_bounds = view->GetBoundsInScreen();
612 ui::test::EventGenerator& generator = GetEventGenerator();
613 generator.set_current_location(view_bounds.CenterPoint());
614 generator.PressTouch();
615 EXPECT_TRUE(view->active());
616
617 gfx::Point move_point(view_bounds.x(), view_bounds.CenterPoint().y());
618 generator.MoveTouch(move_point);
619 EXPECT_FALSE(view->active());
620
621 generator.set_current_location(move_point);
622 generator.ReleaseTouch();
623 EXPECT_FALSE(view->active());
624 }
625
626 TEST_F(SystemTrayTest, SystemTrayHeightWithBubble) { 562 TEST_F(SystemTrayTest, SystemTrayHeightWithBubble) {
627 SystemTray* tray = GetPrimarySystemTray(); 563 SystemTray* tray = GetPrimarySystemTray();
628 WebNotificationTray* notification_tray = 564 WebNotificationTray* notification_tray =
629 StatusAreaWidgetTestHelper::GetStatusAreaWidget() 565 StatusAreaWidgetTestHelper::GetStatusAreaWidget()
630 ->web_notification_tray(); 566 ->web_notification_tray();
631 567
632 // Ensure the initial tray bubble height is zero. 568 // Ensure the initial tray bubble height is zero.
633 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test()); 569 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test());
634 570
635 // Show the default view, ensure the tray bubble height is changed. 571 // Show the default view, ensure the tray bubble height is changed.
636 tray->ShowDefaultView(BUBBLE_CREATE_NEW); 572 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
637 RunAllPendingInMessageLoop(); 573 RunAllPendingInMessageLoop();
638 EXPECT_LT(0, notification_tray->tray_bubble_height_for_test()); 574 EXPECT_LT(0, notification_tray->tray_bubble_height_for_test());
639 575
640 // Hide the default view, ensure the tray bubble height is back to zero. 576 // Hide the default view, ensure the tray bubble height is back to zero.
641 ASSERT_TRUE(tray->CloseSystemBubble()); 577 ASSERT_TRUE(tray->CloseSystemBubble());
642 RunAllPendingInMessageLoop(); 578 RunAllPendingInMessageLoop();
643 579
644 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test()); 580 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test());
645 } 581 }
646 582
647 } // namespace test 583 } // namespace test
648 } // namespace ash 584 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698