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

Unified Diff: chrome/browser/extensions/api/extension_action/page_action_apitest.cc

Issue 10855154: Update browserAction.setIcon and pageAction.setIcon for hidpi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: .. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/extension_action/page_action_apitest.cc
diff --git a/chrome/browser/extensions/api/extension_action/page_action_apitest.cc b/chrome/browser/extensions/api/extension_action/page_action_apitest.cc
index b6f1cc6ed2d084e3a698d4fc17a5007f5d64a3dc..175998107edb4aab4eca5f5b1c38cb0a814c448f 100644
--- a/chrome/browser/extensions/api/extension_action/page_action_apitest.cc
+++ b/chrome/browser/extensions/api/extension_action/page_action_apitest.cc
@@ -17,9 +17,21 @@
#include "chrome/common/extensions/extension_action.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/web_contents.h"
+#include "ui/gfx/image/image_skia.h"
using extensions::Extension;
+namespace {
+
+gfx::Image CreateNonEmptyImage() {
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16);
+ bitmap.allocPixels();
+ return gfx::Image(bitmap);
+}
+
+} // namespace
+
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageAction) {
ASSERT_TRUE(test_server()->Start());
ASSERT_TRUE(RunExtensionTest("page_action/basics")) << message_;
@@ -168,6 +180,31 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OldPageActions) {
browser()->profile(), *extension->page_action(), tab_id, "", 1);
EXPECT_TRUE(catcher.GetNextResult());
}
+
+ // Set icon by its index.
+ {
+ int tab_id =
+ ExtensionTabUtil::GetTabId(chrome::GetActiveWebContents(browser()));
+
+ // Set some icon so we can verify it gets cleaned up by setIconIndex.
+ extension->page_action()->SetIcon(tab_id, CreateNonEmptyImage());
+ ASSERT_FALSE(
+ extension->page_action()->GetExplicitlySetIcon(tab_id).empty());
+
+ // Currently, icon index should be set to 0.
+ ASSERT_EQ(0, extension->page_action()->GetIconIndex(tab_id));
+
+ ResultCatcher catcher;
+ ui_test_utils::NavigateToURL(browser(),
+ GURL(extension->GetResourceURL("set_icon_index.html")));
+ ASSERT_TRUE(catcher.GetNextResult());
+
+ // Check new value of icon index is as expected.
+ EXPECT_EQ(1, extension->page_action()->GetIconIndex(tab_id));
+ // Explicitly set icon should have been reset.
+ ASSERT_TRUE(
+ extension->page_action()->GetExplicitlySetIcon(tab_id).empty());
+ }
}
// Tests popups in page actions.

Powered by Google App Engine
This is Rietveld 408576698