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

Side by Side Diff: chrome/browser/extensions/extension_info_map_unittest.cc

Issue 12093036: Move Extension Location and Type enums to Manifest, and move InstallWarning to its own file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 "base/json/json_file_value_serializer.h" 5 #include "base/json/json_file_value_serializer.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "chrome/browser/extensions/extension_info_map.h" 8 #include "chrome/browser/extensions/extension_info_map.h"
9 #include "chrome/common/chrome_paths.h" 9 #include "chrome/common/chrome_paths.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
11 #include "chrome/common/extensions/extension_manifest_constants.h" 11 #include "chrome/common/extensions/extension_manifest_constants.h"
12 #include "content/public/test/test_browser_thread.h" 12 #include "content/public/test/test_browser_thread.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h"
16 16
17 using content::BrowserThread; 17 using content::BrowserThread;
18 using extensions::APIPermission; 18 using extensions::APIPermission;
19 using extensions::Extension; 19 using extensions::Extension;
20 using extensions::Manifest;
20 using WebKit::WebSecurityOrigin; 21 using WebKit::WebSecurityOrigin;
21 using WebKit::WebString; 22 using WebKit::WebString;
22 23
23 namespace keys = extension_manifest_keys; 24 namespace keys = extension_manifest_keys;
24 25
25 namespace { 26 namespace {
26 27
27 class ExtensionInfoMapTest : public testing::Test { 28 class ExtensionInfoMapTest : public testing::Test {
28 public: 29 public:
29 ExtensionInfoMapTest() 30 ExtensionInfoMapTest()
(...skipping 14 matching lines...) Expand all
44 #elif defined(OS_POSIX) 45 #elif defined(OS_POSIX)
45 FilePath path(FILE_PATH_LITERAL("/foo")); 46 FilePath path(FILE_PATH_LITERAL("/foo"));
46 #endif 47 #endif
47 48
48 DictionaryValue manifest; 49 DictionaryValue manifest;
49 manifest.SetString(keys::kVersion, "1.0.0.0"); 50 manifest.SetString(keys::kVersion, "1.0.0.0");
50 manifest.SetString(keys::kName, name); 51 manifest.SetString(keys::kName, name);
51 52
52 std::string error; 53 std::string error;
53 scoped_refptr<Extension> extension = Extension::Create( 54 scoped_refptr<Extension> extension = Extension::Create(
54 path.AppendASCII(name), Extension::INVALID, manifest, 55 path.AppendASCII(name), Manifest::INVALID_LOCATION, manifest,
55 Extension::NO_FLAGS, &error); 56 Extension::NO_FLAGS, &error);
56 EXPECT_TRUE(extension) << error; 57 EXPECT_TRUE(extension) << error;
57 58
58 return extension; 59 return extension;
59 } 60 }
60 61
61 static scoped_refptr<Extension> LoadManifest(const std::string& dir, 62 static scoped_refptr<Extension> LoadManifest(const std::string& dir,
62 const std::string& test_file) { 63 const std::string& test_file) {
63 FilePath path; 64 FilePath path;
64 PathService::Get(chrome::DIR_TEST_DATA, &path); 65 PathService::Get(chrome::DIR_TEST_DATA, &path);
65 path = path.AppendASCII("extensions") 66 path = path.AppendASCII("extensions")
66 .AppendASCII(dir) 67 .AppendASCII(dir)
67 .AppendASCII(test_file); 68 .AppendASCII(test_file);
68 69
69 JSONFileValueSerializer serializer(path); 70 JSONFileValueSerializer serializer(path);
70 scoped_ptr<Value> result(serializer.Deserialize(NULL, NULL)); 71 scoped_ptr<Value> result(serializer.Deserialize(NULL, NULL));
71 if (!result.get()) 72 if (!result.get())
72 return NULL; 73 return NULL;
73 74
74 std::string error; 75 std::string error;
75 scoped_refptr<Extension> extension = Extension::Create( 76 scoped_refptr<Extension> extension = Extension::Create(
76 path, Extension::INVALID, *static_cast<DictionaryValue*>(result.get()), 77 path, Manifest::INVALID_LOCATION,
78 *static_cast<DictionaryValue*>(result.get()),
77 Extension::NO_FLAGS, &error); 79 Extension::NO_FLAGS, &error);
78 EXPECT_TRUE(extension) << error; 80 EXPECT_TRUE(extension) << error;
79 81
80 return extension; 82 return extension;
81 } 83 }
82 84
83 // Test that the ExtensionInfoMap handles refcounting properly. 85 // Test that the ExtensionInfoMap handles refcounting properly.
84 TEST_F(ExtensionInfoMapTest, RefCounting) { 86 TEST_F(ExtensionInfoMapTest, RefCounting) {
85 scoped_refptr<ExtensionInfoMap> info_map(new ExtensionInfoMap()); 87 scoped_refptr<ExtensionInfoMap> info_map(new ExtensionInfoMap());
86 88
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 EXPECT_FALSE(match); 175 EXPECT_FALSE(match);
174 176
175 // Sandboxed origins should not have any permissions. 177 // Sandboxed origins should not have any permissions.
176 match = info_map->extensions().GetExtensionOrAppByURL(ExtensionURLInfo( 178 match = info_map->extensions().GetExtensionOrAppByURL(ExtensionURLInfo(
177 WebSecurityOrigin::createFromString(WebString::fromUTF8("null")), 179 WebSecurityOrigin::createFromString(WebString::fromUTF8("null")),
178 app_url)); 180 app_url));
179 EXPECT_FALSE(match); 181 EXPECT_FALSE(match);
180 } 182 }
181 183
182 } // namespace 184 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_icon_manager_unittest.cc ('k') | chrome/browser/extensions/extension_install_prompt.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698