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 06606b72c9057875f59118ac50e09ece4dead504..ffcbdf19d78f68c770e35d1aa802734dd892aebc 100644 |
--- a/ui/app_list/views/app_list_view_unittest.cc |
+++ b/ui/app_list/views/app_list_view_unittest.cc |
@@ -12,9 +12,13 @@ |
#include "ui/app_list/pagination_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" |
#include "ui/app_list/views/app_list_main_view.h" |
+#include "ui/app_list/views/apps_container_view.h" |
+#include "ui/app_list/views/apps_grid_view.h" |
#include "ui/app_list/views/contents_view.h" |
#include "ui/app_list/views/search_box_view.h" |
+#include "ui/app_list/views/test/apps_grid_view_test_api.h" |
#include "ui/aura/test/aura_test_base.h" |
#include "ui/aura/window.h" |
#include "ui/views/test/views_test_base.h" |
@@ -44,6 +48,10 @@ class AppListViewTestContext { |
// top level views. Then closes the window. |
void RunDisplayTest(); |
+ // Hides and reshows the app list with a folder open, expecting the main grid |
+ // view to be shown. |
+ void RunReshowWithOpenFolderTest(); |
+ |
// A standard set of checks on a view, e.g., ensuring it is drawn and visible. |
static void CheckView(views::View* subview); |
@@ -59,6 +67,12 @@ class AppListViewTestContext { |
bool is_landscape() const { return is_landscape_; } |
private: |
+ // Shows the app list and waits until a paint occurs. |
+ void Show(); |
+ |
+ // Closes the app list. This sets |view_| to NULL. |
+ void Close(); |
+ |
const bool is_landscape_; |
scoped_ptr<base::RunLoop> run_loop_; |
PaginationModel pagination_model_; |
@@ -117,17 +131,30 @@ void AppListViewTestContext::CheckView(views::View* subview) { |
EXPECT_TRUE(subview->IsDrawn()); |
} |
-void AppListViewTestContext::RunDisplayTest() { |
- EXPECT_FALSE(view_->GetWidget()->IsVisible()); |
- EXPECT_EQ(-1, pagination_model_.total_pages()); |
+void AppListViewTestContext::Show() { |
view_->GetWidget()->Show(); |
- delegate_->GetTestModel()->PopulateApps(kInitialItems); |
- |
run_loop_.reset(new base::RunLoop); |
AppListView::SetNextPaintCallback(run_loop_->QuitClosure()); |
run_loop_->Run(); |
EXPECT_TRUE(view_->GetWidget()->IsVisible()); |
+} |
+ |
+void AppListViewTestContext::Close() { |
+ view_->GetWidget()->Close(); |
+ run_loop_.reset(new base::RunLoop); |
+ run_loop_->Run(); |
+ |
+ // |view_| should have been deleted and set to NULL via ViewClosing(). |
+ EXPECT_FALSE(view_); |
+} |
+ |
+void AppListViewTestContext::RunDisplayTest() { |
+ EXPECT_FALSE(view_->GetWidget()->IsVisible()); |
+ EXPECT_EQ(-1, pagination_model_.total_pages()); |
+ delegate_->GetTestModel()->PopulateApps(kInitialItems); |
+ |
+ Show(); |
if (is_landscape_) |
EXPECT_EQ(2, pagination_model_.total_pages()); |
@@ -141,12 +168,48 @@ void AppListViewTestContext::RunDisplayTest() { |
EXPECT_NO_FATAL_FAILURE(CheckView(main_view->search_box_view())); |
EXPECT_NO_FATAL_FAILURE(CheckView(main_view->contents_view())); |
- view_->GetWidget()->Close(); |
- run_loop_.reset(new base::RunLoop); |
- run_loop_->Run(); |
+ Close(); |
+} |
- // |view_| should have been deleted and set to NULL via ViewClosing(). |
- EXPECT_FALSE(view_); |
+void AppListViewTestContext::RunReshowWithOpenFolderTest() { |
+ EXPECT_FALSE(view_->GetWidget()->IsVisible()); |
+ EXPECT_EQ(-1, pagination_model_.total_pages()); |
+ |
+ AppListTestModel* model = delegate_->GetTestModel(); |
+ model->PopulateApps(kInitialItems); |
+ const std::string folder_id = |
+ model->MergeItems(model->top_level_item_list()->item_at(0)->id(), |
+ model->top_level_item_list()->item_at(1)->id()); |
+ |
+ AppListFolderItem* folder_item = model->FindFolderItem(folder_id); |
+ EXPECT_TRUE(folder_item); |
+ |
+ Show(); |
+ |
+ // The main grid view should be showing initially. |
+ AppListMainView* main_view = view_->app_list_main_view(); |
+ AppsContainerView* container_view = |
+ main_view->contents_view()->apps_container_view(); |
+ EXPECT_NO_FATAL_FAILURE(CheckView(main_view)); |
+ EXPECT_NO_FATAL_FAILURE(CheckView(container_view->apps_grid_view())); |
+ |
tapted
2014/04/01 06:28:27
Can you
EXPECT_FALSE(container_view->app_list_fo
calamity
2014/04/01 08:08:46
Done.
|
+ AppsGridViewTestApi test_api(container_view->apps_grid_view()); |
+ test_api.PressItemAt(0); |
+ |
+ // After pressing the folder item, the folder view should be showing. |
+ EXPECT_NO_FATAL_FAILURE(CheckView(main_view)); |
+ EXPECT_NO_FATAL_FAILURE(CheckView(container_view->app_list_folder_view())); |
+ |
tapted
2014/04/01 06:28:27
and
EXPECT_FALSE(container_view->apps_grid_view()
calamity
2014/04/01 08:08:46
Done.
|
+ view_->GetWidget()->Hide(); |
+ EXPECT_FALSE(view_->GetWidget()->IsVisible()); |
+ |
+ Show(); |
+ |
+ // The main grid view should be showing after a reshow. |
+ EXPECT_NO_FATAL_FAILURE(CheckView(main_view)); |
+ EXPECT_NO_FATAL_FAILURE(CheckView(container_view->apps_grid_view())); |
tapted
2014/04/01 06:28:27
EXPECT_FALSE(container_view->app_list_folder_view(
calamity
2014/04/01 08:08:46
Done.
|
+ |
+ Close(); |
} |
class AppListViewTestAura : public views::ViewsTestBase { |
@@ -257,5 +320,18 @@ TEST_F(AppListViewTestDesktop, DisplayLandscape) { |
EXPECT_NO_FATAL_FAILURE(test_context_->RunDisplayTest()); |
} |
+// Tests that the main grid view is shown after hiding and reshowing the app |
+// list with a folder view open. This is a regression test for crbug.com/357058. |
+TEST_F(AppListViewTestAura, ReshowWithOpenFolder) { |
+ EXPECT_FALSE(test_context_->is_landscape()); |
+ host()->Show(); |
+ EXPECT_NO_FATAL_FAILURE(test_context_->RunReshowWithOpenFolderTest()); |
+} |
+ |
+TEST_F(AppListViewTestDesktop, ReshowWithOpenFolder) { |
+ EXPECT_FALSE(test_context_->is_landscape()); |
+ EXPECT_NO_FATAL_FAILURE(test_context_->RunReshowWithOpenFolderTest()); |
+} |
+ |
} // namespace test |
} // namespace app_list |