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