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

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

Issue 269079: Implement new page action API. (Closed)
Patch Set: compile fixes Created 11 years, 2 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/page_action_apitest.cc
diff --git a/chrome/browser/extensions/page_action_apitest.cc b/chrome/browser/extensions/page_action_apitest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..723c6f88bca4a3884e378c0327ae97ba5dd8dbcc
--- /dev/null
+++ b/chrome/browser/extensions/page_action_apitest.cc
@@ -0,0 +1,75 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_window.h"
+#include "chrome/browser/extensions/extension_apitest.h"
+#include "chrome/browser/extensions/extension_browser_event_router.h"
+#include "chrome/browser/extensions/extension_tabs_module.h"
+#include "chrome/browser/extensions/extensions_service.h"
+#include "chrome/browser/profile.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/views/browser_actions_container.h"
+#include "chrome/browser/views/toolbar_view.h"
+#include "chrome/common/extensions/extension_action.h"
+#include "chrome/test/ui_test_utils.h"
+
+IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageAction) {
+ StartHTTPServer();
+ std::cout << "a\n";
+ ASSERT_TRUE(RunExtensionTest("page_action")) << message_;
+ std::cout << "b\n";
+
+ ExtensionsService* service = browser()->profile()->GetExtensionsService();
+ Extension* extension = service->extensions()->at(0);
+
+ std::cout << "c\n";
+ {
+ // Tell the extension to update the page action state.
+ ResultCatcher catcher;
+ ui_test_utils::NavigateToURL(browser(),
+ GURL(extension->GetResourceURL("update.html")));
+ std::cout << "d\n";
+ ASSERT_TRUE(catcher.GetNextResult());
+ }
+ std::cout << "e\n";
+
+ // Test that we received the changes.
+ const ExtensionActionState* action_state =
+ browser()->GetSelectedTabContents()->GetPageActionState(
+ extension->page_action());
+ ASSERT_TRUE(action_state);
+ EXPECT_EQ("Modified", action_state->title());
+ EXPECT_EQ("badge", action_state->badge_text());
+ EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255),
+ action_state->badge_background_color());
+ std::cout << "f\n";
+
+ {
+ // Simulate the page action being clicked.
+ ResultCatcher catcher;
+ int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedTabContents());
+ ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted(
+ browser()->profile(), extension->id(), "", tab_id, "", 0);
+ std::cout << "g\n";
+ EXPECT_TRUE(catcher.GetNextResult());
+ }
+ std::cout << "h\n";
+
+ {
+ // Tell the extension to update the page action state again.
+ ResultCatcher catcher;
+ ui_test_utils::NavigateToURL(browser(),
+ GURL(extension->GetResourceURL("update2.html")));
+ std::cout << "x\n";
+ ASSERT_TRUE(catcher.GetNextResult());
+ }
+ std::cout << "t\n";
+
+ // Test that we received the changes.
+ action_state = browser()->GetSelectedTabContents()->GetPageActionState(
+ extension->page_action());
+ std::cout << "z\n";
+ EXPECT_TRUE(action_state->icon());
+}
« no previous file with comments | « chrome/browser/extensions/extension_page_actions_module_constants.cc ('k') | chrome/browser/gtk/location_bar_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698