Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(558)

Unified Diff: ui/app_list/views/app_list_view_unittest.cc

Issue 335343002: Add a DummySearchBoxView to the experimental app list start page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/views/app_list_main_view.cc ('k') | ui/app_list/views/start_page_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/app_list_view_unittest.cc
diff --git a/ui/app_list/views/app_list_view_unittest.cc b/ui/app_list/views/app_list_view_unittest.cc
index 280331c0bb5f0d800c1f4097c81c08a36ab121b6..a01c10eeba34a73bb6d12eefca9d23132df570a9 100644
--- a/ui/app_list/views/app_list_view_unittest.cc
+++ b/ui/app_list/views/app_list_view_unittest.cc
@@ -7,9 +7,11 @@
#include "base/command_line.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/app_list/app_list_switches.h"
#include "ui/app_list/pagination_model.h"
+#include "ui/app_list/search_box_model.h"
#include "ui/app_list/test/app_list_test_model.h"
#include "ui/app_list/test/app_list_test_view_delegate.h"
#include "ui/app_list/views/app_list_folder_view.h"
@@ -25,6 +27,7 @@
#include "ui/app_list/views/tile_item_view.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/aura/window.h"
+#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/views_delegate.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
@@ -104,6 +107,10 @@ class AppListViewTestContext {
}
private:
+ // Switches the active launcher page in the contents view and lays out to
+ // ensure all launcher pages are in the correct position.
+ void ShowContentsViewPageAndVerify(int index);
+
// Shows the app list and waits until a paint occurs.
void Show();
@@ -187,6 +194,15 @@ void AppListViewTestContext::CheckView(views::View* subview) {
EXPECT_TRUE(subview->IsDrawn());
}
+void AppListViewTestContext::ShowContentsViewPageAndVerify(int index) {
+ ContentsView* contents_view = view_->app_list_main_view()->contents_view();
+ contents_view->SetActivePage(index);
+ contents_view->Layout();
+ for (int i = 0; i < contents_view->NumLauncherPages(); ++i) {
+ EXPECT_EQ(i == index, IsViewAtOrigin(contents_view->GetPageView(i)));
+ }
+}
+
void AppListViewTestContext::Show() {
view_->GetWidget()->Show();
run_loop_.reset(new base::RunLoop);
@@ -292,20 +308,14 @@ void AppListViewTestContext::RunStartPageTest() {
EXPECT_NO_FATAL_FAILURE(CheckView(start_page_view));
ContentsView* contents_view = main_view->contents_view();
- contents_view->SetActivePage(contents_view->GetPageIndexForNamedPage(
+ ShowContentsViewPageAndVerify(contents_view->GetPageIndexForNamedPage(
ContentsView::NAMED_PAGE_START));
- contents_view->Layout();
EXPECT_FALSE(main_view->search_box_view()->visible());
- EXPECT_TRUE(IsViewAtOrigin(start_page_view));
- EXPECT_FALSE(IsViewAtOrigin(contents_view->apps_container_view()));
EXPECT_EQ(3u, GetVisibleTileItemViews(start_page_view->tile_views()));
- contents_view->SetActivePage(
+ ShowContentsViewPageAndVerify(
contents_view->GetPageIndexForNamedPage(ContentsView::NAMED_PAGE_APPS));
- contents_view->Layout();
EXPECT_TRUE(main_view->search_box_view()->visible());
- EXPECT_FALSE(IsViewAtOrigin(start_page_view));
- EXPECT_TRUE(IsViewAtOrigin(contents_view->apps_container_view()));
// Check tiles hide and show on deletion and addition.
model->CreateAndAddItem("Test app");
@@ -422,7 +432,7 @@ void AppListViewTestContext::RunSearchResultsTest() {
AppListMainView* main_view = view_->app_list_main_view();
ContentsView* contents_view = main_view->contents_view();
- contents_view->SetActivePage(
+ ShowContentsViewPageAndVerify(
contents_view->GetPageIndexForNamedPage(ContentsView::NAMED_PAGE_APPS));
EXPECT_TRUE(IsViewAtOrigin(contents_view->apps_container_view()));
EXPECT_TRUE(main_view->search_box_view()->visible());
@@ -459,6 +469,50 @@ void AppListViewTestContext::RunSearchResultsTest() {
EXPECT_TRUE(main_view->search_box_view()->visible());
}
+ if (test_type_ == EXPERIMENTAL) {
+ // Check that typing into the dummy search box triggers the search page.
+ base::string16 search_text = base::UTF8ToUTF16("test");
+ SearchBoxView* dummy_search_box =
+ contents_view->start_page_view()->dummy_search_box_view();
+ EXPECT_TRUE(dummy_search_box->IsDrawn());
+ dummy_search_box->search_box()->InsertText(search_text);
+ contents_view->Layout();
+ // Check that the current search is using |search_text|.
+ EXPECT_EQ(search_text, delegate_->GetTestModel()->search_box()->text());
+ EXPECT_TRUE(contents_view->IsShowingSearchResults());
+ EXPECT_FALSE(dummy_search_box->IsDrawn());
+ EXPECT_TRUE(main_view->search_box_view()->visible());
+ EXPECT_EQ(search_text, main_view->search_box_view()->search_box()->text());
+ EXPECT_TRUE(
+ contents_view->IsNamedPageActive(ContentsView::NAMED_PAGE_START));
+ EXPECT_TRUE(IsViewAtOrigin(contents_view->start_page_view()));
+
+ // Check that typing into the real search box triggers the search page.
+ ShowContentsViewPageAndVerify(
+ contents_view->GetPageIndexForNamedPage(ContentsView::NAMED_PAGE_APPS));
+ EXPECT_TRUE(IsViewAtOrigin(contents_view->apps_container_view()));
+
+ base::string16 new_search_text = base::UTF8ToUTF16("apple");
+ main_view->search_box_view()->search_box()->SetText(base::string16());
+ main_view->search_box_view()->search_box()->InsertText(new_search_text);
+ // Check that the current search is using |search_text|.
+ EXPECT_EQ(new_search_text, delegate_->GetTestModel()->search_box()->text());
+ EXPECT_EQ(new_search_text,
+ main_view->search_box_view()->search_box()->text());
+ EXPECT_TRUE(contents_view->IsShowingSearchResults());
+ EXPECT_FALSE(dummy_search_box->IsDrawn());
+ EXPECT_TRUE(main_view->search_box_view()->visible());
+ EXPECT_TRUE(dummy_search_box->search_box()->text().empty());
+
+ // Check that the dummy search box is clear when reshowing the start page.
+ ShowContentsViewPageAndVerify(
+ contents_view->GetPageIndexForNamedPage(ContentsView::NAMED_PAGE_APPS));
+ ShowContentsViewPageAndVerify(contents_view->GetPageIndexForNamedPage(
+ ContentsView::NAMED_PAGE_START));
+ EXPECT_TRUE(dummy_search_box->IsDrawn());
+ EXPECT_TRUE(dummy_search_box->search_box()->text().empty());
+ }
+
Close();
}
« no previous file with comments | « ui/app_list/views/app_list_main_view.cc ('k') | ui/app_list/views/start_page_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698