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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/browser.h"
6 #include "chrome/browser/browser_window.h"
7 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/browser/extensions/extension_browser_event_router.h"
9 #include "chrome/browser/extensions/extension_tabs_module.h"
10 #include "chrome/browser/extensions/extensions_service.h"
11 #include "chrome/browser/profile.h"
12 #include "chrome/browser/tab_contents/tab_contents.h"
13 #include "chrome/browser/views/browser_actions_container.h"
14 #include "chrome/browser/views/toolbar_view.h"
15 #include "chrome/common/extensions/extension_action.h"
16 #include "chrome/test/ui_test_utils.h"
17
18 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageAction) {
19 StartHTTPServer();
20 std::cout << "a\n";
21 ASSERT_TRUE(RunExtensionTest("page_action")) << message_;
22 std::cout << "b\n";
23
24 ExtensionsService* service = browser()->profile()->GetExtensionsService();
25 Extension* extension = service->extensions()->at(0);
26
27 std::cout << "c\n";
28 {
29 // Tell the extension to update the page action state.
30 ResultCatcher catcher;
31 ui_test_utils::NavigateToURL(browser(),
32 GURL(extension->GetResourceURL("update.html")));
33 std::cout << "d\n";
34 ASSERT_TRUE(catcher.GetNextResult());
35 }
36 std::cout << "e\n";
37
38 // Test that we received the changes.
39 const ExtensionActionState* action_state =
40 browser()->GetSelectedTabContents()->GetPageActionState(
41 extension->page_action());
42 ASSERT_TRUE(action_state);
43 EXPECT_EQ("Modified", action_state->title());
44 EXPECT_EQ("badge", action_state->badge_text());
45 EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255),
46 action_state->badge_background_color());
47 std::cout << "f\n";
48
49 {
50 // Simulate the page action being clicked.
51 ResultCatcher catcher;
52 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedTabContents()) ;
53 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted(
54 browser()->profile(), extension->id(), "", tab_id, "", 0);
55 std::cout << "g\n";
56 EXPECT_TRUE(catcher.GetNextResult());
57 }
58 std::cout << "h\n";
59
60 {
61 // Tell the extension to update the page action state again.
62 ResultCatcher catcher;
63 ui_test_utils::NavigateToURL(browser(),
64 GURL(extension->GetResourceURL("update2.html")));
65 std::cout << "x\n";
66 ASSERT_TRUE(catcher.GetNextResult());
67 }
68 std::cout << "t\n";
69
70 // Test that we received the changes.
71 action_state = browser()->GetSelectedTabContents()->GetPageActionState(
72 extension->page_action());
73 std::cout << "z\n";
74 EXPECT_TRUE(action_state->icon());
75 }
OLDNEW
« 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