Commit 59f71514 authored by mukai's avatar mukai Committed by Commit bot

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}
parent 0a553dff
...@@ -208,7 +208,6 @@ class HomeCardGestureManager { ...@@ -208,7 +208,6 @@ class HomeCardGestureManager {
smaller_top = top; smaller_top = top;
} }
NOTREACHED();
return last_state_; return last_state_;
} }
...@@ -250,7 +249,6 @@ class HomeCardGestureManager { ...@@ -250,7 +249,6 @@ class HomeCardGestureManager {
} }
smaller_bounds = bounds; smaller_bounds = bounds;
} }
NOTREACHED();
} }
Delegate* delegate_; Delegate* delegate_;
......
...@@ -88,10 +88,10 @@ TEST_F(HomeCardTest, MouseClick) { ...@@ -88,10 +88,10 @@ TEST_F(HomeCardTest, MouseClick) {
// Mouse click at the bottom of the screen should invokes overview mode and // Mouse click at the bottom of the screen should invokes overview mode and
// changes the state to BOTTOM. // changes the state to BOTTOM.
ui::test::EventGenerator generator(root_window());
gfx::Rect screen_rect(root_window()->bounds()); gfx::Rect screen_rect(root_window()->bounds());
generator.MoveMouseTo(gfx::Point( ui::test::EventGenerator generator(
screen_rect.x() + screen_rect.width() / 2, screen_rect.bottom() - 1)); root_window(), gfx::Point(
screen_rect.x() + screen_rect.width() / 2, screen_rect.bottom() - 1));
generator.ClickLeftButton(); generator.ClickLeftButton();
EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState());
...@@ -103,4 +103,83 @@ TEST_F(HomeCardTest, MouseClick) { ...@@ -103,4 +103,83 @@ TEST_F(HomeCardTest, MouseClick) {
EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive()); 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 } // namespace athena
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment