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

Side by Side Diff: chrome/common/extensions/extension_manifests_unittest.cc

Issue 3522015: Implement new strategy for default apps (Closed)
Patch Set: all done Created 10 years, 2 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
« no previous file with comments | « chrome/common/extensions/extension.cc ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 28 matching lines...) Expand all
39 39
40 Extension* LoadExtensionWithLocation(DictionaryValue* value, 40 Extension* LoadExtensionWithLocation(DictionaryValue* value,
41 Extension::Location location, 41 Extension::Location location,
42 std::string* error) { 42 std::string* error) {
43 FilePath path; 43 FilePath path;
44 PathService::Get(chrome::DIR_TEST_DATA, &path); 44 PathService::Get(chrome::DIR_TEST_DATA, &path);
45 path = path.AppendASCII("extensions").AppendASCII("manifest_tests"); 45 path = path.AppendASCII("extensions").AppendASCII("manifest_tests");
46 46
47 scoped_ptr<Extension> extension(new Extension(path.DirName())); 47 scoped_ptr<Extension> extension(new Extension(path.DirName()));
48 extension->set_location(location); 48 extension->set_location(location);
49 extension->set_apps_enabled(enable_apps_);
50 49
51 if (!extension->InitFromValue(*value, false, error)) 50 if (!extension->InitFromValue(*value, false, error))
52 return NULL; 51 return NULL;
53 52
54 return extension.release(); 53 return extension.release();
55 } 54 }
56 55
57 Extension* LoadExtension(const std::string& name, 56 Extension* LoadExtension(const std::string& name,
58 std::string* error) { 57 std::string* error) {
59 return LoadExtensionWithLocation(name, Extension::INTERNAL, error); 58 return LoadExtensionWithLocation(name, Extension::INTERNAL, error);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 const std::string& name, 111 const std::string& name,
113 const std::string& expected_error) { 112 const std::string& expected_error) {
114 std::string error; 113 std::string error;
115 scoped_ptr<Extension> extension(LoadExtension(manifest, &error)); 114 scoped_ptr<Extension> extension(LoadExtension(manifest, &error));
116 VerifyExpectedError(extension.get(), name, error, expected_error); 115 VerifyExpectedError(extension.get(), name, error, expected_error);
117 } 116 }
118 117
119 bool enable_apps_; 118 bool enable_apps_;
120 }; 119 };
121 120
122 TEST_F(ExtensionManifestTest, AppsDisabledByDefault) {
123 #if defined(OS_CHROMEOS)
124 // On ChromeOS, apps are enabled by default.
125 if (Extension::AppsAreEnabled())
126 return;
127 #endif
128
129 enable_apps_ = false;
130 LoadAndExpectError("launch_local_path.json", errors::kAppsNotEnabled);
131 }
132
133 TEST_F(ExtensionManifestTest, ValidApp) { 121 TEST_F(ExtensionManifestTest, ValidApp) {
134 scoped_ptr<Extension> extension(LoadAndExpectSuccess("valid_app.json")); 122 scoped_ptr<Extension> extension(LoadAndExpectSuccess("valid_app.json"));
135 ASSERT_EQ(2u, extension->web_extent().patterns().size()); 123 ASSERT_EQ(2u, extension->web_extent().patterns().size());
136 EXPECT_EQ("http://www.google.com/mail/*", 124 EXPECT_EQ("http://www.google.com/mail/*",
137 extension->web_extent().patterns()[0].GetAsString()); 125 extension->web_extent().patterns()[0].GetAsString());
138 EXPECT_EQ("http://www.google.com/foobar/*", 126 EXPECT_EQ("http://www.google.com/foobar/*",
139 extension->web_extent().patterns()[1].GetAsString()); 127 extension->web_extent().patterns()[1].GetAsString());
140 EXPECT_EQ(extension_misc::LAUNCH_TAB, extension->launch_container()); 128 EXPECT_EQ(extension_misc::LAUNCH_TAB, extension->launch_container());
141 EXPECT_EQ("http://www.google.com/mail/", extension->launch_web_url()); 129 EXPECT_EQ("http://www.google.com/mail/", extension->launch_web_url());
142 } 130 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 } 325 }
338 326
339 TEST_F(ExtensionManifestTest, NormalizeIconPaths) { 327 TEST_F(ExtensionManifestTest, NormalizeIconPaths) {
340 scoped_ptr<Extension> extension( 328 scoped_ptr<Extension> extension(
341 LoadAndExpectSuccess("normalize_icon_paths.json")); 329 LoadAndExpectSuccess("normalize_icon_paths.json"));
342 EXPECT_EQ("16.png", 330 EXPECT_EQ("16.png",
343 extension->icons().Get(16, ExtensionIconSet::MATCH_EXACTLY)); 331 extension->icons().Get(16, ExtensionIconSet::MATCH_EXACTLY));
344 EXPECT_EQ("48.png", 332 EXPECT_EQ("48.png",
345 extension->icons().Get(48, ExtensionIconSet::MATCH_EXACTLY)); 333 extension->icons().Get(48, ExtensionIconSet::MATCH_EXACTLY));
346 } 334 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension.cc ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698