Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/public/cpp/config.h" | 8 #include "ash/public/cpp/config.h" |
| 9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/test/test_app_list_view_presenter_impl.h" | 12 #include "ash/test/test_app_list_view_presenter_impl.h" |
| 13 #include "ash/wm/window_util.h" | 13 #include "ash/wm/window_util.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/test/scoped_feature_list.h" | 16 #include "base/test/scoped_feature_list.h" |
| 17 #include "ui/app_list/app_list_features.h" | 17 #include "ui/app_list/app_list_features.h" |
| 18 #include "ui/app_list/app_list_switches.h" | 18 #include "ui/app_list/app_list_switches.h" |
| 19 #include "ui/app_list/views/app_list_main_view.h" | 19 #include "ui/app_list/views/app_list_main_view.h" |
| 20 #include "ui/app_list/views/app_list_view.h" | 20 #include "ui/app_list/views/app_list_view.h" |
| 21 #include "ui/app_list/views/search_box_view.h" | |
| 21 #include "ui/aura/test/test_windows.h" | 22 #include "ui/aura/test/test_windows.h" |
| 22 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| 23 #include "ui/display/display.h" | 24 #include "ui/display/display.h" |
| 24 #include "ui/display/screen.h" | 25 #include "ui/display/screen.h" |
| 25 #include "ui/events/test/event_generator.h" | 26 #include "ui/events/test/event_generator.h" |
| 27 #include "ui/views/controls/textfield/textfield.h" | |
| 26 | 28 |
| 27 namespace ash { | 29 namespace ash { |
| 28 namespace { | 30 namespace { |
| 29 | 31 |
| 30 int64_t GetPrimaryDisplayId() { | 32 int64_t GetPrimaryDisplayId() { |
| 31 return display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 33 return display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 32 } | 34 } |
| 33 | 35 |
| 34 } // namespace | 36 } // namespace |
| 35 | 37 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 | 225 |
| 224 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | 226 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 225 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); | 227 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); |
| 226 | 228 |
| 227 // Clicking outside the bounds closes the app list. | 229 // Clicking outside the bounds closes the app list. |
| 228 generator.MoveMouseTo(tap_point); | 230 generator.MoveMouseTo(tap_point); |
| 229 generator.ClickLeftButton(); | 231 generator.ClickLeftButton(); |
| 230 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); | 232 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); |
| 231 } | 233 } |
| 232 | 234 |
| 235 // Tests that a keypress activates the searchbox and that clearing the searchbox | |
| 236 // deactivates the searchbox. | |
| 237 TEST_F(AppListPresenterDelegateTest, KeyPressEnablesSearchBox) { | |
| 238 EnableFullscreenAppList(); | |
| 239 | |
| 240 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 241 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 242 app_list::SearchBoxView* search_box_view = | |
| 243 app_list_presenter_impl()->GetView()->search_box_view(); | |
| 244 EXPECT_FALSE(search_box_view->is_search_box_active()); | |
| 245 | |
| 246 // Press any key, the search box should be active. | |
| 247 generator.PressKey(ui::VKEY_0, 0); | |
| 248 EXPECT_TRUE(search_box_view->is_search_box_active()); | |
| 249 | |
| 250 // Delete the text, the search box should be inactive. | |
| 251 search_box_view->ClearSearch(); | |
| 252 EXPECT_FALSE(search_box_view->is_search_box_active()); | |
| 253 } | |
| 254 | |
| 255 // Tests that the searchbox activates when it is clicked and that the searchbox | |
| 256 // is inactive after clicking the app list body. | |
| 257 TEST_F(AppListPresenterDelegateTest, ClickEnablesSearchBox) { | |
| 258 EnableFullscreenAppList(); | |
| 259 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 260 app_list::SearchBoxView* search_box_view = | |
| 261 app_list_presenter_impl()->GetView()->search_box_view(); | |
| 262 | |
| 263 // Click the searchbox, the search box should be active. | |
| 264 gfx::Point search_box_point = | |
| 265 search_box_view->search_box()->GetBoundsInScreen().CenterPoint(); | |
| 266 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 267 generator.MoveMouseTo(search_box_point); | |
| 268 generator.PressLeftButton(); | |
| 269 generator.ReleaseLeftButton(); | |
| 270 EXPECT_TRUE(search_box_view->is_search_box_active()); | |
| 271 EXPECT_TRUE(app_list_presenter_impl()->GetView()->app_list_state() == | |
| 272 app_list::AppListView::AppListState::PEEKING); | |
| 273 | |
| 274 // Click outside the search box, the searchbox should be disabled. | |
| 275 search_box_point.set_x(20); | |
| 276 generator.MoveMouseTo(search_box_point); | |
| 277 generator.PressLeftButton(); | |
| 278 generator.ReleaseLeftButton(); | |
| 279 EXPECT_FALSE(search_box_view->is_search_box_active()); | |
| 280 } | |
| 281 | |
| 282 // Tests that a tap/click on the AppListView from half launcher returns the | |
| 283 // AppListView to Peeking, and that a tap/click on the AppListView from Peeking | |
| 284 // closes the app list. | |
| 285 TEST_P(AppListPresenterDelegateTest, | |
| 286 StateTransitionsByTapAndClickingAppListBodyFromHalf) { | |
| 287 if (!GetParam()) | |
| 288 EnableFullscreenAppList(); | |
|
oshima
2017/07/05 19:11:59
If you enable it anyway, why this has to be parame
newcomer
2017/07/05 22:03:57
I couldn't find a way to create multiple parameter
oshima
2017/07/06 16:04:12
You should create a separate base class, which alw
| |
| 289 | |
| 290 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 291 app_list::AppListView* app_list_view = app_list_presenter_impl()->GetView(); | |
| 292 app_list::SearchBoxView* search_box_view = app_list_view->search_box_view(); | |
| 293 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 294 EXPECT_TRUE(app_list_view->app_list_state() == | |
| 295 app_list::AppListView::AppListState::PEEKING); | |
| 296 | |
| 297 // Press a key, the AppListView should transition to half. | |
| 298 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 299 EXPECT_TRUE(app_list_view->app_list_state() == | |
| 300 app_list::AppListView::AppListState::HALF); | |
| 301 EXPECT_TRUE(search_box_view->is_search_box_active()); | |
| 302 | |
| 303 // Tap outside the search box, the AppListView should transition to Peeking | |
| 304 // and the search box should be inactive. | |
| 305 gfx::Point outside_search_box = | |
| 306 search_box_view->search_box()->GetBoundsInScreen().CenterPoint(); | |
| 307 outside_search_box.set_x(20); | |
| 308 if (GetParam()) { | |
| 309 generator.MoveMouseTo(outside_search_box); | |
| 310 generator.ClickLeftButton(); | |
| 311 } else { | |
| 312 generator.GestureTapDownAndUp(outside_search_box); | |
| 313 } | |
| 314 EXPECT_TRUE(app_list_view->app_list_state() == | |
| 315 app_list::AppListView::AppListState::PEEKING); | |
| 316 EXPECT_FALSE(search_box_view->is_search_box_active()); | |
| 317 | |
| 318 // Tap outside the search box again, the AppListView should hide. | |
| 319 outside_search_box = | |
| 320 search_box_view->search_box()->GetBoundsInScreen().CenterPoint(); | |
| 321 outside_search_box.set_x(20); | |
| 322 if (GetParam()) { | |
| 323 generator.MoveMouseTo(outside_search_box); | |
| 324 generator.ClickLeftButton(); | |
| 325 } else { | |
| 326 generator.GestureTapDownAndUp(outside_search_box); | |
| 327 } | |
| 328 EXPECT_TRUE(app_list_view->app_list_state() == | |
| 329 app_list::AppListView::AppListState::CLOSED); | |
| 330 } | |
| 331 | |
| 332 // Tests that a tap/click on the AppListView from Fullscreen search returns the | |
| 333 // AppListView to fullscreen all apps, and that a tap/click on the AppListView | |
| 334 // from fullscreen all apps closes the app list. | |
| 335 TEST_P(AppListPresenterDelegateTest, | |
| 336 StateTransitionsByTappingAppListBodyFromFullscreen) { | |
| 337 if (!GetParam()) | |
| 338 EnableFullscreenAppList(); | |
| 339 | |
| 340 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 341 app_list::AppListView* app_list_view = app_list_presenter_impl()->GetView(); | |
| 342 app_list::SearchBoxView* search_box_view = app_list_view->search_box_view(); | |
| 343 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 344 | |
| 345 // Execute a long upwards drag, this should transition the app list to | |
| 346 // fullscreen. | |
| 347 int top_of_app_list = | |
| 348 app_list_view->GetWidget()->GetWindowBoundsInScreen().y(); | |
| 349 generator.GestureScrollSequence(gfx::Point(10, top_of_app_list + 20), | |
| 350 gfx::Point(10, 10), | |
| 351 base::TimeDelta::FromMilliseconds(100), 10); | |
| 352 EXPECT_EQ(app_list_view->app_list_state(), | |
| 353 app_list::AppListView::FULLSCREEN_ALL_APPS); | |
| 354 | |
| 355 // Press a key, this should activate the searchbox and transition to | |
| 356 // fullscreen search. | |
| 357 generator.PressKey(ui::KeyboardCode::VKEY_0, 0); | |
| 358 EXPECT_TRUE(app_list_view->app_list_state() == | |
| 359 app_list::AppListView::AppListState::FULLSCREEN_SEARCH); | |
| 360 EXPECT_TRUE(search_box_view->is_search_box_active()); | |
| 361 | |
| 362 // Tap outside the searchbox, this should deactivate the searchbox and the | |
| 363 // applistview should return to fullscreen all apps. | |
| 364 gfx::Point outside_search_box = | |
| 365 search_box_view->search_box()->GetBoundsInScreen().CenterPoint(); | |
| 366 outside_search_box.set_x(20); | |
| 367 if (GetParam()) { | |
| 368 generator.MoveMouseTo(outside_search_box); | |
| 369 generator.ClickLeftButton(); | |
| 370 } else { | |
| 371 generator.GestureTapDownAndUp(outside_search_box); | |
| 372 } | |
| 373 EXPECT_TRUE(app_list_view->app_list_state() == | |
| 374 app_list::AppListView::AppListState::FULLSCREEN_ALL_APPS); | |
| 375 EXPECT_FALSE(search_box_view->is_search_box_active()); | |
| 376 | |
| 377 // Tap outside the searchbox again, this should close the applistview. | |
| 378 if (GetParam()) { | |
| 379 generator.MoveMouseTo(outside_search_box); | |
| 380 generator.ClickLeftButton(); | |
| 381 } else { | |
| 382 generator.GestureTapDownAndUp(outside_search_box); | |
| 383 } | |
| 384 EXPECT_TRUE(app_list_view->app_list_state() == | |
| 385 app_list::AppListView::AppListState::CLOSED); | |
| 386 } | |
| 387 | |
| 388 // Tests that the searchbox activates when it is tapped and that the widget is | |
| 389 // closed after tapping outside the searchbox. | |
| 390 TEST_F(AppListPresenterDelegateTest, TapEnablesSearchBox) { | |
| 391 EnableFullscreenAppList(); | |
| 392 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | |
| 393 app_list::SearchBoxView* search_box_view = | |
| 394 app_list_presenter_impl()->GetView()->search_box_view(); | |
| 395 | |
| 396 // Tap the search box, it should activate. | |
| 397 gfx::Point search_box_point = | |
| 398 search_box_view->search_box()->GetBoundsInScreen().CenterPoint(); | |
| 399 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 400 generator.GestureTapAt(search_box_point); | |
| 401 EXPECT_TRUE(search_box_view->is_search_box_active()); | |
| 402 | |
| 403 // Tap on the body of the app list, the search box should deactivate. | |
| 404 search_box_point.set_x(20); | |
| 405 generator.GestureTapAt(search_box_point); | |
| 406 EXPECT_FALSE(search_box_view->is_search_box_active()); | |
| 407 EXPECT_TRUE(app_list_presenter_impl()->IsVisible()); | |
| 408 | |
| 409 // Tap on the body of the app list again, the app list should hide. | |
| 410 generator.GestureTapAt(search_box_point); | |
| 411 EXPECT_EQ(app_list_presenter_impl()->GetView()->app_list_state(), | |
| 412 app_list::AppListView::AppListState::CLOSED); | |
| 413 } | |
| 414 | |
| 233 } // namespace ash | 415 } // namespace ash |
| OLD | NEW |