| 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 void AppListViewTestContext::CheckView(views::View* subview) { | 224 void AppListViewTestContext::CheckView(views::View* subview) { |
| 225 ASSERT_TRUE(subview); | 225 ASSERT_TRUE(subview); |
| 226 EXPECT_TRUE(subview->parent()); | 226 EXPECT_TRUE(subview->parent()); |
| 227 EXPECT_TRUE(subview->visible()); | 227 EXPECT_TRUE(subview->visible()); |
| 228 EXPECT_TRUE(subview->IsDrawn()); | 228 EXPECT_TRUE(subview->IsDrawn()); |
| 229 EXPECT_FALSE(subview->bounds().IsEmpty()); | 229 EXPECT_FALSE(subview->bounds().IsEmpty()); |
| 230 } | 230 } |
| 231 | 231 |
| 232 bool AppListViewTestContext::SetAppListState(AppListModel::State state) { | 232 bool AppListViewTestContext::SetAppListState(AppListModel::State state) { |
| 233 ContentsView* contents_view = view_->app_list_main_view()->contents_view(); | 233 ContentsView* contents_view = view_->app_list_main_view()->contents_view(); |
| 234 int index = contents_view->GetPageIndexForState(state); | 234 contents_view->SetActivePage(state); |
| 235 contents_view->SetActivePage(index); | |
| 236 contents_view->Layout(); | 235 contents_view->Layout(); |
| 237 return IsStateShown(state); | 236 return IsStateShown(state); |
| 238 } | 237 } |
| 239 | 238 |
| 240 bool AppListViewTestContext::IsStateShown(AppListModel::State state) { | 239 bool AppListViewTestContext::IsStateShown(AppListModel::State state) { |
| 241 ContentsView* contents_view = view_->app_list_main_view()->contents_view(); | 240 ContentsView* contents_view = view_->app_list_main_view()->contents_view(); |
| 242 int index = contents_view->GetPageIndexForState(state); | 241 int index = contents_view->GetPageIndexForState(state); |
| 243 bool success = true; | 242 bool success = true; |
| 244 for (int i = 0; i < contents_view->NumLauncherPages(); ++i) { | 243 for (int i = 0; i < contents_view->NumLauncherPages(); ++i) { |
| 245 success = success && | 244 success = success && |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 void AppListViewTestContext::RunPageSwitchingAnimationTest() { | 498 void AppListViewTestContext::RunPageSwitchingAnimationTest() { |
| 500 if (test_type_ == EXPERIMENTAL) { | 499 if (test_type_ == EXPERIMENTAL) { |
| 501 Show(); | 500 Show(); |
| 502 | 501 |
| 503 AppListMainView* main_view = view_->app_list_main_view(); | 502 AppListMainView* main_view = view_->app_list_main_view(); |
| 504 // Checks on the main view. | 503 // Checks on the main view. |
| 505 EXPECT_NO_FATAL_FAILURE(CheckView(main_view)); | 504 EXPECT_NO_FATAL_FAILURE(CheckView(main_view)); |
| 506 EXPECT_NO_FATAL_FAILURE(CheckView(main_view->contents_view())); | 505 EXPECT_NO_FATAL_FAILURE(CheckView(main_view->contents_view())); |
| 507 | 506 |
| 508 ContentsView* contents_view = main_view->contents_view(); | 507 ContentsView* contents_view = main_view->contents_view(); |
| 509 // Pad the ContentsView with blank pages so we have at least 3 views. | |
| 510 while (contents_view->NumLauncherPages() < 3) | |
| 511 contents_view->AddBlankPageForTesting(); | |
| 512 | 508 |
| 513 contents_view->SetActivePage(0); | 509 int start_page_index = |
| 510 contents_view->GetPageIndexForState(AppListModel::STATE_START); |
| 511 int search_results_page_index = |
| 512 contents_view->GetPageIndexForState(AppListModel::STATE_SEARCH_RESULTS); |
| 513 int apps_page_index = |
| 514 contents_view->GetPageIndexForState(AppListModel::STATE_APPS); |
| 515 |
| 516 contents_view->SetActivePage(AppListModel::STATE_START); |
| 514 contents_view->Layout(); | 517 contents_view->Layout(); |
| 515 | 518 |
| 516 EXPECT_EQ(contents_view->GetOnscreenPageBounds(0), | 519 EXPECT_EQ(contents_view->GetOnscreenPageBounds(start_page_index), |
| 517 contents_view->GetPageView(0)->bounds()); | 520 contents_view->GetPageView(start_page_index)->bounds()); |
| 518 EXPECT_NE(contents_view->GetOnscreenPageBounds(1), | 521 EXPECT_NE(contents_view->GetOnscreenPageBounds(search_results_page_index), |
| 519 contents_view->GetPageView(1)->bounds()); | 522 contents_view->GetPageView(search_results_page_index)->bounds()); |
| 520 EXPECT_NE(contents_view->GetOnscreenPageBounds(2), | 523 EXPECT_NE(contents_view->GetOnscreenPageBounds(apps_page_index), |
| 521 contents_view->GetPageView(2)->bounds()); | 524 contents_view->GetPageView(apps_page_index)->bounds()); |
| 522 | 525 |
| 523 // Change pages. View should not have moved without Layout(). | 526 // Change pages. View should not have moved without Layout(). |
| 524 contents_view->SetActivePage(1); | 527 contents_view->SetActivePage(AppListModel::STATE_SEARCH_RESULTS); |
| 525 EXPECT_EQ(contents_view->GetOnscreenPageBounds(0), | 528 EXPECT_EQ(contents_view->GetOnscreenPageBounds(start_page_index), |
| 526 contents_view->GetPageView(0)->bounds()); | 529 contents_view->GetPageView(start_page_index)->bounds()); |
| 527 EXPECT_NE(contents_view->GetOnscreenPageBounds(1), | 530 EXPECT_NE(contents_view->GetOnscreenPageBounds(search_results_page_index), |
| 528 contents_view->GetPageView(1)->bounds()); | 531 contents_view->GetPageView(search_results_page_index)->bounds()); |
| 529 EXPECT_NE(contents_view->GetOnscreenPageBounds(2), | 532 EXPECT_NE(contents_view->GetOnscreenPageBounds(apps_page_index), |
| 530 contents_view->GetPageView(2)->bounds()); | 533 contents_view->GetPageView(apps_page_index)->bounds()); |
| 531 | 534 |
| 532 // Change to a third page. This queues up the second animation behind the | 535 // Change to a third page. This queues up the second animation behind the |
| 533 // first. | 536 // first. |
| 534 contents_view->SetActivePage(2); | 537 contents_view->SetActivePage(AppListModel::STATE_APPS); |
| 535 EXPECT_EQ(contents_view->GetOnscreenPageBounds(0), | 538 EXPECT_EQ(contents_view->GetOnscreenPageBounds(start_page_index), |
| 536 contents_view->GetPageView(0)->bounds()); | 539 contents_view->GetPageView(start_page_index)->bounds()); |
| 537 EXPECT_NE(contents_view->GetOnscreenPageBounds(1), | 540 EXPECT_NE(contents_view->GetOnscreenPageBounds(search_results_page_index), |
| 538 contents_view->GetPageView(1)->bounds()); | 541 contents_view->GetPageView(search_results_page_index)->bounds()); |
| 539 EXPECT_NE(contents_view->GetOnscreenPageBounds(2), | 542 EXPECT_NE(contents_view->GetOnscreenPageBounds(apps_page_index), |
| 540 contents_view->GetPageView(2)->bounds()); | 543 contents_view->GetPageView(apps_page_index)->bounds()); |
| 541 | 544 |
| 542 // Call Layout(). Should jump to the third page. | 545 // Call Layout(). Should jump to the third page. |
| 543 contents_view->Layout(); | 546 contents_view->Layout(); |
| 544 EXPECT_NE(contents_view->GetOnscreenPageBounds(0), | 547 EXPECT_NE(contents_view->GetOnscreenPageBounds(start_page_index), |
| 545 contents_view->GetPageView(0)->bounds()); | 548 contents_view->GetPageView(start_page_index)->bounds()); |
| 546 EXPECT_NE(contents_view->GetOnscreenPageBounds(1), | 549 EXPECT_NE(contents_view->GetOnscreenPageBounds(search_results_page_index), |
| 547 contents_view->GetPageView(1)->bounds()); | 550 contents_view->GetPageView(search_results_page_index)->bounds()); |
| 548 EXPECT_EQ(contents_view->GetOnscreenPageBounds(2), | 551 EXPECT_EQ(contents_view->GetOnscreenPageBounds(apps_page_index), |
| 549 contents_view->GetPageView(2)->bounds()); | 552 contents_view->GetPageView(apps_page_index)->bounds()); |
| 550 } | 553 } |
| 551 | 554 |
| 552 Close(); | 555 Close(); |
| 553 } | 556 } |
| 554 | 557 |
| 555 void AppListViewTestContext::RunProfileChangeTest() { | 558 void AppListViewTestContext::RunProfileChangeTest() { |
| 556 EXPECT_FALSE(view_->GetWidget()->IsVisible()); | 559 EXPECT_FALSE(view_->GetWidget()->IsVisible()); |
| 557 EXPECT_EQ(-1, GetPaginationModel()->total_pages()); | 560 EXPECT_EQ(-1, GetPaginationModel()->total_pages()); |
| 558 delegate_->GetTestModel()->PopulateApps(kInitialItems); | 561 delegate_->GetTestModel()->PopulateApps(kInitialItems); |
| 559 | 562 |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 AppListViewTestAura, | 833 AppListViewTestAura, |
| 831 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 834 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| 832 #endif | 835 #endif |
| 833 | 836 |
| 834 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, | 837 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, |
| 835 AppListViewTestDesktop, | 838 AppListViewTestDesktop, |
| 836 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 839 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| 837 | 840 |
| 838 } // namespace test | 841 } // namespace test |
| 839 } // namespace app_list | 842 } // namespace app_list |
| OLD | NEW |