OLD | NEW |
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 "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
6 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
7 #include "chrome/browser/extensions/extension_toolbar_model.h" | |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/test/base/ui_test_utils.h" | 9 #include "chrome/test/base/ui_test_utils.h" |
10 #include "extensions/common/extension.h" | 10 #include "extensions/common/extension.h" |
11 #include "net/test/embedded_test_server/embedded_test_server.h" | 11 #include "net/test/embedded_test_server/embedded_test_server.h" |
12 | 12 |
13 namespace extensions { | 13 namespace extensions { |
14 namespace { | 14 namespace { |
15 | 15 |
16 // Times out on win syzyasan, http://crbug.com/166026 | 16 // Times out on win syzyasan, http://crbug.com/166026 |
17 #if defined(SYZYASAN) | 17 #if defined(SYZYASAN) |
18 #define MAYBE_ActiveTab DISABLED_ActiveTab | 18 #define MAYBE_ActiveTab DISABLED_ActiveTab |
19 #else | 19 #else |
20 #define MAYBE_ActiveTab ActiveTab | 20 #define MAYBE_ActiveTab ActiveTab |
21 #endif | 21 #endif |
22 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_ActiveTab) { | 22 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_ActiveTab) { |
23 ASSERT_TRUE(StartEmbeddedTestServer()); | 23 ASSERT_TRUE(StartEmbeddedTestServer()); |
24 | 24 |
25 const Extension* extension = | 25 const Extension* extension = |
26 LoadExtension(test_data_dir_.AppendASCII("active_tab")); | 26 LoadExtension(test_data_dir_.AppendASCII("active_tab")); |
27 ASSERT_TRUE(extension); | 27 ASSERT_TRUE(extension); |
28 | 28 |
29 ExtensionToolbarModel* toolbar_model = | |
30 ExtensionToolbarModel::Get(browser()->profile()); | |
31 | |
32 // Shouldn't be initially granted based on activeTab. | 29 // Shouldn't be initially granted based on activeTab. |
33 { | 30 { |
34 ResultCatcher catcher; | 31 ResultCatcher catcher; |
35 ui_test_utils::NavigateToURL( | 32 ui_test_utils::NavigateToURL( |
36 browser(), | 33 browser(), |
37 embedded_test_server()->GetURL( | 34 embedded_test_server()->GetURL( |
38 "/extensions/api_test/active_tab/page.html")); | 35 "/extensions/api_test/active_tab/page.html")); |
39 EXPECT_TRUE(catcher.GetNextResult()) << message_; | 36 EXPECT_TRUE(catcher.GetNextResult()) << message_; |
40 } | 37 } |
41 | 38 |
42 // Granting to the extension should give it access to page.html. | 39 // Granting to the extension should give it access to page.html. |
43 { | 40 { |
44 ResultCatcher catcher; | 41 ResultCatcher catcher; |
45 toolbar_model->ExecuteBrowserAction(extension, browser(), NULL, true); | 42 ExtensionActionAPI::Get(browser()->profile())->ExecuteExtensionAction( |
| 43 extension, browser(), true); |
46 EXPECT_TRUE(catcher.GetNextResult()) << message_; | 44 EXPECT_TRUE(catcher.GetNextResult()) << message_; |
47 } | 45 } |
48 | 46 |
49 // Changing page should go back to it not having access. | 47 // Changing page should go back to it not having access. |
50 { | 48 { |
51 ResultCatcher catcher; | 49 ResultCatcher catcher; |
52 ui_test_utils::NavigateToURL( | 50 ui_test_utils::NavigateToURL( |
53 browser(), | 51 browser(), |
54 embedded_test_server()->GetURL( | 52 embedded_test_server()->GetURL( |
55 "/extensions/api_test/active_tab/final_page.html")); | 53 "/extensions/api_test/active_tab/final_page.html")); |
56 EXPECT_TRUE(catcher.GetNextResult()) << message_; | 54 EXPECT_TRUE(catcher.GetNextResult()) << message_; |
57 } | 55 } |
58 } | 56 } |
59 | 57 |
60 } // namespace | 58 } // namespace |
61 } // namespace extensions | 59 } // namespace extensions |
OLD | NEW |