| 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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 ASSERT_TRUE(extension) << message_; | 499 ASSERT_TRUE(extension) << message_; |
| 500 | 500 |
| 501 // Test that there is a browser action in the toolbar. | 501 // Test that there is a browser action in the toolbar. |
| 502 ASSERT_EQ(1, GetBrowserActionsBar()->NumberOfBrowserActions()); | 502 ASSERT_EQ(1, GetBrowserActionsBar()->NumberOfBrowserActions()); |
| 503 | 503 |
| 504 // Open an incognito window and test that the browser action isn't there by | 504 // Open an incognito window and test that the browser action isn't there by |
| 505 // default. | 505 // default. |
| 506 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); | 506 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); |
| 507 base::RunLoop().RunUntilIdle(); // Wait for profile initialization. | 507 base::RunLoop().RunUntilIdle(); // Wait for profile initialization. |
| 508 Browser* incognito_browser = | 508 Browser* incognito_browser = |
| 509 new Browser(Browser::CreateParams(incognito_profile, | 509 new Browser(Browser::CreateParams(incognito_profile)); |
| 510 browser()->host_desktop_type())); | |
| 511 | 510 |
| 512 ASSERT_EQ(0, | 511 ASSERT_EQ(0, |
| 513 BrowserActionTestUtil(incognito_browser).NumberOfBrowserActions()); | 512 BrowserActionTestUtil(incognito_browser).NumberOfBrowserActions()); |
| 514 | 513 |
| 515 // Now enable the extension in incognito mode, and test that the browser | 514 // Now enable the extension in incognito mode, and test that the browser |
| 516 // action shows up. | 515 // action shows up. |
| 517 // SetIsIncognitoEnabled() requires a reload of the extension, so we have to | 516 // SetIsIncognitoEnabled() requires a reload of the extension, so we have to |
| 518 // wait for it. | 517 // wait for it. |
| 519 TestExtensionRegistryObserver registry_observer( | 518 TestExtensionRegistryObserver registry_observer( |
| 520 ExtensionRegistry::Get(profile()), extension->id()); | 519 ExtensionRegistry::Get(profile()), extension->id()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 534 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, IncognitoSplit) { | 533 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, IncognitoSplit) { |
| 535 ResultCatcher catcher; | 534 ResultCatcher catcher; |
| 536 const Extension* extension = LoadExtensionWithFlags( | 535 const Extension* extension = LoadExtensionWithFlags( |
| 537 test_data_dir_.AppendASCII("browser_action/split_mode"), | 536 test_data_dir_.AppendASCII("browser_action/split_mode"), |
| 538 kFlagEnableIncognito); | 537 kFlagEnableIncognito); |
| 539 ASSERT_TRUE(extension) << message_; | 538 ASSERT_TRUE(extension) << message_; |
| 540 | 539 |
| 541 // Open an incognito window. | 540 // Open an incognito window. |
| 542 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); | 541 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); |
| 543 Browser* incognito_browser = | 542 Browser* incognito_browser = |
| 544 new Browser(Browser::CreateParams(incognito_profile, | 543 new Browser(Browser::CreateParams(incognito_profile)); |
| 545 browser()->host_desktop_type())); | |
| 546 base::RunLoop().RunUntilIdle(); // Wait for profile initialization. | 544 base::RunLoop().RunUntilIdle(); // Wait for profile initialization. |
| 547 // Navigate just to have a tab in this window, otherwise wonky things happen. | 545 // Navigate just to have a tab in this window, otherwise wonky things happen. |
| 548 OpenURLOffTheRecord(browser()->profile(), GURL("about:blank")); | 546 OpenURLOffTheRecord(browser()->profile(), GURL("about:blank")); |
| 549 ASSERT_EQ(1, | 547 ASSERT_EQ(1, |
| 550 BrowserActionTestUtil(incognito_browser).NumberOfBrowserActions()); | 548 BrowserActionTestUtil(incognito_browser).NumberOfBrowserActions()); |
| 551 | 549 |
| 552 // A click in the regular profile should open a tab in the regular profile. | 550 // A click in the regular profile should open a tab in the regular profile. |
| 553 ExtensionActionAPI* extension_action_api = | 551 ExtensionActionAPI* extension_action_api = |
| 554 ExtensionActionAPI::Get(browser()->profile()); | 552 ExtensionActionAPI::Get(browser()->profile()); |
| 555 extension_action_api->ExecuteExtensionAction( | 553 extension_action_api->ExecuteExtensionAction( |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 gfx::Image first_icon = GetBrowserActionsBar()->GetIcon(0); | 743 gfx::Image first_icon = GetBrowserActionsBar()->GetIcon(0); |
| 746 ResultCatcher catcher; | 744 ResultCatcher catcher; |
| 747 ready_listener.Reply(std::string()); | 745 ready_listener.Reply(std::string()); |
| 748 EXPECT_TRUE(catcher.GetNextResult()); | 746 EXPECT_TRUE(catcher.GetNextResult()); |
| 749 gfx::Image next_icon = GetBrowserActionsBar()->GetIcon(0); | 747 gfx::Image next_icon = GetBrowserActionsBar()->GetIcon(0); |
| 750 EXPECT_FALSE(gfx::test::AreImagesEqual(first_icon, next_icon)); | 748 EXPECT_FALSE(gfx::test::AreImagesEqual(first_icon, next_icon)); |
| 751 } | 749 } |
| 752 | 750 |
| 753 } // namespace | 751 } // namespace |
| 754 } // namespace extensions | 752 } // namespace extensions |
| OLD | NEW |