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

Side by Side Diff: chrome/browser/extensions/api/extension_action/browser_action_apitest.cc

Issue 10827191: Convert extension action icons code to use ImageSkia instead of SkBitmap (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 8 years, 4 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(TOOLKIT_GTK) 7 #if defined(TOOLKIT_GTK)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
11 #include "chrome/browser/extensions/browser_action_test_util.h" 11 #include "chrome/browser/extensions/browser_action_test_util.h"
12 #include "chrome/browser/extensions/extension_apitest.h" 12 #include "chrome/browser/extensions/extension_apitest.h"
13 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/extension_tab_util.h" 14 #include "chrome/browser/extensions/extension_tab_util.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_commands.h" 17 #include "chrome/browser/ui/browser_commands.h"
18 #include "chrome/browser/ui/browser_tabstrip.h" 18 #include "chrome/browser/ui/browser_tabstrip.h"
19 #include "chrome/browser/ui/browser_window.h" 19 #include "chrome/browser/ui/browser_window.h"
20 #include "chrome/common/chrome_notification_types.h" 20 #include "chrome/common/chrome_notification_types.h"
21 #include "chrome/common/extensions/extension_action.h" 21 #include "chrome/common/extensions/extension_action.h"
22 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
23 #include "chrome/test/base/ui_test_utils.h" 23 #include "chrome/test/base/ui_test_utils.h"
24 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
25 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
26 #include "content/public/test/browser_test_utils.h" 26 #include "content/public/test/browser_test_utils.h"
27 #include "ui/gfx/image/image_skia.h"
27 #include "ui/gfx/rect.h" 28 #include "ui/gfx/rect.h"
28 #include "ui/gfx/size.h" 29 #include "ui/gfx/size.h"
29 30
30 using content::WebContents; 31 using content::WebContents;
31 using extensions::Extension; 32 using extensions::Extension;
32 33
33 class BrowserActionApiTest : public ExtensionApiTest { 34 class BrowserActionApiTest : public ExtensionApiTest {
34 public: 35 public:
35 BrowserActionApiTest() {} 36 BrowserActionApiTest() {}
36 virtual ~BrowserActionApiTest() {} 37 virtual ~BrowserActionApiTest() {}
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 const Extension* extension = GetSingleLoadedExtension(); 99 const Extension* extension = GetSingleLoadedExtension();
99 ASSERT_TRUE(extension) << message_; 100 ASSERT_TRUE(extension) << message_;
100 101
101 // Test that there is a browser action in the toolbar. 102 // Test that there is a browser action in the toolbar.
102 ASSERT_EQ(1, GetBrowserActionsBar().NumberOfBrowserActions()); 103 ASSERT_EQ(1, GetBrowserActionsBar().NumberOfBrowserActions());
103 EXPECT_TRUE(GetBrowserActionsBar().HasIcon(0)); 104 EXPECT_TRUE(GetBrowserActionsBar().HasIcon(0));
104 105
105 // Set prev_id which holds the id of the previous image, and use it in the 106 // Set prev_id which holds the id of the previous image, and use it in the
106 // next test to see if the image changes. 107 // next test to see if the image changes.
107 uint32_t prev_id = extension->browser_action()->GetIcon(0). 108 uint32_t prev_id = extension->browser_action()->GetIcon(0).
108 ToSkBitmap()->getGenerationID(); 109 bitmap()->getGenerationID();
109 110
110 // Tell the extension to update the icon using setIcon({imageData:...}). 111 // Tell the extension to update the icon using setIcon({imageData:...}).
111 ResultCatcher catcher; 112 ResultCatcher catcher;
112 ui_test_utils::NavigateToURL(browser(), 113 ui_test_utils::NavigateToURL(browser(),
113 GURL(extension->GetResourceURL("update.html"))); 114 GURL(extension->GetResourceURL("update.html")));
114 ASSERT_TRUE(catcher.GetNextResult()); 115 ASSERT_TRUE(catcher.GetNextResult());
115 116
116 // Test that we received the changes. 117 // Test that we received the changes.
117 EXPECT_TRUE(GetBrowserActionsBar().HasIcon(0)); 118 EXPECT_TRUE(GetBrowserActionsBar().HasIcon(0));
118 EXPECT_NE(prev_id, 119 EXPECT_NE(prev_id,
119 extension->browser_action()->GetIcon(0). 120 extension->browser_action()->GetIcon(0).
120 ToSkBitmap()->getGenerationID()); 121 bitmap()->getGenerationID());
121 prev_id = extension->browser_action()->GetIcon(0). 122 prev_id = extension->browser_action()->GetIcon(0).
122 ToSkBitmap()->getGenerationID(); 123 bitmap()->getGenerationID();
123 124
124 // Tell the extension to update the icon using setIcon({path:...}). 125 // Tell the extension to update the icon using setIcon({path:...}).
125 ui_test_utils::NavigateToURL(browser(), 126 ui_test_utils::NavigateToURL(browser(),
126 GURL(extension->GetResourceURL("update2.html"))); 127 GURL(extension->GetResourceURL("update2.html")));
127 ASSERT_TRUE(catcher.GetNextResult()); 128 ASSERT_TRUE(catcher.GetNextResult());
128 EXPECT_TRUE(GetBrowserActionsBar().HasIcon(0)); 129 EXPECT_TRUE(GetBrowserActionsBar().HasIcon(0));
129 EXPECT_NE(prev_id, 130 EXPECT_NE(prev_id,
130 extension->browser_action()->GetIcon(0). 131 extension->browser_action()->GetIcon(0).
131 ToSkBitmap()->getGenerationID()); 132 bitmap()->getGenerationID());
132 } 133 }
133 134
134 // This test is flaky as per http://crbug.com/74557. 135 // This test is flaky as per http://crbug.com/74557.
135 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, 136 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest,
136 DISABLED_TabSpecificBrowserActionState) { 137 DISABLED_TabSpecificBrowserActionState) {
137 ASSERT_TRUE(RunExtensionTest("browser_action/tab_specific_state")) << 138 ASSERT_TRUE(RunExtensionTest("browser_action/tab_specific_state")) <<
138 message_; 139 message_;
139 const Extension* extension = GetSingleLoadedExtension(); 140 const Extension* extension = GetSingleLoadedExtension();
140 ASSERT_TRUE(extension) << message_; 141 ASSERT_TRUE(extension) << message_;
141 142
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 ResultCatcher catcher; 471 ResultCatcher catcher;
471 ui_test_utils::NavigateToURL(browser(), 472 ui_test_utils::NavigateToURL(browser(),
472 GURL(extension->GetResourceURL("update.html"))); 473 GURL(extension->GetResourceURL("update.html")));
473 ASSERT_TRUE(catcher.GetNextResult()); 474 ASSERT_TRUE(catcher.GetNextResult());
474 475
475 // Test the getters for a specific tab. 476 // Test the getters for a specific tab.
476 ui_test_utils::NavigateToURL(browser(), 477 ui_test_utils::NavigateToURL(browser(),
477 GURL(extension->GetResourceURL("update2.html"))); 478 GURL(extension->GetResourceURL("update2.html")));
478 ASSERT_TRUE(catcher.GetNextResult()); 479 ASSERT_TRUE(catcher.GetNextResult());
479 } 480 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698