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/common/extensions/manifest_tests/extension_manifest_test.h" | 5 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/json/json_file_value_serializer.h" | 8 #include "base/json/json_file_value_serializer.h" |
9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/common/extensions/extension_manifest_constants.h" | 11 #include "chrome/common/extensions/extension_manifest_constants.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace errors = extension_manifest_errors; | 14 namespace errors = extension_manifest_errors; |
15 | 15 |
16 TEST_F(ExtensionManifestTest, PlatformApps) { | 16 TEST_F(ExtensionManifestTest, PlatformApps) { |
17 // A minimal platform app. | 17 // A minimal platform app. |
18 LoadAndExpectError("init_valid_platform_app.json", | 18 LoadAndExpectError("init_valid_platform_app.json", |
19 errors::kPlatformAppFlagRequired); | 19 errors::kPlatformAppFlagRequired); |
20 | 20 |
21 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePlatformApps); | 21 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePlatformApps); |
22 | 22 |
23 LoadAndExpectSuccess("init_valid_platform_app.json"); | 23 LoadAndExpectSuccess("init_valid_platform_app.json"); |
24 | 24 |
25 LoadAndExpectError( | 25 LoadAndExpectError( |
| 26 "init_invalid_platform_app_1.json", |
| 27 extension_manifest_errors::kLaunchNotAllowedForPlatformApps); |
| 28 LoadAndExpectError( |
| 29 "init_invalid_platform_app_2.json", |
| 30 extension_manifest_errors::kBackgroundRequiredForPlatformApps); |
| 31 LoadAndExpectError( |
26 "init_invalid_platform_app_3.json", | 32 "init_invalid_platform_app_3.json", |
27 "Feature 'platform_app' is not accessible. " | 33 "Feature 'platform_app' is not accessible. " |
28 "'platform_app' requires manifest version of at least 2."); | 34 "'platform_app' requires manifest version of at least 2."); |
29 } | 35 } |
30 | 36 |
31 TEST_F(ExtensionManifestTest, CertainApisRequirePlatformApps) { | 37 TEST_F(ExtensionManifestTest, CertainApisRequirePlatformApps) { |
32 // Put APIs here that should be restricted to platform apps, but that haven't | 38 // Put APIs here that should be restricted to platform apps, but that haven't |
33 // yet graduated from experimental. | 39 // yet graduated from experimental. |
34 const char* kPlatformAppExperimentalApis[] = { | 40 const char* kPlatformAppExperimentalApis[] = { |
35 "dns", | 41 "dns", |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 92 |
87 // Finally, we should succeed with both experimental and platform-app flags | 93 // Finally, we should succeed with both experimental and platform-app flags |
88 // set. | 94 // set. |
89 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePlatformApps); | 95 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePlatformApps); |
90 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { | 96 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { |
91 const char* api_name = kPlatformAppExperimentalApis[i]; | 97 const char* api_name = kPlatformAppExperimentalApis[i]; |
92 FilePath file_path = temp_dir.path().AppendASCII(api_name); | 98 FilePath file_path = temp_dir.path().AppendASCII(api_name); |
93 LoadAndExpectSuccess(file_path.MaybeAsASCII().c_str()); | 99 LoadAndExpectSuccess(file_path.MaybeAsASCII().c_str()); |
94 } | 100 } |
95 } | 101 } |
OLD | NEW |