Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
| 10 #include "chrome/browser/extensions/extension_test_message_listener.h" | 10 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
| 14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
| 15 #include "content/public/browser/render_frame_host.h" | 15 #include "content/public/browser/render_frame_host.h" |
| 16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 17 #include "content/public/test/browser_test_utils.h" | 17 #include "content/public/test/browser_test_utils.h" |
| 18 #include "extensions/browser/event_router.h" | 18 #include "extensions/browser/event_router.h" |
| 19 #include "extensions/common/api/test.h" | 19 #include "extensions/common/api/test.h" |
| 20 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
| 21 #include "extensions/common/feature_switch.h" | |
| 22 #include "extensions/common/switches.h" | |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 24 |
| 23 namespace extensions { | 25 namespace extensions { |
| 24 | 26 |
| 25 namespace OnMessage = core_api::test::OnMessage; | 27 namespace OnMessage = core_api::test::OnMessage; |
| 26 | 28 |
| 27 namespace { | 29 namespace { |
| 28 | 30 |
| 29 void FindFrame(const GURL& url, | 31 void FindFrame(const GURL& url, |
| 30 content::RenderFrameHost** out, | 32 content::RenderFrameHost** out, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 browser()->tab_strip_model()->GetActiveWebContents(); | 103 browser()->tab_strip_model()->GetActiveWebContents(); |
| 102 | 104 |
| 103 if (active_web_contents->GetLastCommittedURL() == frame_url) | 105 if (active_web_contents->GetLastCommittedURL() == frame_url) |
| 104 return active_web_contents->GetMainFrame(); | 106 return active_web_contents->GetMainFrame(); |
| 105 | 107 |
| 106 content::RenderFrameHost* frame_host = NULL; | 108 content::RenderFrameHost* frame_host = NULL; |
| 107 active_web_contents->ForEachFrame( | 109 active_web_contents->ForEachFrame( |
| 108 base::Bind(&FindFrame, frame_url, &frame_host)); | 110 base::Bind(&FindFrame, frame_url, &frame_host)); |
| 109 return frame_host; | 111 return frame_host; |
| 110 } | 112 } |
| 113 | |
| 114 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | |
| 115 // Need to add a command line flag as well as a FeatureSwitch because the | |
| 116 // FeatureSwitch is not copied over to the renderer process from the | |
| 117 // browser process. | |
| 118 command_line->AppendSwitch( | |
| 119 extensions::switches::kEnableEmbeddedExtensionOptions); | |
| 120 ExtensionApiTest::SetUpCommandLine(command_line); | |
| 121 } | |
| 111 }; | 122 }; |
| 112 | 123 |
| 113 IN_PROC_BROWSER_TEST_F(ExtensionWebUITest, SanityCheckAvailableAPIs) { | 124 IN_PROC_BROWSER_TEST_F(ExtensionWebUITest, SanityCheckAvailableAPIs) { |
| 114 ASSERT_TRUE(RunTestOnExtensions("sanity_check_available_apis.js")); | 125 ASSERT_TRUE(RunTestOnExtensions("sanity_check_available_apis.js")); |
| 115 } | 126 } |
| 116 | 127 |
| 117 IN_PROC_BROWSER_TEST_F(ExtensionWebUITest, SanityCheckUnavailableAPIs) { | 128 IN_PROC_BROWSER_TEST_F(ExtensionWebUITest, SanityCheckUnavailableAPIs) { |
| 118 ASSERT_TRUE(RunTestOnAbout("sanity_check_available_apis.js")); | 129 ASSERT_TRUE(RunTestOnAbout("sanity_check_available_apis.js")); |
| 119 } | 130 } |
| 120 | 131 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 ASSERT_TRUE(RunTestOnExtensions("runtime_last_error.js")); | 171 ASSERT_TRUE(RunTestOnExtensions("runtime_last_error.js")); |
| 161 | 172 |
| 162 ASSERT_TRUE(listener->WaitUntilSatisfied()); | 173 ASSERT_TRUE(listener->WaitUntilSatisfied()); |
| 163 listener->ReplyWithError("unknown host"); | 174 listener->ReplyWithError("unknown host"); |
| 164 | 175 |
| 165 listener.reset(new ExtensionTestMessageListener(false)); | 176 listener.reset(new ExtensionTestMessageListener(false)); |
| 166 ASSERT_TRUE(listener->WaitUntilSatisfied()); | 177 ASSERT_TRUE(listener->WaitUntilSatisfied()); |
| 167 EXPECT_EQ("true", listener->message()); | 178 EXPECT_EQ("true", listener->message()); |
| 168 } | 179 } |
| 169 | 180 |
| 181 IN_PROC_BROWSER_TEST_F(ExtensionWebUITest, CanEmbedExtensionOptions) { | |
| 182 FeatureSwitch::ScopedOverride enable_options( | |
| 183 FeatureSwitch::embedded_extension_options(), true); | |
|
not at google - send to devlin
2014/08/07 23:06:02
might as well do this in a member variable as well
ericzeng
2014/08/08 00:23:46
Done.
| |
| 184 | |
| 185 scoped_ptr<ExtensionTestMessageListener> listener( | |
| 186 new ExtensionTestMessageListener("ready", true)); | |
| 187 | |
| 188 const Extension* extension = InstallExtension( | |
| 189 test_data_dir_.AppendASCII("extension_options").AppendASCII("embed_self"), | |
| 190 1); | |
| 191 ASSERT_TRUE(extension); | |
| 192 | |
| 193 ASSERT_TRUE(RunTestOnExtensions("can_embed_extension_options.js")); | |
| 194 | |
| 195 ASSERT_TRUE(listener->WaitUntilSatisfied()); | |
| 196 listener->Reply(extension->id()); | |
| 197 listener.reset(new ExtensionTestMessageListener("guest loaded", false)); | |
| 198 ASSERT_TRUE(listener->WaitUntilSatisfied()); | |
| 199 } | |
| 200 | |
| 170 } // namespace | 201 } // namespace |
| 171 | 202 |
| 172 } // namespace extensions | 203 } // namespace extensions |
| OLD | NEW |