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

Side by Side Diff: chrome/common/extensions/manifest_handlers/ui_overrides_handler_unittest.cc

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_handlers/ui_overrides_handler.h" 5 #include "chrome/common/extensions/manifest_handlers/ui_overrides_handler.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_string_value_serializer.h" 10 #include "base/json/json_string_value_serializer.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 TEST_F(UIOverrideTest, ParseManifest) { 50 TEST_F(UIOverrideTest, ParseManifest) {
51 extensions::ScopedCurrentChannel channel(version_info::Channel::DEV); 51 extensions::ScopedCurrentChannel channel(version_info::Channel::DEV);
52 // This functionality requires a feature flag. 52 // This functionality requires a feature flag.
53 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 53 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
54 "--enable-override-bookmarks-ui", "1"); 54 "--enable-override-bookmarks-ui", "1");
55 std::string manifest(kManifest); 55 std::string manifest(kManifest);
56 JSONStringValueDeserializer json(manifest); 56 JSONStringValueDeserializer json(manifest);
57 std::string error; 57 std::string error;
58 std::unique_ptr<base::Value> root(json.Deserialize(NULL, &error)); 58 std::unique_ptr<base::Value> root(json.Deserialize(NULL, &error));
59 ASSERT_TRUE(root); 59 ASSERT_TRUE(root);
60 ASSERT_TRUE(root->IsType(base::Value::TYPE_DICTIONARY)); 60 ASSERT_TRUE(root->IsType(base::Value::Type::DICTIONARY));
61 scoped_refptr<Extension> extension = Extension::Create( 61 scoped_refptr<Extension> extension = Extension::Create(
62 base::FilePath(FILE_PATH_LITERAL("//nonexistent")), 62 base::FilePath(FILE_PATH_LITERAL("//nonexistent")),
63 Manifest::INVALID_LOCATION, 63 Manifest::INVALID_LOCATION,
64 *static_cast<base::DictionaryValue*>(root.get()), 64 *static_cast<base::DictionaryValue*>(root.get()),
65 Extension::NO_FLAGS, 65 Extension::NO_FLAGS,
66 &error); 66 &error);
67 ASSERT_TRUE(extension.get()) << error; 67 ASSERT_TRUE(extension.get()) << error;
68 ASSERT_TRUE(extension->manifest()->HasPath(manifest_keys::kUIOverride)); 68 ASSERT_TRUE(extension->manifest()->HasPath(manifest_keys::kUIOverride));
69 69
70 UIOverrides* ui_override = static_cast<UIOverrides*>( 70 UIOverrides* ui_override = static_cast<UIOverrides*>(
71 extension->GetManifestData(manifest_keys::kUIOverride)); 71 extension->GetManifestData(manifest_keys::kUIOverride));
72 ASSERT_TRUE(ui_override); 72 ASSERT_TRUE(ui_override);
73 ASSERT_TRUE(ui_override->bookmarks_ui); 73 ASSERT_TRUE(ui_override->bookmarks_ui);
74 EXPECT_TRUE(ui_override->bookmarks_ui->remove_button); 74 EXPECT_TRUE(ui_override->bookmarks_ui->remove_button);
75 EXPECT_TRUE(ui_override->bookmarks_ui->remove_bookmark_shortcut); 75 EXPECT_TRUE(ui_override->bookmarks_ui->remove_bookmark_shortcut);
76 } 76 }
77 77
78 TEST_F(UIOverrideTest, ParseBrokenManifest) { 78 TEST_F(UIOverrideTest, ParseBrokenManifest) {
79 extensions::ScopedCurrentChannel channel(version_info::Channel::DEV); 79 extensions::ScopedCurrentChannel channel(version_info::Channel::DEV);
80 // This functionality requires a feature flag. 80 // This functionality requires a feature flag.
81 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 81 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
82 "--enable-override-bookmarks-ui", "1"); 82 "--enable-override-bookmarks-ui", "1");
83 std::string manifest(kBrokenManifest); 83 std::string manifest(kBrokenManifest);
84 JSONStringValueDeserializer json(manifest); 84 JSONStringValueDeserializer json(manifest);
85 std::string error; 85 std::string error;
86 std::unique_ptr<base::Value> root(json.Deserialize(NULL, &error)); 86 std::unique_ptr<base::Value> root(json.Deserialize(NULL, &error));
87 ASSERT_TRUE(root); 87 ASSERT_TRUE(root);
88 ASSERT_TRUE(root->IsType(base::Value::TYPE_DICTIONARY)); 88 ASSERT_TRUE(root->IsType(base::Value::Type::DICTIONARY));
89 scoped_refptr<Extension> extension = Extension::Create( 89 scoped_refptr<Extension> extension = Extension::Create(
90 base::FilePath(FILE_PATH_LITERAL("//nonexistent")), 90 base::FilePath(FILE_PATH_LITERAL("//nonexistent")),
91 Manifest::INVALID_LOCATION, 91 Manifest::INVALID_LOCATION,
92 *static_cast<base::DictionaryValue*>(root.get()), 92 *static_cast<base::DictionaryValue*>(root.get()),
93 Extension::NO_FLAGS, 93 Extension::NO_FLAGS,
94 &error); 94 &error);
95 EXPECT_FALSE(extension.get()); 95 EXPECT_FALSE(extension.get());
96 EXPECT_EQ( 96 EXPECT_EQ(
97 extensions::ErrorUtils::FormatErrorMessage( 97 extensions::ErrorUtils::FormatErrorMessage(
98 extensions::manifest_errors::kInvalidEmptyDictionary, 98 extensions::manifest_errors::kInvalidEmptyDictionary,
99 extensions::manifest_keys::kUIOverride), 99 extensions::manifest_keys::kUIOverride),
100 error); 100 error);
101 } 101 }
102 102
103 } // namespace 103 } // namespace
OLDNEW
« no previous file with comments | « chrome/common/extensions/manifest_handlers/theme_handler.cc ('k') | chrome/installer/util/master_preferences.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698