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

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

Issue 882243002: [Extensions] Make extension actions use gfx::Image over gfx::ImageSkia. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 5 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/set_icon_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 "base/base64.h" 7 #include "base/base64.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/test/values_test_util.h" 9 #include "base/test/values_test_util.h"
10 #include "chrome/browser/extensions/extension_action.h" 10 #include "chrome/browser/extensions/extension_action.h"
11 #include "chrome/browser/extensions/extension_action_manager.h" 11 #include "chrome/browser/extensions/extension_action_manager.h"
12 #include "chrome/browser/extensions/extension_service_test_base.h" 12 #include "chrome/browser/extensions/extension_service_test_base.h"
13 #include "chrome/browser/extensions/extension_tab_util.h" 13 #include "chrome/browser/extensions/extension_tab_util.h"
14 #include "chrome/browser/extensions/test_extension_environment.h" 14 #include "chrome/browser/extensions/test_extension_environment.h"
15 #include "chrome/browser/extensions/test_extension_system.h" 15 #include "chrome/browser/extensions/test_extension_system.h"
16 #include "chrome/test/base/testing_profile.h" 16 #include "chrome/test/base/testing_profile.h"
17 #include "chrome/test/base/testing_profile.h" 17 #include "chrome/test/base/testing_profile.h"
18 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "extensions/browser/extension_system.h" 19 #include "extensions/browser/extension_system.h"
20 #include "extensions/common/extension.h" 20 #include "extensions/common/extension.h"
21 #include "extensions/common/extension_builder.h" 21 #include "extensions/common/extension_builder.h"
22 #include "extensions/common/value_builder.h" 22 #include "extensions/common/value_builder.h"
23 #include "ipc/ipc_message_utils.h" 23 #include "ipc/ipc_message_utils.h"
24 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 #include "ui/gfx/image/image_skia.h" 26 #include "third_party/skia/include/core/SkBitmap.h"
27 #include "ui/gfx/image/image.h"
27 #include "ui/gfx/ipc/gfx_param_traits.h" 28 #include "ui/gfx/ipc/gfx_param_traits.h"
28 29
29 namespace extensions { 30 namespace extensions {
30 namespace { 31 namespace {
31 32
32 using base::test::ParseJson; 33 using base::test::ParseJson;
33 using testing::HasSubstr; 34 using testing::HasSubstr;
34 35
35 36
36 scoped_ptr<base::DictionaryValue> SimpleManifest() { 37 scoped_ptr<base::DictionaryValue> SimpleManifest() {
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 ExtensionAction* page_action = 200 ExtensionAction* page_action =
200 ExtensionActionManager::Get(env.profile())->GetPageAction(*extension); 201 ExtensionActionManager::Get(env.profile())->GetPageAction(*extension);
201 scoped_ptr<content::WebContents> contents = env.MakeTab(); 202 scoped_ptr<content::WebContents> contents = env.MakeTab();
202 const int tab_id = ExtensionTabUtil::GetTabId(contents.get()); 203 const int tab_id = ExtensionTabUtil::GetTabId(contents.get());
203 EXPECT_FALSE(page_action->GetIsVisible(tab_id)); 204 EXPECT_FALSE(page_action->GetIsVisible(tab_id));
204 ContentAction::ApplyInfo apply_info = { 205 ContentAction::ApplyInfo apply_info = {
205 env.profile(), contents.get() 206 env.profile(), contents.get()
206 }; 207 };
207 208
208 // The declarative icon shouldn't exist unless the content action is applied. 209 // The declarative icon shouldn't exist unless the content action is applied.
209 EXPECT_TRUE(page_action->GetDeclarativeIcon(tab_id).bitmap()->empty()); 210 EXPECT_TRUE(page_action->GetDeclarativeIcon(tab_id).IsEmpty());
210 result->Apply(extension->id(), base::Time(), &apply_info); 211 result->Apply(extension->id(), base::Time(), &apply_info);
211 EXPECT_FALSE(page_action->GetDeclarativeIcon(tab_id).bitmap()->empty()); 212 EXPECT_FALSE(page_action->GetDeclarativeIcon(tab_id).IsEmpty());
212 result->Revert(extension->id(), base::Time(), &apply_info); 213 result->Revert(extension->id(), base::Time(), &apply_info);
213 EXPECT_TRUE(page_action->GetDeclarativeIcon(tab_id).bitmap()->empty()); 214 EXPECT_TRUE(page_action->GetDeclarativeIcon(tab_id).IsEmpty());
214 } 215 }
215 216
216 TEST_F(RequestContentScriptTest, MissingScripts) { 217 TEST_F(RequestContentScriptTest, MissingScripts) {
217 Init(); 218 Init();
218 std::string error; 219 std::string error;
219 bool bad_message = false; 220 bool bad_message = false;
220 scoped_refptr<const ContentAction> result = ContentAction::Create( 221 scoped_refptr<const ContentAction> result = ContentAction::Create(
221 profile(), 222 profile(),
222 HostID(HostID::EXTENSIONS, extension()->id()), 223 HostID(HostID::EXTENSIONS, extension()->id()),
223 extension(), 224 extension(),
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 " \"matchAboutBlank\": null\n" 394 " \"matchAboutBlank\": null\n"
394 "}"), 395 "}"),
395 &error, 396 &error,
396 &bad_message); 397 &bad_message);
397 EXPECT_TRUE(bad_message); 398 EXPECT_TRUE(bad_message);
398 ASSERT_FALSE(result.get()); 399 ASSERT_FALSE(result.get());
399 } 400 }
400 401
401 } // namespace 402 } // namespace
402 } // namespace extensions 403 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/declarative_content/set_icon_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698