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/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 "dns", | 96 "dns", |
97 "serial", | 97 "serial", |
98 }; | 98 }; |
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<base::DictionaryValue> manifest( |
107 LoadManifest("init_valid_platform_app.json", &error)); | 107 LoadManifest("init_valid_platform_app.json", &error)); |
108 | 108 |
109 std::vector<linked_ptr<DictionaryValue> > manifests; | 109 std::vector<linked_ptr<DictionaryValue> > manifests; |
110 // Create each manifest. | 110 // Create each manifest. |
111 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { | 111 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { |
112 const char* api_name = kPlatformAppExperimentalApis[i]; | 112 const char* api_name = kPlatformAppExperimentalApis[i]; |
113 | 113 |
114 // DictionaryValue will take ownership of this ListValue. | 114 // DictionaryValue will take ownership of this ListValue. |
115 ListValue *permissions = new ListValue(); | 115 base::ListValue *permissions = new base::ListValue(); |
116 permissions->Append(base::Value::CreateStringValue("experimental")); | 116 permissions->Append(new base::StringValue("experimental")); |
117 permissions->Append(base::Value::CreateStringValue(api_name)); | 117 permissions->Append(new base::StringValue(api_name)); |
118 manifest->Set("permissions", permissions); | 118 manifest->Set("permissions", permissions); |
119 manifests.push_back(make_linked_ptr(manifest->DeepCopy())); | 119 manifests.push_back(make_linked_ptr(manifest->DeepCopy())); |
120 } | 120 } |
121 | 121 |
122 // First try to load without any flags. This should fail for every API. | 122 // First try to load without any flags. This should fail for every API. |
123 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { | 123 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { |
124 LoadAndExpectError(Manifest(manifests[i].get(), ""), | 124 LoadAndExpectError(Manifest(manifests[i].get(), ""), |
125 errors::kExperimentalFlagRequired); | 125 errors::kExperimentalFlagRequired); |
126 } | 126 } |
127 | 127 |
128 // Now try again with the experimental flag set. | 128 // Now try again with the experimental flag set. |
129 CommandLine::ForCurrentProcess()->AppendSwitch( | 129 CommandLine::ForCurrentProcess()->AppendSwitch( |
130 switches::kEnableExperimentalExtensionApis); | 130 switches::kEnableExperimentalExtensionApis); |
131 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { | 131 for (size_t i = 0; i < arraysize(kPlatformAppExperimentalApis); ++i) { |
132 LoadAndExpectSuccess(Manifest(manifests[i].get(), "")); | 132 LoadAndExpectSuccess(Manifest(manifests[i].get(), "")); |
133 } | 133 } |
134 } | 134 } |
OLD | NEW |