OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/home/public/home_card.h" | 5 #include "athena/home/public/home_card.h" |
6 | 6 |
7 #include "athena/activity/public/activity_factory.h" | 7 #include "athena/activity/public/activity_factory.h" |
8 #include "athena/activity/public/activity_manager.h" | 8 #include "athena/activity/public/activity_manager.h" |
9 #include "athena/test/athena_test_base.h" | 9 #include "athena/test/athena_test_base.h" |
10 #include "athena/wm/public/window_manager.h" | 10 #include "athena/wm/public/window_manager.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState()); | 81 EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState()); |
82 generator.PressKey(ui::VKEY_L, ui::EF_CONTROL_DOWN); | 82 generator.PressKey(ui::VKEY_L, ui::EF_CONTROL_DOWN); |
83 EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState()); | 83 EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState()); |
84 } | 84 } |
85 | 85 |
86 TEST_F(HomeCardTest, MouseClick) { | 86 TEST_F(HomeCardTest, MouseClick) { |
87 ASSERT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); | 87 ASSERT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); |
88 | 88 |
89 // Mouse click at the bottom of the screen should invokes overview mode and | 89 // Mouse click at the bottom of the screen should invokes overview mode and |
90 // changes the state to BOTTOM. | 90 // changes the state to BOTTOM. |
91 ui::test::EventGenerator generator(root_window()); | |
92 gfx::Rect screen_rect(root_window()->bounds()); | 91 gfx::Rect screen_rect(root_window()->bounds()); |
93 generator.MoveMouseTo(gfx::Point( | 92 ui::test::EventGenerator generator( |
94 screen_rect.x() + screen_rect.width() / 2, screen_rect.bottom() - 1)); | 93 root_window(), gfx::Point( |
| 94 screen_rect.x() + screen_rect.width() / 2, screen_rect.bottom() - 1)); |
95 generator.ClickLeftButton(); | 95 generator.ClickLeftButton(); |
96 | 96 |
97 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); | 97 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); |
98 EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive()); | 98 EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive()); |
99 | 99 |
100 // Further clicks are simply ignored. | 100 // Further clicks are simply ignored. |
101 generator.ClickLeftButton(); | 101 generator.ClickLeftButton(); |
102 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); | 102 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); |
103 EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive()); | 103 EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive()); |
104 } | 104 } |
105 | 105 |
| 106 TEST_F(HomeCardTest, Gestures) { |
| 107 ASSERT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); |
| 108 ui::test::EventGenerator generator(root_window()); |
| 109 gfx::Rect screen_rect(root_window()->bounds()); |
| 110 |
| 111 const int bottom = screen_rect.bottom(); |
| 112 const int x = screen_rect.x() + 1; |
| 113 |
| 114 generator.GestureScrollSequence(gfx::Point(x, bottom - 1), |
| 115 gfx::Point(x, bottom - 40), |
| 116 base::TimeDelta::FromSeconds(1), |
| 117 10); |
| 118 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); |
| 119 EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive()); |
| 120 |
| 121 // Too short moves. Nothing has changed. |
| 122 generator.GestureScrollSequence(gfx::Point(x, bottom - 40), |
| 123 gfx::Point(x, bottom - 80), |
| 124 base::TimeDelta::FromSeconds(1), |
| 125 10); |
| 126 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); |
| 127 EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive()); |
| 128 |
| 129 generator.GestureScrollSequence(gfx::Point(x, bottom - 40), |
| 130 gfx::Point(x, bottom - 20), |
| 131 base::TimeDelta::FromSeconds(1), |
| 132 10); |
| 133 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); |
| 134 EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive()); |
| 135 |
| 136 // Swipe up to the centered state. |
| 137 generator.GestureScrollSequence(gfx::Point(x, bottom - 40), |
| 138 gfx::Point(x, bottom - 300), |
| 139 base::TimeDelta::FromSeconds(1), |
| 140 10); |
| 141 EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState()); |
| 142 EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive()); |
| 143 |
| 144 // Swipe up from centered; nothing has to be changed. |
| 145 generator.GestureScrollSequence(gfx::Point(x, bottom - 300), |
| 146 gfx::Point(x, bottom - 350), |
| 147 base::TimeDelta::FromSeconds(1), |
| 148 10); |
| 149 EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState()); |
| 150 EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive()); |
| 151 |
| 152 // Swipe down slightly; nothing has to be changed. |
| 153 generator.GestureScrollSequence(gfx::Point(x, bottom - 300), |
| 154 gfx::Point(x, bottom - 250), |
| 155 base::TimeDelta::FromSeconds(1), |
| 156 10); |
| 157 EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState()); |
| 158 EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive()); |
| 159 |
| 160 // Swipe down to the bottom state. |
| 161 generator.GestureScrollSequence(gfx::Point(x, 10), |
| 162 gfx::Point(x, bottom - 40), |
| 163 base::TimeDelta::FromSeconds(1), |
| 164 10); |
| 165 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, HomeCard::Get()->GetState()); |
| 166 EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive()); |
| 167 |
| 168 generator.GestureScrollSequence(gfx::Point(x, bottom - 40), |
| 169 gfx::Point(x, bottom - 300), |
| 170 base::TimeDelta::FromSeconds(1), |
| 171 10); |
| 172 EXPECT_EQ(HomeCard::VISIBLE_CENTERED, HomeCard::Get()->GetState()); |
| 173 EXPECT_TRUE(WindowManager::GetInstance()->IsOverviewModeActive()); |
| 174 |
| 175 // Swipe down to the minimized state. |
| 176 generator.GestureScrollSequence(gfx::Point(x, 10), |
| 177 gfx::Point(x, bottom - 1), |
| 178 base::TimeDelta::FromSeconds(1), |
| 179 10); |
| 180 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); |
| 181 EXPECT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive()); |
| 182 |
| 183 } |
| 184 |
106 } // namespace athena | 185 } // namespace athena |
OLD | NEW |