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

Unified Diff: chrome/browser/ui/app_list/app_list_service_views_browsertest.cc

Issue 276833002: Make the App Info Dialog appear modal (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed unnecessary mac fixes Created 6 years, 7 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
Index: chrome/browser/ui/app_list/app_list_service_views_browsertest.cc
diff --git a/chrome/browser/ui/app_list/app_list_service_views_browsertest.cc b/chrome/browser/ui/app_list/app_list_service_views_browsertest.cc
index 7bee1a8988873b191c3bf76423b50814fa465f7d..8db01dbcce1ff548d0ebb44a2dd61d429da416ed 100644
--- a/chrome/browser/ui/app_list/app_list_service_views_browsertest.cc
+++ b/chrome/browser/ui/app_list/app_list_service_views_browsertest.cc
@@ -4,12 +4,56 @@
#include "chrome/browser/ui/app_list/app_list_service_views.h"
+#include "base/path_service.h"
#include "base/run_loop.h"
+#include "chrome/browser/extensions/extension_browsertest.h"
+#include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
#include "chrome/browser/ui/app_list/test/chrome_app_list_test_support.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/in_process_browser_test.h"
+#include "ui/app_list/app_list_switches.h"
+#include "ui/app_list/views/app_list_view.h"
#include "ui/views/widget/widget.h"
+#if defined(OS_CHROMEOS)
+#include "ash/shell.h"
+#include "ash/test/app_list_controller_test_api.h"
+#endif
+
+namespace {
+
+app_list::AppListView* GetAppListView(AppListService* service) {
+#if defined(OS_CHROMEOS)
+ return ash::test::AppListControllerTestApi(ash::Shell::GetInstance()).view();
+#else
+ return static_cast<AppListServiceViews*>(service)->shower().app_list();
+#endif
+}
+
+} // namespace
+
+namespace test {
+
+// Allow access to private variables of the AppListView for testing.
+class AppListViewTestApi {
+ public:
+ explicit AppListViewTestApi(app_list::AppListView* view) : view_(view) {}
+ virtual ~AppListViewTestApi() {}
+
+ bool is_overlay_visible() {
+ DCHECK(view_->overlay_view_);
+ return view_->overlay_view_->visible();
+ }
+
+ private:
+ app_list::AppListView* view_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppListViewTestApi);
+};
+
+} // namespace test
+
// Browser Test for AppListService on Views platforms.
typedef InProcessBrowserTest AppListServiceViewsBrowserTest;
@@ -42,3 +86,73 @@ IN_PROC_BROWSER_TEST_F(AppListServiceViewsBrowserTest, NativeClose) {
// Note: no need to sink message queue.
EXPECT_FALSE(service->GetAppListWindow());
}
+
+// Browser Test for AppListController that ensures the App Info dialog opens
+// correctly.
+class AppListControllerAppInfoDialogBrowserTest : public ExtensionBrowserTest {
+ public:
+ AppListControllerAppInfoDialogBrowserTest() {}
+ virtual ~AppListControllerAppInfoDialogBrowserTest() {}
+
+ virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE {
+ ExtensionBrowserTest::SetUpCommandLine(command_line);
+ command_line->AppendSwitch(app_list::switches::kEnableAppInfo);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AppListControllerAppInfoDialogBrowserTest);
+};
+
+// Test the DoShowAppInfoFlow function of the controller delegate.
+IN_PROC_BROWSER_TEST_F(AppListControllerAppInfoDialogBrowserTest,
+ DoShowAppInfoFlow) {
+ // Install an extension to open the dialog for.
+ test::SigninProfile(browser()->profile());
+ base::FilePath test_extension_path;
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_extension_path));
+ test_extension_path = test_extension_path.AppendASCII("extensions")
+ .AppendASCII("platform_apps")
+ .AppendASCII("minimal");
+ const extensions::Extension* extension = InstallExtension(
+ test_extension_path, 1 /* expected_change: new install */);
+ ASSERT_TRUE(extension);
+
+ // Open the app list window.
+ AppListService* service = test::GetAppListService();
+ EXPECT_FALSE(service->GetAppListWindow());
+
+ service->ShowForProfile(browser()->profile());
+ gfx::NativeWindow window = service->GetAppListWindow();
+ EXPECT_TRUE(window);
+
+ views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
+ ASSERT_TRUE(widget);
+
+ test::AppListViewTestApi test_api(GetAppListView(service));
+
+ // Open the app info dialog.
+ views::Widget::Widgets owned_widgets;
+ widget->GetAllOwnedWidgets(window, &owned_widgets);
+ EXPECT_EQ(0U, owned_widgets.size());
+ EXPECT_FALSE(test_api.is_overlay_visible());
+
+ AppListControllerDelegate* controller = service->GetControllerDelegate();
+ ASSERT_TRUE(controller);
+ controller->DoShowAppInfoFlow(browser()->profile(), extension->id());
+ base::RunLoop().RunUntilIdle();
+
+ owned_widgets.clear();
+ widget->GetAllOwnedWidgets(window, &owned_widgets);
+ EXPECT_EQ(1U, owned_widgets.size());
+ EXPECT_TRUE(test_api.is_overlay_visible());
+
+ // Close the app info dialog.
+ views::Widget* app_info_dialog = *owned_widgets.begin();
+ app_info_dialog->Close();
+ base::RunLoop().RunUntilIdle();
+
+ owned_widgets.clear();
+ widget->GetAllOwnedWidgets(window, &owned_widgets);
+ EXPECT_EQ(0U, owned_widgets.size());
+ EXPECT_FALSE(test_api.is_overlay_visible());
+}
« no previous file with comments | « chrome/browser/ui/app_list/app_list_controller_delegate_views.cc ('k') | chrome/browser/ui/app_list/extension_app_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698