| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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", | 26 "init_invalid_platform_app_1.json", |
| 27 extension_manifest_errors::kLaunchNotAllowedForPlatformApps); | 27 extension_manifest_errors::kLaunchNotAllowedForPlatformApps); |
| 28 LoadAndExpectError( | 28 LoadAndExpectError( |
| 29 "init_invalid_platform_app_2.json", | 29 "init_invalid_platform_app_2.json", |
| 30 extension_manifest_errors::kBackgroundRequiredForPlatformApps); | 30 extension_manifest_errors::kBackgroundRequiredForPlatformApps); |
| 31 LoadAndExpectError( | 31 |
| 32 "init_invalid_platform_app_3.json", | 32 scoped_refptr<Extension> extension = |
| 33 "Feature 'platform_app' is not accessible. " | 33 LoadAndExpectSuccess("init_invalid_platform_app_3.json"); |
| 34 "'platform_app' requires manifest version of at least 2."); | 34 ASSERT_TRUE(extension); |
| 35 ASSERT_EQ(1u, extension->install_warnings().size()); |
| 36 EXPECT_EQ("'platform_app' requires manifest version of at least 2.", |
| 37 extension->install_warnings()[0]); |
| 35 } | 38 } |
| 36 | 39 |
| 37 TEST_F(ExtensionManifestTest, CertainApisRequirePlatformApps) { | 40 TEST_F(ExtensionManifestTest, CertainApisRequirePlatformApps) { |
| 38 // Put APIs here that should be restricted to platform apps, but that haven't | 41 // Put APIs here that should be restricted to platform apps, but that haven't |
| 39 // yet graduated from experimental. | 42 // yet graduated from experimental. |
| 40 const char* kPlatformAppExperimentalApis[] = { | 43 const char* kPlatformAppExperimentalApis[] = { |
| 41 "dns", | 44 "dns", |
| 42 "serial", | 45 "serial", |
| 43 "socket", | 46 "socket", |
| 44 }; | 47 }; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 95 |
| 93 // Finally, we should succeed with both experimental and platform-app flags | 96 // Finally, we should succeed with both experimental and platform-app flags |
| 94 // set. | 97 // set. |
| 95 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePlatformApps); | 98 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePlatformApps); |
| 96 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { | 99 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { |
| 97 const char* api_name = kPlatformAppExperimentalApis[i]; | 100 const char* api_name = kPlatformAppExperimentalApis[i]; |
| 98 FilePath file_path = temp_dir.path().AppendASCII(api_name); | 101 FilePath file_path = temp_dir.path().AppendASCII(api_name); |
| 99 LoadAndExpectSuccess(file_path.MaybeAsASCII().c_str()); | 102 LoadAndExpectSuccess(file_path.MaybeAsASCII().c_str()); |
| 100 } | 103 } |
| 101 } | 104 } |
| OLD | NEW |