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

Unified Diff: athena/home/home_card_unittest.cc

Issue 498823002: Adds tests of home card state transition upon gestures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« athena/home/home_card_impl.cc ('K') | « athena/home/home_card_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: athena/home/home_card_unittest.cc
diff --git a/athena/home/home_card_unittest.cc b/athena/home/home_card_unittest.cc
index 86b9cd115b28058103f7038ec5a1a125c17136fe..92daeba696b9ee1fae95314f2d62287d03bad9c9 100644
--- a/athena/home/home_card_unittest.cc
+++ b/athena/home/home_card_unittest.cc
@@ -88,10 +88,10 @@ TEST_F(HomeCardTest, MouseClick) {
// Mouse click at the bottom of the screen should invokes overview mode and
// changes the state to BOTTOM.
- ui::test::EventGenerator generator(root_window());
gfx::Rect screen_rect(root_window()->bounds());
- generator.MoveMouseTo(gfx::Point(
- screen_rect.x() + screen_rect.width() / 2, screen_rect.bottom() - 1));
+ ui::test::EventGenerator generator(
+ root_window(), gfx::Point(
+ screen_rect.x() + screen_rect.width() / 2, screen_rect.bottom() - 1));
generator.ClickLeftButton();
EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState());
@@ -103,4 +103,83 @@ TEST_F(HomeCardTest, MouseClick) {
EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive());
}
+TEST_F(HomeCardTest, Gestures) {
+ ASSERT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState());
+ ui::test::EventGenerator generator(root_window());
+ gfx::Rect screen_rect(root_window()->bounds());
+
+ const int bottom = screen_rect.bottom();
+ const int x = screen_rect.x() + 1;
+
+ generator.GestureScrollSequence(gfx::Point(x, bottom - 1),
+ gfx::Point(x, bottom - 40),
+ base::TimeDelta::FromSeconds(1),
+ 10);
+ EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState());
+ EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive());
+
+ // Too short moves. Nothing has changed.
+ generator.GestureScrollSequence(gfx::Point(x, bottom - 40),
+ gfx::Point(x, bottom - 80),
+ base::TimeDelta::FromSeconds(1),
+ 10);
+ EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState());
+ EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive());
+
+ generator.GestureScrollSequence(gfx::Point(x, bottom - 40),
+ gfx::Point(x, bottom - 20),
+ base::TimeDelta::FromSeconds(1),
+ 10);
+ EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState());
+ EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive());
+
+ // Swipe up to the centered state.
+ generator.GestureScrollSequence(gfx::Point(x, bottom - 40),
+ gfx::Point(x, bottom - 300),
+ base::TimeDelta::FromSeconds(1),
+ 10);
+ EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState());
+ EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive());
+
+ // Swipe up from centered; nothing has to be changed.
+ generator.GestureScrollSequence(gfx::Point(x, bottom - 300),
+ gfx::Point(x, bottom - 350),
+ base::TimeDelta::FromSeconds(1),
+ 10);
+ EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState());
+ EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive());
+
+ // Swipe down slightly; nothing has to be changed.
+ generator.GestureScrollSequence(gfx::Point(x, bottom - 300),
+ gfx::Point(x, bottom - 250),
+ base::TimeDelta::FromSeconds(1),
+ 10);
+ EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState());
+ EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive());
+
+ // Swipe down to the bottom state.
+ generator.GestureScrollSequence(gfx::Point(x, 10),
+ gfx::Point(x, bottom - 40),
+ base::TimeDelta::FromSeconds(1),
+ 10);
+ EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState());
+ EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive());
+
+ generator.GestureScrollSequence(gfx::Point(x, bottom - 40),
+ gfx::Point(x, bottom - 300),
+ base::TimeDelta::FromSeconds(1),
+ 10);
+ EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState());
+ EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive());
+
+ // Swipe down to the minimized state.
+ generator.GestureScrollSequence(gfx::Point(x, 10),
+ gfx::Point(x, bottom - 1),
+ base::TimeDelta::FromSeconds(1),
+ 10);
+ EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState());
+ EXPECT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive());
+
+}
+
} // namespace athena
« athena/home/home_card_impl.cc ('K') | « athena/home/home_card_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698