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

Side by Side Diff: chrome/browser/extensions/api/declarative_content/content_action_unittest.cc

Issue 2675563002: [Extensions] Remove usage of extension_action_redesign in declarativeContent (Closed)
Patch Set: . Created 3 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc » ('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) 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 "chrome/browser/extensions/api/declarative_content/content_action.h" 5 #include "chrome/browser/extensions/api/declarative_content/content_action.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/test/values_test_util.h" 11 #include "base/test/values_test_util.h"
12 #include "chrome/browser/extensions/extension_action.h" 12 #include "chrome/browser/extensions/extension_action.h"
13 #include "chrome/browser/extensions/extension_action_manager.h" 13 #include "chrome/browser/extensions/extension_action_manager.h"
14 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/extension_service_test_base.h" 15 #include "chrome/browser/extensions/extension_service_test_base.h"
15 #include "chrome/browser/extensions/extension_tab_util.h" 16 #include "chrome/browser/extensions/extension_tab_util.h"
16 #include "chrome/browser/extensions/test_extension_environment.h" 17 #include "chrome/browser/extensions/test_extension_environment.h"
17 #include "chrome/browser/extensions/test_extension_system.h" 18 #include "chrome/browser/extensions/test_extension_system.h"
18 #include "chrome/test/base/testing_profile.h" 19 #include "chrome/test/base/testing_profile.h"
19 #include "chrome/test/base/testing_profile.h" 20 #include "chrome/test/base/testing_profile.h"
20 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
21 #include "extensions/browser/extension_system.h" 22 #include "extensions/browser/extension_system.h"
22 #include "extensions/common/extension.h" 23 #include "extensions/common/extension.h"
23 #include "extensions/common/extension_builder.h" 24 #include "extensions/common/extension_builder.h"
24 #include "extensions/common/feature_switch.h"
25 #include "extensions/common/value_builder.h" 25 #include "extensions/common/value_builder.h"
26 #include "ipc/ipc_message_utils.h" 26 #include "ipc/ipc_message_utils.h"
27 #include "testing/gmock/include/gmock/gmock.h" 27 #include "testing/gmock/include/gmock/gmock.h"
28 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
29 #include "third_party/skia/include/core/SkBitmap.h" 29 #include "third_party/skia/include/core/SkBitmap.h"
30 #include "ui/gfx/image/image.h" 30 #include "ui/gfx/image/image.h"
31 #include "ui/gfx/ipc/skia/gfx_skia_param_traits.h" 31 #include "ui/gfx/ipc/skia/gfx_skia_param_traits.h"
32 32
33 namespace extensions { 33 namespace extensions {
34 namespace { 34 namespace {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 result = ContentAction::Create(NULL, NULL, *ParseJson( 91 result = ContentAction::Create(NULL, NULL, *ParseJson(
92 "{\n" 92 "{\n"
93 " \"instanceType\": \"declarativeContent.UnknownType\",\n" 93 " \"instanceType\": \"declarativeContent.UnknownType\",\n"
94 "}"), 94 "}"),
95 &error); 95 &error);
96 EXPECT_THAT(error, HasSubstr("invalid instanceType")); 96 EXPECT_THAT(error, HasSubstr("invalid instanceType"));
97 EXPECT_FALSE(result.get()); 97 EXPECT_FALSE(result.get());
98 } 98 }
99 99
100 TEST(DeclarativeContentActionTest, ShowPageActionWithoutPageAction) { 100 TEST(DeclarativeContentActionTest, ShowPageActionWithoutPageAction) {
101 // Tests legacy behavior.
102 FeatureSwitch::ScopedOverride action_redesign_override(
103 FeatureSwitch::extension_action_redesign(), false);
104 TestExtensionEnvironment env; 101 TestExtensionEnvironment env;
105 102
106 const Extension* extension = env.MakeExtension(base::DictionaryValue()); 103 // We install a component extension because all other extensions have a
104 // required action.
105 DictionaryBuilder manifest;
106 manifest.Set("name", "extension")
107 .Set("version", "0.1")
108 .Set("manifest_version", 2)
109 .Set("description", "an extension");
110 scoped_refptr<const Extension> extension =
111 ExtensionBuilder()
112 .SetManifest(manifest.Build())
113 .SetLocation(Manifest::COMPONENT)
114 .Build();
115 env.GetExtensionService()->AddExtension(extension.get());
116
107 std::string error; 117 std::string error;
108 std::unique_ptr<const ContentAction> result = ContentAction::Create( 118 std::unique_ptr<const ContentAction> result = ContentAction::Create(
109 NULL, extension, 119 NULL, extension.get(),
110 *ParseJson("{\n" 120 *ParseJson("{\n"
111 " \"instanceType\": \"declarativeContent.ShowPageAction\",\n" 121 " \"instanceType\": \"declarativeContent.ShowPageAction\",\n"
112 "}"), 122 "}"),
113 &error); 123 &error);
114 EXPECT_THAT(error, testing::HasSubstr("without a page action")); 124 EXPECT_THAT(error, testing::HasSubstr("without a page action"));
115 ASSERT_FALSE(result.get()); 125 ASSERT_FALSE(result.get());
116 } 126 }
117 127
118 TEST(DeclarativeContentActionTest, ShowPageAction) { 128 TEST(DeclarativeContentActionTest, ShowPageAction) {
119 TestExtensionEnvironment env; 129 TestExtensionEnvironment env;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" 337 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n"
328 " \"js\": [\"script.js\"],\n" 338 " \"js\": [\"script.js\"],\n"
329 " \"matchAboutBlank\": null\n" 339 " \"matchAboutBlank\": null\n"
330 "}"), 340 "}"),
331 &error); 341 &error);
332 ASSERT_FALSE(result.get()); 342 ASSERT_FALSE(result.get());
333 } 343 }
334 344
335 } // namespace 345 } // namespace
336 } // namespace extensions 346 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698