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