| 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 "ui/app_list/views/app_list_view.h" | 5 #include "ui/app_list/views/app_list_view.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // top level views. Then closes the window. | 70 // top level views. Then closes the window. |
| 71 void RunDisplayTest(); | 71 void RunDisplayTest(); |
| 72 | 72 |
| 73 // Hides and reshows the app list with a folder open, expecting the main grid | 73 // Hides and reshows the app list with a folder open, expecting the main grid |
| 74 // view to be shown. | 74 // view to be shown. |
| 75 void RunReshowWithOpenFolderTest(); | 75 void RunReshowWithOpenFolderTest(); |
| 76 | 76 |
| 77 // Tests displaying of the experimental app list and shows the start page. | 77 // Tests displaying of the experimental app list and shows the start page. |
| 78 void RunStartPageTest(); | 78 void RunStartPageTest(); |
| 79 | 79 |
| 80 // Tests switching rapidly between multiple pages of the launcher. |
| 81 void RunPageSwitchingAnimationTest(); |
| 82 |
| 80 // Tests changing the App List profile. | 83 // Tests changing the App List profile. |
| 81 void RunProfileChangeTest(); | 84 void RunProfileChangeTest(); |
| 82 | 85 |
| 83 // Tests displaying of the search results. | 86 // Tests displaying of the search results. |
| 84 void RunSearchResultsTest(); | 87 void RunSearchResultsTest(); |
| 85 | 88 |
| 86 // A standard set of checks on a view, e.g., ensuring it is drawn and visible. | 89 // A standard set of checks on a view, e.g., ensuring it is drawn and visible. |
| 87 static void CheckView(views::View* subview); | 90 static void CheckView(views::View* subview); |
| 88 | 91 |
| 89 // Invoked when the Widget is closing, and the view it contains is about to | 92 // Invoked when the Widget is closing, and the view it contains is about to |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 EXPECT_EQ(4u, GetVisibleTileItemViews(start_page_view->tile_views())); | 311 EXPECT_EQ(4u, GetVisibleTileItemViews(start_page_view->tile_views())); |
| 309 model->DeleteItem(model->GetItemName(0)); | 312 model->DeleteItem(model->GetItemName(0)); |
| 310 EXPECT_EQ(3u, GetVisibleTileItemViews(start_page_view->tile_views())); | 313 EXPECT_EQ(3u, GetVisibleTileItemViews(start_page_view->tile_views())); |
| 311 } else { | 314 } else { |
| 312 EXPECT_EQ(NULL, start_page_view); | 315 EXPECT_EQ(NULL, start_page_view); |
| 313 } | 316 } |
| 314 | 317 |
| 315 Close(); | 318 Close(); |
| 316 } | 319 } |
| 317 | 320 |
| 321 void AppListViewTestContext::RunPageSwitchingAnimationTest() { |
| 322 if (test_type_ == EXPERIMENTAL) { |
| 323 Show(); |
| 324 |
| 325 AppListMainView* main_view = view_->app_list_main_view(); |
| 326 // Checks on the main view. |
| 327 EXPECT_NO_FATAL_FAILURE(CheckView(main_view)); |
| 328 EXPECT_NO_FATAL_FAILURE(CheckView(main_view->contents_view())); |
| 329 |
| 330 ContentsView* contents_view = main_view->contents_view(); |
| 331 // Pad the ContentsView with blank pages so we have at least 3 views. |
| 332 while (contents_view->NumLauncherPages() < 3) |
| 333 contents_view->AddBlankPageForTesting(); |
| 334 |
| 335 contents_view->SetActivePage(0); |
| 336 contents_view->Layout(); |
| 337 EXPECT_TRUE(IsViewAtOrigin(contents_view->GetPageView(0))); |
| 338 EXPECT_FALSE(IsViewAtOrigin(contents_view->GetPageView(1))); |
| 339 EXPECT_FALSE(IsViewAtOrigin(contents_view->GetPageView(2))); |
| 340 |
| 341 // Change pages. View should not have moved without Layout(). |
| 342 contents_view->SetActivePage(1); |
| 343 EXPECT_TRUE(IsViewAtOrigin(contents_view->GetPageView(0))); |
| 344 EXPECT_FALSE(IsViewAtOrigin(contents_view->GetPageView(1))); |
| 345 EXPECT_FALSE(IsViewAtOrigin(contents_view->GetPageView(2))); |
| 346 |
| 347 // Change to a third page. This queues up the second animation behind the |
| 348 // first. |
| 349 contents_view->SetActivePage(2); |
| 350 EXPECT_TRUE(IsViewAtOrigin(contents_view->GetPageView(0))); |
| 351 EXPECT_FALSE(IsViewAtOrigin(contents_view->GetPageView(1))); |
| 352 EXPECT_FALSE(IsViewAtOrigin(contents_view->GetPageView(2))); |
| 353 |
| 354 // Call Layout(). Should jump to the third page. |
| 355 contents_view->Layout(); |
| 356 EXPECT_FALSE(IsViewAtOrigin(contents_view->GetPageView(0))); |
| 357 EXPECT_FALSE(IsViewAtOrigin(contents_view->GetPageView(1))); |
| 358 EXPECT_TRUE(IsViewAtOrigin(contents_view->GetPageView(2))); |
| 359 } |
| 360 |
| 361 Close(); |
| 362 } |
| 363 |
| 318 void AppListViewTestContext::RunProfileChangeTest() { | 364 void AppListViewTestContext::RunProfileChangeTest() { |
| 319 EXPECT_FALSE(view_->GetWidget()->IsVisible()); | 365 EXPECT_FALSE(view_->GetWidget()->IsVisible()); |
| 320 EXPECT_EQ(-1, GetPaginationModel()->total_pages()); | 366 EXPECT_EQ(-1, GetPaginationModel()->total_pages()); |
| 321 delegate_->GetTestModel()->PopulateApps(kInitialItems); | 367 delegate_->GetTestModel()->PopulateApps(kInitialItems); |
| 322 | 368 |
| 323 Show(); | 369 Show(); |
| 324 | 370 |
| 325 if (is_landscape()) | 371 if (is_landscape()) |
| 326 EXPECT_EQ(2, GetPaginationModel()->total_pages()); | 372 EXPECT_EQ(2, GetPaginationModel()->total_pages()); |
| 327 else | 373 else |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 | 561 |
| 516 // Tests that the start page view operates correctly. | 562 // Tests that the start page view operates correctly. |
| 517 TEST_P(AppListViewTestAura, StartPageTest) { | 563 TEST_P(AppListViewTestAura, StartPageTest) { |
| 518 EXPECT_NO_FATAL_FAILURE(test_context_->RunStartPageTest()); | 564 EXPECT_NO_FATAL_FAILURE(test_context_->RunStartPageTest()); |
| 519 } | 565 } |
| 520 | 566 |
| 521 TEST_P(AppListViewTestDesktop, StartPageTest) { | 567 TEST_P(AppListViewTestDesktop, StartPageTest) { |
| 522 EXPECT_NO_FATAL_FAILURE(test_context_->RunStartPageTest()); | 568 EXPECT_NO_FATAL_FAILURE(test_context_->RunStartPageTest()); |
| 523 } | 569 } |
| 524 | 570 |
| 571 // Tests that the start page view operates correctly. |
| 572 TEST_P(AppListViewTestAura, PageSwitchingAnimationTest) { |
| 573 EXPECT_NO_FATAL_FAILURE(test_context_->RunPageSwitchingAnimationTest()); |
| 574 } |
| 575 |
| 576 TEST_P(AppListViewTestDesktop, PageSwitchingAnimationTest) { |
| 577 EXPECT_NO_FATAL_FAILURE(test_context_->RunPageSwitchingAnimationTest()); |
| 578 } |
| 579 |
| 525 // Tests that the profile changes operate correctly. | 580 // Tests that the profile changes operate correctly. |
| 526 TEST_P(AppListViewTestAura, ProfileChangeTest) { | 581 TEST_P(AppListViewTestAura, ProfileChangeTest) { |
| 527 EXPECT_NO_FATAL_FAILURE(test_context_->RunProfileChangeTest()); | 582 EXPECT_NO_FATAL_FAILURE(test_context_->RunProfileChangeTest()); |
| 528 } | 583 } |
| 529 | 584 |
| 530 TEST_P(AppListViewTestDesktop, ProfileChangeTest) { | 585 TEST_P(AppListViewTestDesktop, ProfileChangeTest) { |
| 531 EXPECT_NO_FATAL_FAILURE(test_context_->RunProfileChangeTest()); | 586 EXPECT_NO_FATAL_FAILURE(test_context_->RunProfileChangeTest()); |
| 532 } | 587 } |
| 533 | 588 |
| 534 // Tests that the correct views are displayed for showing search results. | 589 // Tests that the correct views are displayed for showing search results. |
| 535 TEST_P(AppListViewTestAura, SearchResultsTest) { | 590 TEST_P(AppListViewTestAura, SearchResultsTest) { |
| 536 EXPECT_NO_FATAL_FAILURE(test_context_->RunSearchResultsTest()); | 591 EXPECT_NO_FATAL_FAILURE(test_context_->RunSearchResultsTest()); |
| 537 } | 592 } |
| 538 | 593 |
| 539 TEST_P(AppListViewTestDesktop, SearchResultsTest) { | 594 TEST_P(AppListViewTestDesktop, SearchResultsTest) { |
| 540 EXPECT_NO_FATAL_FAILURE(test_context_->RunSearchResultsTest()); | 595 EXPECT_NO_FATAL_FAILURE(test_context_->RunSearchResultsTest()); |
| 541 } | 596 } |
| 542 | 597 |
| 543 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, | 598 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, |
| 544 AppListViewTestAura, | 599 AppListViewTestAura, |
| 545 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 600 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| 546 | 601 |
| 547 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, | 602 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, |
| 548 AppListViewTestDesktop, | 603 AppListViewTestDesktop, |
| 549 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 604 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| 550 | 605 |
| 551 } // namespace test | 606 } // namespace test |
| 552 } // namespace app_list | 607 } // namespace app_list |
| OLD | NEW |