| 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/files/scoped_temp_dir.h" |
| 8 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.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 scoped_refptr<extensions::Extension> extension = | 17 scoped_refptr<extensions::Extension> extension = |
| 18 LoadAndExpectSuccess("init_valid_platform_app.json"); | 18 LoadAndExpectSuccess("init_valid_platform_app.json"); |
| 19 EXPECT_TRUE(extension->is_storage_isolated()); | 19 EXPECT_TRUE(extension->is_storage_isolated()); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // TODO(miket): When the first platform-app API leaves experimental, write | 99 // TODO(miket): When the first platform-app API leaves experimental, write |
| 100 // similar code that tests without the experimental flag. | 100 // similar code that tests without the experimental flag. |
| 101 | 101 |
| 102 // This manifest is a skeleton used to build more specific manifests for | 102 // This manifest is a skeleton used to build more specific manifests for |
| 103 // testing. The requirements are that (1) it be a valid platform app, and (2) | 103 // testing. The requirements are that (1) it be a valid platform app, and (2) |
| 104 // it contain no permissions dictionary. | 104 // it contain no permissions dictionary. |
| 105 std::string error; | 105 std::string error; |
| 106 scoped_ptr<DictionaryValue> manifest( | 106 scoped_ptr<DictionaryValue> manifest( |
| 107 LoadManifestFile("init_valid_platform_app.json", &error)); | 107 LoadManifestFile("init_valid_platform_app.json", &error)); |
| 108 | 108 |
| 109 ScopedTempDir temp_dir; | 109 base::ScopedTempDir temp_dir; |
| 110 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 110 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 111 | 111 |
| 112 // Create each manifest. | 112 // Create each manifest. |
| 113 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { | 113 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { |
| 114 const char* api_name = kPlatformAppExperimentalApis[i]; | 114 const char* api_name = kPlatformAppExperimentalApis[i]; |
| 115 | 115 |
| 116 // DictionaryValue will take ownership of this ListValue. | 116 // DictionaryValue will take ownership of this ListValue. |
| 117 ListValue *permissions = new ListValue(); | 117 ListValue *permissions = new ListValue(); |
| 118 permissions->Append(base::Value::CreateStringValue("experimental")); | 118 permissions->Append(base::Value::CreateStringValue("experimental")); |
| 119 permissions->Append(base::Value::CreateStringValue(api_name)); | 119 permissions->Append(base::Value::CreateStringValue(api_name)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 136 | 136 |
| 137 // Now try again with the experimental flag set. | 137 // Now try again with the experimental flag set. |
| 138 CommandLine::ForCurrentProcess()->AppendSwitch( | 138 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 139 switches::kEnableExperimentalExtensionApis); | 139 switches::kEnableExperimentalExtensionApis); |
| 140 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { | 140 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { |
| 141 const char* api_name = kPlatformAppExperimentalApis[i]; | 141 const char* api_name = kPlatformAppExperimentalApis[i]; |
| 142 FilePath file_path = temp_dir.path().AppendASCII(api_name); | 142 FilePath file_path = temp_dir.path().AppendASCII(api_name); |
| 143 LoadAndExpectSuccess(file_path.MaybeAsASCII().c_str()); | 143 LoadAndExpectSuccess(file_path.MaybeAsASCII().c_str()); |
| 144 } | 144 } |
| 145 } | 145 } |
| OLD | NEW |