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

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: add tests, extract convenience method in tests 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..adb4e4484f03235f359e3e3781805289d51eb738 100644
--- a/ui/app_list/views/app_list_view_unittest.cc
+++ b/ui/app_list/views/app_list_view_unittest.cc
@@ -7,6 +7,7 @@
#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"
@@ -25,6 +26,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 +106,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 ShowContentsViewPage(int index);
+
// Shows the app list and waits until a paint occurs.
void Show();
@@ -187,6 +193,15 @@ void AppListViewTestContext::CheckView(views::View* subview) {
EXPECT_TRUE(subview->IsDrawn());
}
+void AppListViewTestContext::ShowContentsViewPage(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 +307,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(
+ ShowContentsViewPage(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(
+ ShowContentsViewPage(
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 +431,7 @@ void AppListViewTestContext::RunSearchResultsTest() {
AppListMainView* main_view = view_->app_list_main_view();
ContentsView* contents_view = main_view->contents_view();
- contents_view->SetActivePage(
+ ShowContentsViewPage(
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 +468,40 @@ 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();
+ 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()));
+
tapted 2014/06/19 07:29:25 // Check that the current search is using |search_
calamity 2014/06/19 08:21:47 Done.
+ // Check that typing into the real search box triggers the search page.
+ ShowContentsViewPage(
+ contents_view->GetPageIndexForNamedPage(ContentsView::NAMED_PAGE_APPS));
+ EXPECT_TRUE(IsViewAtOrigin(contents_view->apps_container_view()));
+ main_view->search_box_view()->search_box()->InsertText(search_text);
tapted 2014/06/19 07:29:25 perhaps a different search text? Then you can veri
calamity 2014/06/19 08:21:47 Done.
+ EXPECT_TRUE(contents_view->IsShowingSearchResults());
+ EXPECT_FALSE(dummy_search_box->IsDrawn());
+ EXPECT_TRUE(main_view->search_box_view()->visible());
+
+ // Check that the dummy search box is cleared when reshowing the start page.
tapted 2014/06/19 07:29:25 Should the dummy search box be already cleared her
calamity 2014/06/19 08:21:47 Done.
+ ShowContentsViewPage(
+ contents_view->GetPageIndexForNamedPage(ContentsView::NAMED_PAGE_APPS));
tapted 2014/06/19 07:29:24 did you mean to do this as well as the next line?
calamity 2014/06/19 08:21:47 In this case I wanted to reset the start page by s
+ ShowContentsViewPage(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