Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | |
| 8 #include "chrome/browser/extensions/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.h" |
| 9 #include "chrome/browser/extensions/extension_host.h" | 10 #include "chrome/browser/extensions/extension_host.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/extensions/extension_test_message_listener.h" | 12 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 14 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| 14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_list.h" | 16 #include "chrome/browser/ui/browser_list.h" |
| 16 #include "chrome/browser/web_applications/web_app.h" | 17 #include "chrome/browser/web_applications/web_app.h" |
| 17 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 37 // RenderViewContextMenu. | 38 // RenderViewContextMenu. |
| 38 virtual bool GetAcceleratorForCommandId(int command_id, | 39 virtual bool GetAcceleratorForCommandId(int command_id, |
| 39 ui::Accelerator* accelerator) { | 40 ui::Accelerator* accelerator) { |
| 40 return false; | 41 return false; |
| 41 } | 42 } |
| 42 virtual void PlatformInit() {} | 43 virtual void PlatformInit() {} |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 } // namespace | 46 } // namespace |
| 46 | 47 |
| 47 class PlatformAppBrowserTest : public ExtensionBrowserTest { | 48 class PlatformAppBrowserTest : public ExtensionApiTest { |
| 48 public: | 49 public: |
| 49 virtual void SetUpCommandLine(CommandLine* command_line) { | 50 virtual void SetUpCommandLine(CommandLine* command_line) { |
| 50 ExtensionBrowserTest::SetUpCommandLine(command_line); | 51 ExtensionBrowserTest::SetUpCommandLine(command_line); |
| 51 command_line->AppendSwitch(switches::kEnablePlatformApps); | 52 command_line->AppendSwitch(switches::kEnablePlatformApps); |
| 52 } | 53 } |
| 53 | 54 |
| 54 protected: | 55 protected: |
| 55 void LoadAndLaunchPlatformApp(const char* name) { | 56 void LoadAndLaunchPlatformApp(const char* name) { |
| 56 ui_test_utils::WindowedNotificationObserver app_loaded_observer( | 57 ui_test_utils::WindowedNotificationObserver app_loaded_observer( |
| 57 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 58 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 ASSERT_EQ(1, menu->menu_model().GetItemCount()); | 177 ASSERT_EQ(1, menu->menu_model().GetItemCount()); |
| 177 } | 178 } |
| 178 | 179 |
| 179 // Disabled until shell windows are implemented for non-GTK, non-Views toolkits. | 180 // Disabled until shell windows are implemented for non-GTK, non-Views toolkits. |
| 180 #if defined(TOOLKIT_GTK) || defined(TOOLKIT_VIEWS) | 181 #if defined(TOOLKIT_GTK) || defined(TOOLKIT_VIEWS) |
| 181 #define MAYBE_DisallowNavigation DisallowNavigation | 182 #define MAYBE_DisallowNavigation DisallowNavigation |
| 182 #else | 183 #else |
| 183 #define MAYBE_DisallowNavigation DISABLED_DisallowNavigation | 184 #define MAYBE_DisallowNavigation DISABLED_DisallowNavigation |
| 184 #endif | 185 #endif |
| 185 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_DisallowNavigation) { | 186 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_DisallowNavigation) { |
| 186 ASSERT_TRUE(test_server()->Start()); | 187 ASSERT_TRUE(test_server()->Start()); |
| 187 | 188 |
| 188 LoadAndLaunchPlatformApp("navigation"); | 189 LoadAndLaunchPlatformApp("navigation"); |
| 189 WebContents* web_contents = GetFirstPlatformAppWebContents(); | 190 WebContents* web_contents = GetFirstPlatformAppWebContents(); |
| 190 | 191 |
| 191 GURL remote_url = test_server()->GetURL( | 192 GURL remote_url = test_server()->GetURL( |
| 192 "files/extensions/platform_apps/navigation/nav-target.html"); | 193 "files/extensions/platform_apps/navigation/nav-target.html"); |
| 193 | 194 |
| 194 std::string script = StringPrintf( | 195 std::string script = StringPrintf( |
| 195 "runTests(\"%s\")", remote_url.spec().c_str()); | 196 "runTests(\"%s\")", remote_url.spec().c_str()); |
| 196 bool result = false; | 197 bool result = false; |
| 197 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 198 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 198 web_contents->GetRenderViewHost(), L"", | 199 web_contents->GetRenderViewHost(), L"", |
| 199 UTF8ToWide(script), &result)); | 200 UTF8ToWide(script), &result)); |
| 200 EXPECT_TRUE(result); | 201 EXPECT_TRUE(result); |
| 201 } | 202 } |
| 203 | |
| 204 // Disabled until shell windows are implemented for non-GTK, non-Views toolkits. | |
| 205 #if defined(TOOLKIT_GTK) || defined(TOOLKIT_VIEWS) | |
| 206 #define MAYBE_DisallowModalDialogs DisallowModalDialogs | |
| 207 #else | |
| 208 #define MAYBE_DisallowModalDialogs DISABLED_DisallowModalDialogs | |
| 209 #endif | |
| 210 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_DisallowModalDialogs) { | |
| 211 ASSERT_TRUE(RunExtensionTest("platform_apps/modal_dialogs")) << message_; | |
|
jstritar
2012/01/19 20:20:41
I'll convert these to use RunExtensionSubtest and
| |
| 212 } | |
| OLD | NEW |