diff options
author | mukai <mukai@chromium.org> | 2014-08-23 23:16:46 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-24 06:17:13 +0000 |
commit | 59f71514210683fbb694b5f73e99513203b9e072 (patch) | |
tree | c6d2125a300412d99a2a592e6af7fd9458a377c6 | |
parent | 0a553dff54bf9ca2d859e6595c2045c8d2e0785c (diff) | |
download | chromium_src-59f71514210683fbb694b5f73e99513203b9e072.zip chromium_src-59f71514210683fbb694b5f73e99513203b9e072.tar.gz chromium_src-59f71514210683fbb694b5f73e99513203b9e072.tar.bz2 |
Adds tests of home card state transition upon gestures.
BUG=403813
R=oshima@chromium.org
TEST=athena_unittests
Review URL: https://codereview.chromium.org/498823002
Cr-Commit-Position: refs/heads/master@{#291622}
-rw-r--r-- | athena/home/home_card_impl.cc | 2 | ||||
-rw-r--r-- | athena/home/home_card_unittest.cc | 85 |
2 files changed, 82 insertions, 5 deletions
diff --git a/athena/home/home_card_impl.cc b/athena/home/home_card_impl.cc index 042ff6c..7b73bc2 100644 --- a/athena/home/home_card_impl.cc +++ b/athena/home/home_card_impl.cc @@ -208,7 +208,6 @@ class HomeCardGestureManager { smaller_top = top; } - NOTREACHED(); return last_state_; } @@ -250,7 +249,6 @@ class HomeCardGestureManager { } smaller_bounds = bounds; } - NOTREACHED(); } Delegate* delegate_; diff --git a/athena/home/home_card_unittest.cc b/athena/home/home_card_unittest.cc index 86b9cd1..92daeba 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 |