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

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

Issue 506883003: Remove implicit conversions from scoped_refptr to T* in chrome/*/extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_string_value_serializer.h" 8 #include "base/json/json_string_value_serializer.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/common/extensions/features/feature_channel.h" 10 #include "chrome/common/extensions/features/feature_channel.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 std::string error; 55 std::string error;
56 scoped_ptr<base::Value> root(json.Deserialize(NULL, &error)); 56 scoped_ptr<base::Value> root(json.Deserialize(NULL, &error));
57 ASSERT_TRUE(root); 57 ASSERT_TRUE(root);
58 ASSERT_TRUE(root->IsType(base::Value::TYPE_DICTIONARY)); 58 ASSERT_TRUE(root->IsType(base::Value::TYPE_DICTIONARY));
59 scoped_refptr<Extension> extension = Extension::Create( 59 scoped_refptr<Extension> extension = Extension::Create(
60 base::FilePath(FILE_PATH_LITERAL("//nonexistent")), 60 base::FilePath(FILE_PATH_LITERAL("//nonexistent")),
61 Manifest::INVALID_LOCATION, 61 Manifest::INVALID_LOCATION,
62 *static_cast<base::DictionaryValue*>(root.get()), 62 *static_cast<base::DictionaryValue*>(root.get()),
63 Extension::NO_FLAGS, 63 Extension::NO_FLAGS,
64 &error); 64 &error);
65 ASSERT_TRUE(extension) << error; 65 ASSERT_TRUE(extension.get()) << error;
66 ASSERT_TRUE(extension->manifest()->HasPath(manifest_keys::kUIOverride)); 66 ASSERT_TRUE(extension->manifest()->HasPath(manifest_keys::kUIOverride));
67 67
68 UIOverrides* ui_override = static_cast<UIOverrides*>( 68 UIOverrides* ui_override = static_cast<UIOverrides*>(
69 extension->GetManifestData(manifest_keys::kUIOverride)); 69 extension->GetManifestData(manifest_keys::kUIOverride));
70 ASSERT_TRUE(ui_override); 70 ASSERT_TRUE(ui_override);
71 ASSERT_TRUE(ui_override->bookmarks_ui); 71 ASSERT_TRUE(ui_override->bookmarks_ui);
72 EXPECT_TRUE(ui_override->bookmarks_ui->remove_button); 72 EXPECT_TRUE(ui_override->bookmarks_ui->remove_button);
73 EXPECT_TRUE(ui_override->bookmarks_ui->remove_bookmark_shortcut); 73 EXPECT_TRUE(ui_override->bookmarks_ui->remove_bookmark_shortcut);
74 } 74 }
75 75
76 TEST_F(UIOverrideTest, ParseBrokenManifest) { 76 TEST_F(UIOverrideTest, ParseBrokenManifest) {
77 extensions::ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV); 77 extensions::ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV);
78 // This functionality requires a feature flag. 78 // This functionality requires a feature flag.
79 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 79 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
80 "--enable-override-bookmarks-ui", 80 "--enable-override-bookmarks-ui",
81 "1"); 81 "1");
82 std::string manifest(kBrokenManifest); 82 std::string manifest(kBrokenManifest);
83 JSONStringValueSerializer json(&manifest); 83 JSONStringValueSerializer json(&manifest);
84 std::string error; 84 std::string error;
85 scoped_ptr<base::Value> root(json.Deserialize(NULL, &error)); 85 scoped_ptr<base::Value> root(json.Deserialize(NULL, &error));
86 ASSERT_TRUE(root); 86 ASSERT_TRUE(root);
87 ASSERT_TRUE(root->IsType(base::Value::TYPE_DICTIONARY)); 87 ASSERT_TRUE(root->IsType(base::Value::TYPE_DICTIONARY));
88 scoped_refptr<Extension> extension = Extension::Create( 88 scoped_refptr<Extension> extension = Extension::Create(
89 base::FilePath(FILE_PATH_LITERAL("//nonexistent")), 89 base::FilePath(FILE_PATH_LITERAL("//nonexistent")),
90 Manifest::INVALID_LOCATION, 90 Manifest::INVALID_LOCATION,
91 *static_cast<base::DictionaryValue*>(root.get()), 91 *static_cast<base::DictionaryValue*>(root.get()),
92 Extension::NO_FLAGS, 92 Extension::NO_FLAGS,
93 &error); 93 &error);
94 EXPECT_FALSE(extension); 94 EXPECT_FALSE(extension.get());
95 EXPECT_EQ( 95 EXPECT_EQ(
96 extensions::ErrorUtils::FormatErrorMessage( 96 extensions::ErrorUtils::FormatErrorMessage(
97 extensions::manifest_errors::kInvalidEmptyDictionary, 97 extensions::manifest_errors::kInvalidEmptyDictionary,
98 extensions::manifest_keys::kUIOverride), 98 extensions::manifest_keys::kUIOverride),
99 error); 99 error);
100 } 100 }
101 101
102 } // namespace 102 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698