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

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

Issue 12207167: Cleanup: Remove deprecated base::Value methods from chrome/common. Use base::Value too. (Closed) Base URL: svn://chrome-svn/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/file_path.h" 5 #include "base/file_path.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
11 #include "chrome/common/extensions/extension_set.h" 11 #include "chrome/common/extensions/extension_set.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 using extensions::Extension; 14 using extensions::Extension;
15 15
16 namespace { 16 namespace {
17 17
18 scoped_refptr<Extension> CreateTestExtension(const std::string& name, 18 scoped_refptr<Extension> CreateTestExtension(const std::string& name,
19 const std::string& launch_url, 19 const std::string& launch_url,
20 const std::string& extent) { 20 const std::string& extent) {
21 #if defined(OS_WIN) 21 #if defined(OS_WIN)
22 base::FilePath path(FILE_PATH_LITERAL("c:\\")); 22 base::FilePath path(FILE_PATH_LITERAL("c:\\"));
23 #else 23 #else
24 base::FilePath path(FILE_PATH_LITERAL("/")); 24 base::FilePath path(FILE_PATH_LITERAL("/"));
25 #endif 25 #endif
26 path = path.AppendASCII(name); 26 path = path.AppendASCII(name);
27 27
28 DictionaryValue manifest; 28 base::DictionaryValue manifest;
29 manifest.SetString("name", name); 29 manifest.SetString("name", name);
30 manifest.SetString("version", "1"); 30 manifest.SetString("version", "1");
31 31
32 if (!launch_url.empty()) 32 if (!launch_url.empty())
33 manifest.SetString("app.launch.web_url", launch_url); 33 manifest.SetString("app.launch.web_url", launch_url);
34 34
35 if (!extent.empty()) { 35 if (!extent.empty()) {
36 ListValue* urls = new ListValue(); 36 base::ListValue* urls = new base::ListValue();
37 manifest.Set("app.urls", urls); 37 manifest.Set("app.urls", urls);
38 urls->Append(Value::CreateStringValue(extent)); 38 urls->Append(new base::StringValue(extent));
39 } 39 }
40 40
41 std::string error; 41 std::string error;
42 scoped_refptr<Extension> extension( 42 scoped_refptr<Extension> extension(
43 Extension::Create(path, extensions::Manifest::INTERNAL, manifest, 43 Extension::Create(path, extensions::Manifest::INTERNAL, manifest,
44 Extension::NO_FLAGS, &error)); 44 Extension::NO_FLAGS, &error));
45 EXPECT_TRUE(extension.get()) << error; 45 EXPECT_TRUE(extension.get()) << error;
46 return extension; 46 return extension;
47 } 47 }
48 48
49 } // namespace 49 } // namespace
50 50
51 TEST(ExtensionSetTest, ExtensionSet) { 51 TEST(ExtensionSetTest, ExtensionSet) {
52 scoped_refptr<Extension> ext1(CreateTestExtension( 52 scoped_refptr<Extension> ext1(CreateTestExtension(
53 "a", "https://chrome.google.com/launch", "https://chrome.google.com/")); 53 "a", "https://chrome.google.com/launch", "https://chrome.google.com/"));
54 54
55 scoped_refptr<Extension> ext2(CreateTestExtension( 55 scoped_refptr<Extension> ext2(CreateTestExtension(
56 "a", "http://code.google.com/p/chromium", 56 "a", "http://code.google.com/p/chromium",
57 "http://code.google.com/p/chromium/")); 57 "http://code.google.com/p/chromium/"));
58 58
59 scoped_refptr<Extension> ext3(CreateTestExtension( 59 scoped_refptr<Extension> ext3(CreateTestExtension(
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 to_add->Insert(ext5); 127 to_add->Insert(ext5);
128 to_add->Insert(ext6); 128 to_add->Insert(ext6);
129 129
130 ASSERT_TRUE(extensions.Contains(ext3->id())); 130 ASSERT_TRUE(extensions.Contains(ext3->id()));
131 ASSERT_TRUE(extensions.InsertAll(*to_add)); 131 ASSERT_TRUE(extensions.InsertAll(*to_add));
132 EXPECT_EQ(4u, extensions.size()); 132 EXPECT_EQ(4u, extensions.size());
133 133
134 ASSERT_FALSE(extensions.InsertAll(*to_add)); // Re-adding same set no-ops. 134 ASSERT_FALSE(extensions.InsertAll(*to_add)); // Re-adding same set no-ops.
135 EXPECT_EQ(4u, extensions.size()); 135 EXPECT_EQ(4u, extensions.size());
136 } 136 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698