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

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

Issue 10375021: Move Extension into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Take 6 Created 8 years, 7 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
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<Extension> extension = LoadAndExpectSuccess(manifest); 28 scoped_refptr<extensions::Extension> extension =
29 LoadAndExpectSuccess(manifest);
29 if (extension.get()) { 30 if (extension.get()) {
30 std::vector<std::string> warnings; 31 std::vector<std::string> warnings;
31 warnings.push_back(kManifestVersionError); 32 warnings.push_back(kManifestVersionError);
32 EXPECT_EQ(warnings, extension->install_warnings()); 33 EXPECT_EQ(warnings, extension->install_warnings());
33 } 34 }
34 } 35 }
35 36
36 // Extension with manifest version 1 cannot use storage API. 37 // Extension with manifest version 1 cannot use storage API.
37 { 38 {
38 DictionaryValue manifest_with_version; 39 DictionaryValue manifest_with_version;
39 manifest_with_version.SetInteger(keys::kManifestVersion, 1); 40 manifest_with_version.SetInteger(keys::kManifestVersion, 1);
40 manifest_with_version.MergeDictionary(&base_manifest); 41 manifest_with_version.MergeDictionary(&base_manifest);
41 42
42 Manifest manifest(&manifest_with_version, "test"); 43 Manifest manifest(&manifest_with_version, "test");
43 scoped_refptr<Extension> extension = LoadAndExpectSuccess(manifest); 44 scoped_refptr<extensions::Extension> extension =
45 LoadAndExpectSuccess(manifest);
44 if (extension.get()) { 46 if (extension.get()) {
45 std::vector<std::string> warnings; 47 std::vector<std::string> warnings;
46 warnings.push_back(kManifestVersionError); 48 warnings.push_back(kManifestVersionError);
47 EXPECT_EQ(warnings, extension->install_warnings()); 49 EXPECT_EQ(warnings, extension->install_warnings());
48 } 50 }
49 } 51 }
50 52
51 // Extension with manifest version 2 *can* use storage API. 53 // Extension with manifest version 2 *can* use storage API.
52 { 54 {
53 DictionaryValue manifest_with_version; 55 DictionaryValue manifest_with_version;
54 manifest_with_version.SetInteger(keys::kManifestVersion, 2); 56 manifest_with_version.SetInteger(keys::kManifestVersion, 2);
55 manifest_with_version.MergeDictionary(&base_manifest); 57 manifest_with_version.MergeDictionary(&base_manifest);
56 58
57 Manifest manifest(&manifest_with_version, "test"); 59 Manifest manifest(&manifest_with_version, "test");
58 scoped_refptr<Extension> extension = LoadAndExpectSuccess(manifest); 60 scoped_refptr<extensions::Extension> extension =
61 LoadAndExpectSuccess(manifest);
59 if (extension.get()) { 62 if (extension.get()) {
60 std::vector<std::string> empty; 63 std::vector<std::string> empty;
61 EXPECT_EQ(empty, extension->install_warnings()); 64 EXPECT_EQ(empty, extension->install_warnings());
62 } 65 }
63 } 66 }
64 } 67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698