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 "chrome/browser/apps/app_browsertest_util.h" | 5 #include "chrome/browser/apps/app_browsertest_util.h" |
6 #include "chrome/browser/extensions/api/management/management_api.h" | 6 #include "chrome/browser/extensions/api/management/management_api.h" |
7 #include "chrome/browser/extensions/api/runtime/runtime_api.h" | |
8 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
9 #include "chrome/browser/extensions/extension_function_test_utils.h" | 8 #include "chrome/browser/extensions/extension_function_test_utils.h" |
10 #include "chrome/browser/extensions/test_extension_dir.h" | 9 #include "chrome/browser/extensions/test_extension_dir.h" |
11 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
12 #include "content/public/browser/notification_service.h" | 11 #include "content/public/browser/notification_service.h" |
| 12 #include "extensions/browser/api/runtime/runtime_api.h" |
13 #include "extensions/browser/extension_registry.h" | 13 #include "extensions/browser/extension_registry.h" |
14 #include "net/test/embedded_test_server/embedded_test_server.h" | 14 #include "net/test/embedded_test_server/embedded_test_server.h" |
15 | 15 |
16 // Tests the privileged components of chrome.runtime. | 16 // Tests the privileged components of chrome.runtime. |
17 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeRuntimePrivileged) { | 17 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeRuntimePrivileged) { |
18 ASSERT_TRUE(RunExtensionTest("runtime/privileged")) << message_; | 18 ASSERT_TRUE(RunExtensionTest("runtime/privileged")) << message_; |
19 } | 19 } |
20 | 20 |
21 // Tests the unprivileged components of chrome.runtime. | 21 // Tests the unprivileged components of chrome.runtime. |
22 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeRuntimeUnprivileged) { | 22 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeRuntimeUnprivileged) { |
23 ASSERT_TRUE(StartEmbeddedTestServer()); | 23 ASSERT_TRUE(StartEmbeddedTestServer()); |
24 ASSERT_TRUE( | 24 ASSERT_TRUE( |
25 LoadExtension(test_data_dir_.AppendASCII("runtime/content_script"))); | 25 LoadExtension(test_data_dir_.AppendASCII("runtime/content_script"))); |
26 | 26 |
27 // The content script runs on webpage.html. | 27 // The content script runs on webpage.html. |
28 ResultCatcher catcher; | 28 ResultCatcher catcher; |
29 ui_test_utils::NavigateToURL(browser(), | 29 ui_test_utils::NavigateToURL(browser(), |
30 embedded_test_server()->GetURL("/webpage.html")); | 30 embedded_test_server()->GetURL("/webpage.html")); |
31 EXPECT_TRUE(catcher.GetNextResult()) << message_; | 31 EXPECT_TRUE(catcher.GetNextResult()) << message_; |
32 } | 32 } |
33 | 33 |
34 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeRuntimeUninstallURL) { | 34 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeRuntimeUninstallURL) { |
35 // Auto-confirm the uninstall dialog. | 35 // Auto-confirm the uninstall dialog. |
36 extensions::ManagementUninstallFunction::SetAutoConfirmForTest(true); | 36 extensions::ManagementUninstallFunction::SetAutoConfirmForTest(true); |
37 ASSERT_TRUE(LoadExtension( | 37 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("runtime") |
38 test_data_dir_.AppendASCII("runtime").AppendASCII("uninstall_url"). | 38 .AppendASCII("uninstall_url") |
39 AppendASCII("sets_uninstall_url"))); | 39 .AppendASCII("sets_uninstall_url"))); |
40 ASSERT_TRUE(RunExtensionTest("runtime/uninstall_url")) << message_; | 40 ASSERT_TRUE(RunExtensionTest("runtime/uninstall_url")) << message_; |
41 } | 41 } |
42 | 42 |
43 namespace extensions { | 43 namespace extensions { |
44 | 44 |
45 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeRuntimeGetPlatformInfo) { | 45 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeRuntimeGetPlatformInfo) { |
46 scoped_ptr<base::Value> result( | 46 scoped_ptr<base::Value> result( |
47 extension_function_test_utils::RunFunctionAndReturnSingleResult( | 47 extension_function_test_utils::RunFunctionAndReturnSingleResult( |
48 new RuntimeGetPlatformInfoFunction(), | 48 new RuntimeGetPlatformInfoFunction(), "[]", browser())); |
49 "[]", | |
50 browser())); | |
51 ASSERT_TRUE(result.get() != NULL); | 49 ASSERT_TRUE(result.get() != NULL); |
52 base::DictionaryValue* dict = | 50 base::DictionaryValue* dict = |
53 extension_function_test_utils::ToDictionary(result.get()); | 51 extension_function_test_utils::ToDictionary(result.get()); |
54 ASSERT_TRUE(dict != NULL); | 52 ASSERT_TRUE(dict != NULL); |
55 EXPECT_TRUE(dict->HasKey("os")); | 53 EXPECT_TRUE(dict->HasKey("os")); |
56 EXPECT_TRUE(dict->HasKey("arch")); | 54 EXPECT_TRUE(dict->HasKey("arch")); |
57 EXPECT_TRUE(dict->HasKey("nacl_arch")); | 55 EXPECT_TRUE(dict->HasKey("nacl_arch")); |
58 } | 56 } |
59 | 57 |
60 // Tests chrome.runtime.getPackageDirectory with an app. | 58 // Tests chrome.runtime.getPackageDirectory with an app. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } else { | 118 } else { |
121 load_observer.Wait(); | 119 load_observer.Wait(); |
122 WaitForExtensionViewsToLoad(); | 120 WaitForExtensionViewsToLoad(); |
123 } | 121 } |
124 } | 122 } |
125 ASSERT_TRUE( | 123 ASSERT_TRUE( |
126 registry->GetExtensionById(extension_id, ExtensionRegistry::TERMINATED)); | 124 registry->GetExtensionById(extension_id, ExtensionRegistry::TERMINATED)); |
127 } | 125 } |
128 | 126 |
129 } // namespace extensions | 127 } // namespace extensions |
OLD | NEW |