| 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 3fd45a37e4808f6c5d2c42b50bc4cd5a7274001c..c7d54226f6aa4a9289fde9694711e30be7711d0d 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).isNull());
|
| +
|
| + // 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).isNull());
|
| + }
|
| }
|
|
|
| // Tests popups in page actions.
|
|
|