| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 9 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 10 #include "chrome/browser/extensions/browser_action_test_util.h" | 10 #include "chrome/browser/extensions/browser_action_test_util.h" |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 ASSERT_TRUE(extension) << message_; | 498 ASSERT_TRUE(extension) << message_; |
| 499 | 499 |
| 500 // Test that there is a browser action in the toolbar. | 500 // Test that there is a browser action in the toolbar. |
| 501 ASSERT_EQ(1, GetBrowserActionsBar()->NumberOfBrowserActions()); | 501 ASSERT_EQ(1, GetBrowserActionsBar()->NumberOfBrowserActions()); |
| 502 | 502 |
| 503 // Open an incognito window and test that the browser action isn't there by | 503 // Open an incognito window and test that the browser action isn't there by |
| 504 // default. | 504 // default. |
| 505 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); | 505 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); |
| 506 base::RunLoop().RunUntilIdle(); // Wait for profile initialization. | 506 base::RunLoop().RunUntilIdle(); // Wait for profile initialization. |
| 507 Browser* incognito_browser = | 507 Browser* incognito_browser = |
| 508 new Browser(Browser::CreateParams(incognito_profile, | 508 new Browser(Browser::CreateParams(incognito_profile)); |
| 509 browser()->host_desktop_type())); | |
| 510 | 509 |
| 511 ASSERT_EQ(0, | 510 ASSERT_EQ(0, |
| 512 BrowserActionTestUtil(incognito_browser).NumberOfBrowserActions()); | 511 BrowserActionTestUtil(incognito_browser).NumberOfBrowserActions()); |
| 513 | 512 |
| 514 // Now enable the extension in incognito mode, and test that the browser | 513 // Now enable the extension in incognito mode, and test that the browser |
| 515 // action shows up. | 514 // action shows up. |
| 516 // SetIsIncognitoEnabled() requires a reload of the extension, so we have to | 515 // SetIsIncognitoEnabled() requires a reload of the extension, so we have to |
| 517 // wait for it. | 516 // wait for it. |
| 518 TestExtensionRegistryObserver registry_observer( | 517 TestExtensionRegistryObserver registry_observer( |
| 519 ExtensionRegistry::Get(profile()), extension->id()); | 518 ExtensionRegistry::Get(profile()), extension->id()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 533 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, IncognitoSplit) { | 532 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, IncognitoSplit) { |
| 534 ResultCatcher catcher; | 533 ResultCatcher catcher; |
| 535 const Extension* extension = LoadExtensionWithFlags( | 534 const Extension* extension = LoadExtensionWithFlags( |
| 536 test_data_dir_.AppendASCII("browser_action/split_mode"), | 535 test_data_dir_.AppendASCII("browser_action/split_mode"), |
| 537 kFlagEnableIncognito); | 536 kFlagEnableIncognito); |
| 538 ASSERT_TRUE(extension) << message_; | 537 ASSERT_TRUE(extension) << message_; |
| 539 | 538 |
| 540 // Open an incognito window. | 539 // Open an incognito window. |
| 541 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); | 540 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); |
| 542 Browser* incognito_browser = | 541 Browser* incognito_browser = |
| 543 new Browser(Browser::CreateParams(incognito_profile, | 542 new Browser(Browser::CreateParams(incognito_profile)); |
| 544 browser()->host_desktop_type())); | |
| 545 base::RunLoop().RunUntilIdle(); // Wait for profile initialization. | 543 base::RunLoop().RunUntilIdle(); // Wait for profile initialization. |
| 546 // Navigate just to have a tab in this window, otherwise wonky things happen. | 544 // Navigate just to have a tab in this window, otherwise wonky things happen. |
| 547 OpenURLOffTheRecord(browser()->profile(), GURL("about:blank")); | 545 OpenURLOffTheRecord(browser()->profile(), GURL("about:blank")); |
| 548 ASSERT_EQ(1, | 546 ASSERT_EQ(1, |
| 549 BrowserActionTestUtil(incognito_browser).NumberOfBrowserActions()); | 547 BrowserActionTestUtil(incognito_browser).NumberOfBrowserActions()); |
| 550 | 548 |
| 551 // A click in the regular profile should open a tab in the regular profile. | 549 // A click in the regular profile should open a tab in the regular profile. |
| 552 ExtensionActionAPI* extension_action_api = | 550 ExtensionActionAPI* extension_action_api = |
| 553 ExtensionActionAPI::Get(browser()->profile()); | 551 ExtensionActionAPI::Get(browser()->profile()); |
| 554 extension_action_api->ExecuteExtensionAction( | 552 extension_action_api->ExecuteExtensionAction( |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 std::string result; | 729 std::string result; |
| 732 EXPECT_TRUE( | 730 EXPECT_TRUE( |
| 733 content::ExecuteScriptAndExtractString(frame_host, script, &result)); | 731 content::ExecuteScriptAndExtractString(frame_host, script, &result)); |
| 734 EXPECT_EQ("DONE", result); | 732 EXPECT_EQ("DONE", result); |
| 735 | 733 |
| 736 EXPECT_TRUE(actions_bar->HidePopup()); | 734 EXPECT_TRUE(actions_bar->HidePopup()); |
| 737 } | 735 } |
| 738 | 736 |
| 739 } // namespace | 737 } // namespace |
| 740 } // namespace extensions | 738 } // namespace extensions |
| OLD | NEW |