Chromium Code Reviews| Index: ash/system/date/date_view_unittest.cc |
| diff --git a/ash/system/date/date_view_unittest.cc b/ash/system/date/date_view_unittest.cc |
| index 4bada635c592f6d325ed64c9ce90c5c8c9e9fee4..709a4c5dc7a75e756ee53dc12d3c0999daeba5d3 100644 |
| --- a/ash/system/date/date_view_unittest.cc |
| +++ b/ash/system/date/date_view_unittest.cc |
| @@ -4,13 +4,24 @@ |
| #include "ash/system/date/date_view.h" |
| +#include "ash/ash_switches.h" |
| +#include "ash/root_window_controller.h" |
| +#include "ash/shelf/shelf_widget.h" |
| +#include "ash/shell.h" |
| +#include "ash/system/date/date_default_view.h" |
| +#include "ash/system/status_area_widget.h" |
| +#include "ash/system/tray/system_tray.h" |
| #include "ash/test/ash_test_base.h" |
| +#include "base/command_line.h" |
| +#include "ui/events/test/event_generator.h" |
| +#include "ui/gfx/point.h" |
| +#include "ui/gfx/rect.h" |
| #include "ui/views/controls/label.h" |
| namespace ash { |
| namespace tray { |
| -class TimeViewTest : public ash::test::AshTestBase { |
| +class TimeViewTest : public test::AshTestBase { |
| public: |
| TimeViewTest() {} |
| virtual ~TimeViewTest() {} |
| @@ -60,5 +71,81 @@ TEST_F(TimeViewTest, Basics) { |
| EXPECT_FALSE(vertical_label_minutes()->parent()); |
| } |
| +class DateViewTest : public test::AshTestBase { |
| + public: |
| + DateViewTest() {} |
| + virtual ~DateViewTest() {} |
| + |
| + // Returns the instance of DateView created by the SystemTray once the default |
| + // views have been created. |
| + const DateView* GetDateView() const; |
| + |
| + // Forces the SystemTray to create all default views and to show them. |
| + void LaunchDefaultViews(); |
| + |
| + virtual void SetUp() OVERRIDE { |
| + CommandLine::ForCurrentProcess()->AppendSwitch( |
| + switches::kAshEnableTouchViewTouchFeedback); |
| + test::AshTestBase::SetUp(); |
| + } |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(DateViewTest); |
| +}; |
| + |
| +const DateView* DateViewTest::GetDateView() const { |
| + return Shell::GetPrimaryRootWindowController()->shelf()-> |
| + status_area_widget()->system_tray()->GetTrayDateForTesting()-> |
| + GetDefaultViewForTesting()->GetDateView(); |
| +} |
| + |
| +void DateViewTest::LaunchDefaultViews() { |
| + Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget()-> |
| + system_tray()->ShowDefaultView(BUBBLE_CREATE_NEW); |
| +} |
| + |
| +// Tests that touch interactions triggers the active render state while the |
| +// touch is occuring. |
| +TEST_F(DateViewTest, TouchFeedback) { |
| + LaunchDefaultViews(); |
| + const DateView* view = GetDateView(); |
| + EXPECT_FALSE(view->active()); |
| + |
| + ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| + generator.set_current_location(view->GetBoundsInScreen().CenterPoint()); |
| + generator.PressTouch(); |
| + RunAllPendingInMessageLoop(); |
| + EXPECT_TRUE(view->active()); |
| + |
| + generator.ReleaseTouch(); |
| + RunAllPendingInMessageLoop(); |
| + EXPECT_FALSE(view->active()); |
| +} |
| + |
| +// Tests that touch interactions that leave the DateView cancel the active |
| +// state. |
| +TEST_F(DateViewTest, TouchFeedbackCancellation) { |
| + LaunchDefaultViews(); |
| + const DateView* view = GetDateView(); |
| + EXPECT_FALSE(view->active()); |
| + |
| + gfx::Rect view_bounds = view->GetBoundsInScreen(); |
| + ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| + generator.set_current_location(view_bounds.CenterPoint()); |
| + generator.PressTouch(); |
| + RunAllPendingInMessageLoop(); |
| + EXPECT_TRUE(view->active()); |
| + |
| + gfx::Point move_point(view_bounds.x(), view_bounds.CenterPoint().y()); |
|
jonross
2014/09/12 19:18:29
Due to crbug.com/413844 and the removal of acting
|
| + generator.MoveTouch(move_point); |
| + RunAllPendingInMessageLoop(); |
| + EXPECT_FALSE(view->active()); |
| + |
| + generator.set_current_location(move_point); |
| + generator.ReleaseTouch(); |
| + RunAllPendingInMessageLoop(); |
| + EXPECT_FALSE(view->active()); |
| +} |
| + |
| } // namespace tray |
| } // namespace ash |