| 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 "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 EXPECT_EQ(2, GetPaginationModel()->total_pages()); | 262 EXPECT_EQ(2, GetPaginationModel()->total_pages()); |
| 263 else | 263 else |
| 264 EXPECT_EQ(3, GetPaginationModel()->total_pages()); | 264 EXPECT_EQ(3, GetPaginationModel()->total_pages()); |
| 265 EXPECT_EQ(0, GetPaginationModel()->selected_page()); | 265 EXPECT_EQ(0, GetPaginationModel()->selected_page()); |
| 266 | 266 |
| 267 // Checks on the main view. | 267 // Checks on the main view. |
| 268 AppListMainView* main_view = view_->app_list_main_view(); | 268 AppListMainView* main_view = view_->app_list_main_view(); |
| 269 EXPECT_NO_FATAL_FAILURE(CheckView(main_view)); | 269 EXPECT_NO_FATAL_FAILURE(CheckView(main_view)); |
| 270 EXPECT_NO_FATAL_FAILURE(CheckView(main_view->contents_view())); | 270 EXPECT_NO_FATAL_FAILURE(CheckView(main_view->contents_view())); |
| 271 | 271 |
| 272 EXPECT_TRUE(main_view->contents_view()->IsNamedPageActive( | 272 EXPECT_TRUE(main_view->contents_view()->IsShowStateActive( |
| 273 test_type_ == EXPERIMENTAL ? ContentsView::NAMED_PAGE_START | 273 test_type_ == EXPERIMENTAL ? AppListModel::SHOW_START |
| 274 : ContentsView::NAMED_PAGE_APPS)); | 274 : AppListModel::SHOW_APPS)); |
| 275 | 275 |
| 276 Close(); | 276 Close(); |
| 277 } | 277 } |
| 278 | 278 |
| 279 void AppListViewTestContext::RunReshowWithOpenFolderTest() { | 279 void AppListViewTestContext::RunReshowWithOpenFolderTest() { |
| 280 EXPECT_FALSE(view_->GetWidget()->IsVisible()); | 280 EXPECT_FALSE(view_->GetWidget()->IsVisible()); |
| 281 EXPECT_EQ(-1, GetPaginationModel()->total_pages()); | 281 EXPECT_EQ(-1, GetPaginationModel()->total_pages()); |
| 282 | 282 |
| 283 AppListTestModel* model = delegate_->GetTestModel(); | 283 AppListTestModel* model = delegate_->GetTestModel(); |
| 284 model->PopulateApps(kInitialItems); | 284 model->PopulateApps(kInitialItems); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 StartPageView* start_page_view = | 332 StartPageView* start_page_view = |
| 333 main_view->contents_view()->start_page_view(); | 333 main_view->contents_view()->start_page_view(); |
| 334 // Checks on the main view. | 334 // Checks on the main view. |
| 335 EXPECT_NO_FATAL_FAILURE(CheckView(main_view)); | 335 EXPECT_NO_FATAL_FAILURE(CheckView(main_view)); |
| 336 EXPECT_NO_FATAL_FAILURE(CheckView(main_view->contents_view())); | 336 EXPECT_NO_FATAL_FAILURE(CheckView(main_view->contents_view())); |
| 337 if (test_type_ == EXPERIMENTAL) { | 337 if (test_type_ == EXPERIMENTAL) { |
| 338 EXPECT_NO_FATAL_FAILURE(CheckView(start_page_view)); | 338 EXPECT_NO_FATAL_FAILURE(CheckView(start_page_view)); |
| 339 | 339 |
| 340 // Show the start page view. | 340 // Show the start page view. |
| 341 ContentsView* contents_view = main_view->contents_view(); | 341 ContentsView* contents_view = main_view->contents_view(); |
| 342 ShowContentsViewPageAndVerify(contents_view->GetPageIndexForNamedPage( | 342 ShowContentsViewPageAndVerify( |
| 343 ContentsView::NAMED_PAGE_START)); | 343 contents_view->GetPageIndexForShowState(AppListModel::SHOW_START)); |
| 344 EXPECT_FALSE(main_view->search_box_view()->visible()); | 344 EXPECT_FALSE(main_view->search_box_view()->visible()); |
| 345 | 345 |
| 346 gfx::Size view_size(view_->GetPreferredSize()); | 346 gfx::Size view_size(view_->GetPreferredSize()); |
| 347 ShowContentsViewPageAndVerify( | 347 ShowContentsViewPageAndVerify( |
| 348 contents_view->GetPageIndexForNamedPage(ContentsView::NAMED_PAGE_APPS)); | 348 contents_view->GetPageIndexForShowState(AppListModel::SHOW_APPS)); |
| 349 EXPECT_TRUE(main_view->search_box_view()->visible()); | 349 EXPECT_TRUE(main_view->search_box_view()->visible()); |
| 350 | 350 |
| 351 // Hiding and showing the search box should not affect the app list's | 351 // Hiding and showing the search box should not affect the app list's |
| 352 // preferred size. This is a regression test for http://crbug.com/386912. | 352 // preferred size. This is a regression test for http://crbug.com/386912. |
| 353 EXPECT_EQ(view_size.ToString(), view_->GetPreferredSize().ToString()); | 353 EXPECT_EQ(view_size.ToString(), view_->GetPreferredSize().ToString()); |
| 354 | 354 |
| 355 // Check tiles hide and show on deletion and addition. | 355 // Check tiles hide and show on deletion and addition. |
| 356 model->results()->Add(new TestTileSearchResult()); | 356 model->results()->Add(new TestTileSearchResult()); |
| 357 start_page_view->UpdateForTesting(); | 357 start_page_view->UpdateForTesting(); |
| 358 EXPECT_EQ(1u, GetVisibleTileItemViews(start_page_view->tile_views())); | 358 EXPECT_EQ(1u, GetVisibleTileItemViews(start_page_view->tile_views())); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 EXPECT_FALSE(view_->GetWidget()->IsVisible()); | 470 EXPECT_FALSE(view_->GetWidget()->IsVisible()); |
| 471 EXPECT_EQ(-1, GetPaginationModel()->total_pages()); | 471 EXPECT_EQ(-1, GetPaginationModel()->total_pages()); |
| 472 AppListTestModel* model = delegate_->GetTestModel(); | 472 AppListTestModel* model = delegate_->GetTestModel(); |
| 473 model->PopulateApps(3); | 473 model->PopulateApps(3); |
| 474 | 474 |
| 475 Show(); | 475 Show(); |
| 476 | 476 |
| 477 AppListMainView* main_view = view_->app_list_main_view(); | 477 AppListMainView* main_view = view_->app_list_main_view(); |
| 478 ContentsView* contents_view = main_view->contents_view(); | 478 ContentsView* contents_view = main_view->contents_view(); |
| 479 ShowContentsViewPageAndVerify( | 479 ShowContentsViewPageAndVerify( |
| 480 contents_view->GetPageIndexForNamedPage(ContentsView::NAMED_PAGE_APPS)); | 480 contents_view->GetPageIndexForShowState(AppListModel::SHOW_APPS)); |
| 481 EXPECT_TRUE(main_view->search_box_view()->visible()); | 481 EXPECT_TRUE(main_view->search_box_view()->visible()); |
| 482 | 482 |
| 483 // Show the search results. | 483 // Show the search results. |
| 484 contents_view->ShowSearchResults(true); | 484 contents_view->ShowSearchResults(true); |
| 485 contents_view->Layout(); | 485 contents_view->Layout(); |
| 486 EXPECT_TRUE(contents_view->IsShowingSearchResults()); | 486 EXPECT_TRUE(contents_view->IsShowingSearchResults()); |
| 487 EXPECT_TRUE(main_view->search_box_view()->visible()); | 487 EXPECT_TRUE(main_view->search_box_view()->visible()); |
| 488 | 488 |
| 489 const gfx::Rect active_contents_bounds = | 489 const gfx::Rect active_contents_bounds = |
| 490 contents_view->GetDefaultContentsBounds(); | 490 contents_view->GetDefaultContentsBounds(); |
| 491 if (test_type_ == EXPERIMENTAL) { | 491 if (test_type_ == EXPERIMENTAL) { |
| 492 EXPECT_TRUE( | 492 EXPECT_TRUE(contents_view->IsShowStateActive(AppListModel::SHOW_START)); |
| 493 contents_view->IsNamedPageActive(ContentsView::NAMED_PAGE_START)); | |
| 494 EXPECT_EQ(active_contents_bounds, | 493 EXPECT_EQ(active_contents_bounds, |
| 495 contents_view->start_page_view()->bounds()); | 494 contents_view->start_page_view()->bounds()); |
| 496 } else { | 495 } else { |
| 497 EXPECT_TRUE(contents_view->IsNamedPageActive( | 496 EXPECT_TRUE( |
| 498 ContentsView::NAMED_PAGE_SEARCH_RESULTS)); | 497 contents_view->IsShowStateActive(AppListModel::SHOW_SEARCH_RESULTS)); |
| 499 EXPECT_EQ(active_contents_bounds, | 498 EXPECT_EQ(active_contents_bounds, |
| 500 contents_view->search_results_view()->bounds()); | 499 contents_view->search_results_view()->bounds()); |
| 501 } | 500 } |
| 502 | 501 |
| 503 // Hide the search results. | 502 // Hide the search results. |
| 504 contents_view->ShowSearchResults(false); | 503 contents_view->ShowSearchResults(false); |
| 505 contents_view->Layout(); | 504 contents_view->Layout(); |
| 506 EXPECT_FALSE(contents_view->IsShowingSearchResults()); | 505 EXPECT_FALSE(contents_view->IsShowingSearchResults()); |
| 507 | 506 |
| 508 // Check that we return to the page that we were on before the search. | 507 // Check that we return to the page that we were on before the search. |
| 509 EXPECT_TRUE(contents_view->IsNamedPageActive(ContentsView::NAMED_PAGE_APPS)); | 508 EXPECT_TRUE(contents_view->IsShowStateActive(AppListModel::SHOW_APPS)); |
| 510 EXPECT_EQ(active_contents_bounds, | 509 EXPECT_EQ(active_contents_bounds, |
| 511 contents_view->apps_container_view()->bounds()); | 510 contents_view->apps_container_view()->bounds()); |
| 512 EXPECT_TRUE(main_view->search_box_view()->visible()); | 511 EXPECT_TRUE(main_view->search_box_view()->visible()); |
| 513 | 512 |
| 514 if (test_type_ == EXPERIMENTAL) { | 513 if (test_type_ == EXPERIMENTAL) { |
| 515 ShowContentsViewPageAndVerify(contents_view->GetPageIndexForNamedPage( | 514 ShowContentsViewPageAndVerify( |
| 516 ContentsView::NAMED_PAGE_START)); | 515 contents_view->GetPageIndexForShowState(AppListModel::SHOW_START)); |
| 517 | 516 |
| 518 // Check that typing into the dummy search box triggers the search page. | 517 // Check that typing into the dummy search box triggers the search page. |
| 519 base::string16 search_text = base::UTF8ToUTF16("test"); | 518 base::string16 search_text = base::UTF8ToUTF16("test"); |
| 520 SearchBoxView* dummy_search_box = | 519 SearchBoxView* dummy_search_box = |
| 521 contents_view->start_page_view()->dummy_search_box_view(); | 520 contents_view->start_page_view()->dummy_search_box_view(); |
| 522 EXPECT_TRUE(dummy_search_box->IsDrawn()); | 521 EXPECT_TRUE(dummy_search_box->IsDrawn()); |
| 523 dummy_search_box->search_box()->InsertText(search_text); | 522 dummy_search_box->search_box()->InsertText(search_text); |
| 524 contents_view->Layout(); | 523 contents_view->Layout(); |
| 525 // Check that the current search is using |search_text|. | 524 // Check that the current search is using |search_text|. |
| 526 EXPECT_EQ(search_text, delegate_->GetTestModel()->search_box()->text()); | 525 EXPECT_EQ(search_text, delegate_->GetTestModel()->search_box()->text()); |
| 527 EXPECT_TRUE(contents_view->IsShowingSearchResults()); | 526 EXPECT_TRUE(contents_view->IsShowingSearchResults()); |
| 528 EXPECT_FALSE(dummy_search_box->IsDrawn()); | 527 EXPECT_FALSE(dummy_search_box->IsDrawn()); |
| 529 EXPECT_TRUE(main_view->search_box_view()->visible()); | 528 EXPECT_TRUE(main_view->search_box_view()->visible()); |
| 530 EXPECT_EQ(search_text, main_view->search_box_view()->search_box()->text()); | 529 EXPECT_EQ(search_text, main_view->search_box_view()->search_box()->text()); |
| 531 EXPECT_TRUE( | 530 EXPECT_TRUE(contents_view->IsShowStateActive(AppListModel::SHOW_START)); |
| 532 contents_view->IsNamedPageActive(ContentsView::NAMED_PAGE_START)); | |
| 533 EXPECT_EQ(active_contents_bounds, | 531 EXPECT_EQ(active_contents_bounds, |
| 534 contents_view->start_page_view()->bounds()); | 532 contents_view->start_page_view()->bounds()); |
| 535 | 533 |
| 536 // Check that typing into the real search box triggers the search page. | 534 // Check that typing into the real search box triggers the search page. |
| 537 ShowContentsViewPageAndVerify( | 535 ShowContentsViewPageAndVerify( |
| 538 contents_view->GetPageIndexForNamedPage(ContentsView::NAMED_PAGE_APPS)); | 536 contents_view->GetPageIndexForShowState(AppListModel::SHOW_APPS)); |
| 539 EXPECT_EQ(active_contents_bounds, | 537 EXPECT_EQ(active_contents_bounds, |
| 540 contents_view->apps_container_view()->bounds()); | 538 contents_view->apps_container_view()->bounds()); |
| 541 | 539 |
| 542 base::string16 new_search_text = base::UTF8ToUTF16("apple"); | 540 base::string16 new_search_text = base::UTF8ToUTF16("apple"); |
| 543 main_view->search_box_view()->search_box()->SetText(base::string16()); | 541 main_view->search_box_view()->search_box()->SetText(base::string16()); |
| 544 main_view->search_box_view()->search_box()->InsertText(new_search_text); | 542 main_view->search_box_view()->search_box()->InsertText(new_search_text); |
| 545 // Check that the current search is using |search_text|. | 543 // Check that the current search is using |search_text|. |
| 546 EXPECT_EQ(new_search_text, delegate_->GetTestModel()->search_box()->text()); | 544 EXPECT_EQ(new_search_text, delegate_->GetTestModel()->search_box()->text()); |
| 547 EXPECT_EQ(new_search_text, | 545 EXPECT_EQ(new_search_text, |
| 548 main_view->search_box_view()->search_box()->text()); | 546 main_view->search_box_view()->search_box()->text()); |
| 549 EXPECT_TRUE(contents_view->IsShowingSearchResults()); | 547 EXPECT_TRUE(contents_view->IsShowingSearchResults()); |
| 550 EXPECT_FALSE(dummy_search_box->IsDrawn()); | 548 EXPECT_FALSE(dummy_search_box->IsDrawn()); |
| 551 EXPECT_TRUE(main_view->search_box_view()->visible()); | 549 EXPECT_TRUE(main_view->search_box_view()->visible()); |
| 552 EXPECT_TRUE(dummy_search_box->search_box()->text().empty()); | 550 EXPECT_TRUE(dummy_search_box->search_box()->text().empty()); |
| 553 | 551 |
| 554 // Check that the dummy search box is clear when reshowing the start page. | 552 // Check that the dummy search box is clear when reshowing the start page. |
| 555 ShowContentsViewPageAndVerify( | 553 ShowContentsViewPageAndVerify( |
| 556 contents_view->GetPageIndexForNamedPage(ContentsView::NAMED_PAGE_APPS)); | 554 contents_view->GetPageIndexForShowState(AppListModel::SHOW_APPS)); |
| 557 ShowContentsViewPageAndVerify(contents_view->GetPageIndexForNamedPage( | 555 ShowContentsViewPageAndVerify( |
| 558 ContentsView::NAMED_PAGE_START)); | 556 contents_view->GetPageIndexForShowState(AppListModel::SHOW_START)); |
| 559 EXPECT_TRUE(dummy_search_box->IsDrawn()); | 557 EXPECT_TRUE(dummy_search_box->IsDrawn()); |
| 560 EXPECT_TRUE(dummy_search_box->search_box()->text().empty()); | 558 EXPECT_TRUE(dummy_search_box->search_box()->text().empty()); |
| 561 } | 559 } |
| 562 | 560 |
| 563 Close(); | 561 Close(); |
| 564 } | 562 } |
| 565 | 563 |
| 566 class AppListViewTestAura : public views::ViewsTestBase, | 564 class AppListViewTestAura : public views::ViewsTestBase, |
| 567 public ::testing::WithParamInterface<int> { | 565 public ::testing::WithParamInterface<int> { |
| 568 public: | 566 public: |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, | 714 INSTANTIATE_TEST_CASE_P(AppListViewTestAuraInstance, |
| 717 AppListViewTestAura, | 715 AppListViewTestAura, |
| 718 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 716 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| 719 | 717 |
| 720 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, | 718 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, |
| 721 AppListViewTestDesktop, | 719 AppListViewTestDesktop, |
| 722 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 720 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| 723 | 721 |
| 724 } // namespace test | 722 } // namespace test |
| 725 } // namespace app_list | 723 } // namespace app_list |
| OLD | NEW |