Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: chrome/common/extensions/manifest_tests/extension_manifests_storage_unittest.cc

Issue 10544059: Change the platform app manifest structure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update for getDisplayPath, implement restrictions via _manifest_features.json Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "chrome/common/extensions/extension_manifest_constants.h" 8 #include "chrome/common/extensions/extension_manifest_constants.h"
9 9
10 namespace keys = extension_manifest_keys; 10 namespace keys = extension_manifest_keys;
11 11
12 TEST_F(ExtensionManifestTest, StorageAPIManifestVersionAvailability) { 12 TEST_F(ExtensionManifestTest, StorageAPIManifestVersionAvailability) {
13 DictionaryValue base_manifest; 13 DictionaryValue base_manifest;
14 { 14 {
15 base_manifest.SetString(keys::kName, "test"); 15 base_manifest.SetString(keys::kName, "test");
16 base_manifest.SetString(keys::kVersion, "0.1"); 16 base_manifest.SetString(keys::kVersion, "0.1");
17 ListValue* permissions = new ListValue(); 17 ListValue* permissions = new ListValue();
18 permissions->Append(Value::CreateStringValue("storage")); 18 permissions->Append(Value::CreateStringValue("storage"));
19 base_manifest.Set(keys::kPermissions, permissions); 19 base_manifest.Set(keys::kPermissions, permissions);
20 } 20 }
21 21
22 std::string kManifestVersionError = 22 std::string kManifestVersionError =
23 "'storage' requires manifest version of at least 2."; 23 "'storage' requires manifest version of at least 2.";
24 24
25 // Extension with no manifest version cannot use storage API. 25 // Extension with no manifest version cannot use storage API.
26 { 26 {
27 Manifest manifest(&base_manifest, "test"); 27 Manifest manifest(&base_manifest, "test");
28 scoped_refptr<extensions::Extension> extension = 28 LoadAndExpectWarning(manifest, kManifestVersionError);
29 LoadAndExpectSuccess(manifest);
30 if (extension.get()) {
31 std::vector<std::string> warnings;
32 warnings.push_back(kManifestVersionError);
33 EXPECT_EQ(warnings, extension->install_warnings());
34 }
35 } 29 }
36 30
37 // Extension with manifest version 1 cannot use storage API. 31 // Extension with manifest version 1 cannot use storage API.
38 { 32 {
39 DictionaryValue manifest_with_version; 33 DictionaryValue manifest_with_version;
40 manifest_with_version.SetInteger(keys::kManifestVersion, 1); 34 manifest_with_version.SetInteger(keys::kManifestVersion, 1);
41 manifest_with_version.MergeDictionary(&base_manifest); 35 manifest_with_version.MergeDictionary(&base_manifest);
42 36
43 Manifest manifest(&manifest_with_version, "test"); 37 Manifest manifest(&manifest_with_version, "test");
44 scoped_refptr<extensions::Extension> extension = 38 LoadAndExpectWarning(manifest, kManifestVersionError);
45 LoadAndExpectSuccess(manifest);
46 if (extension.get()) {
47 std::vector<std::string> warnings;
48 warnings.push_back(kManifestVersionError);
49 EXPECT_EQ(warnings, extension->install_warnings());
50 }
51 } 39 }
52 40
53 // Extension with manifest version 2 *can* use storage API. 41 // Extension with manifest version 2 *can* use storage API.
54 { 42 {
55 DictionaryValue manifest_with_version; 43 DictionaryValue manifest_with_version;
56 manifest_with_version.SetInteger(keys::kManifestVersion, 2); 44 manifest_with_version.SetInteger(keys::kManifestVersion, 2);
57 manifest_with_version.MergeDictionary(&base_manifest); 45 manifest_with_version.MergeDictionary(&base_manifest);
58 46
59 Manifest manifest(&manifest_with_version, "test"); 47 Manifest manifest(&manifest_with_version, "test");
60 scoped_refptr<extensions::Extension> extension = 48 scoped_refptr<extensions::Extension> extension =
61 LoadAndExpectSuccess(manifest); 49 LoadAndExpectSuccess(manifest);
62 if (extension.get()) { 50 EXPECT_TRUE(extension->install_warnings().empty());
63 std::vector<std::string> empty;
64 EXPECT_EQ(empty, extension->install_warnings());
65 }
66 } 51 }
67 } 52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698