Chromium Code Reviews| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "chrome/browser/ui/browser.h" | 6 #include "chrome/browser/ui/browser.h" |
| 7 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 7 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 9 #include "chrome/test/base/in_process_browser_test.h" | 9 #include "chrome/test/base/in_process_browser_test.h" |
| 10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
| 11 #include "content/public/browser/navigation_controller.h" | 11 #include "content/public/browser/navigation_controller.h" |
| 12 #include "content/public/browser/navigation_entry.h" | 12 #include "content/public/browser/navigation_entry.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 #if defined(OS_CHROMEOS) | |
| 18 #include "chrome/browser/browser_process.h" | |
| 19 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" | |
| 20 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | |
| 21 #include "chrome/browser/chromeos/policy/stub_enterprise_install_attributes.h" | |
| 22 #include "components/policy/core/common/mock_configuration_policy_provider.h" | |
| 23 #include "components/policy/core/common/policy_types.h" | |
| 24 #endif | |
| 25 | |
| 17 namespace content { | 26 namespace content { |
| 18 | 27 |
| 19 class ChromeContentBrowserClientBrowserTest : public InProcessBrowserTest { | 28 class ChromeContentBrowserClientBrowserTest : public InProcessBrowserTest { |
| 20 public: | 29 public: |
| 21 // Returns the last committed navigation entry of the first tab. May be NULL | 30 // Returns the last committed navigation entry of the first tab. May be NULL |
| 22 // if there is no such entry. | 31 // if there is no such entry. |
| 23 NavigationEntry* GetLastCommittedEntry() { | 32 NavigationEntry* GetLastCommittedEntry() { |
| 24 return browser()->tab_strip_model()->GetWebContentsAt(0)-> | 33 return browser()->tab_strip_model()->GetWebContentsAt(0)-> |
| 25 GetController().GetLastCommittedEntry(); | 34 GetController().GetLastCommittedEntry(); |
| 26 } | 35 } |
| 27 | 36 |
| 28 #if defined(OS_CHROMEOS) | 37 #if defined(OS_CHROMEOS) |
| 29 void SetUpCommandLine(base::CommandLine* command_line) override { | 38 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 30 command_line->AppendSwitch(switches::kDisableAboutInSettings); | 39 command_line->AppendSwitch(switches::kDisableAboutInSettings); |
| 31 } | 40 } |
| 41 | |
| 42 protected: | |
| 43 void SetUpInProcessBrowserTestFixture() override { | |
| 44 // Set up fake install attributes. | |
| 45 scoped_ptr<policy::StubEnterpriseInstallAttributes> attributes( | |
| 46 new policy::StubEnterpriseInstallAttributes()); | |
| 47 attributes->SetDomain("example.com"); | |
| 48 attributes->SetRegistrationUser("user@example.com"); | |
| 49 policy::BrowserPolicyConnectorChromeOS::SetInstallAttributesForTesting( | |
| 50 attributes.release()); | |
| 51 } | |
| 32 #endif | 52 #endif |
| 33 }; | 53 }; |
| 34 | 54 |
| 35 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, | 55 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, |
| 36 UberURLHandler_SettingsPage) { | 56 UberURLHandler_SettingsPage) { |
| 37 const GURL url_short("chrome://settings/"); | 57 const GURL url_short("chrome://settings/"); |
| 38 const GURL url_long("chrome://chrome/settings/"); | 58 const GURL url_long("chrome://chrome/settings/"); |
| 39 | 59 |
| 40 ui_test_utils::NavigateToURL(browser(), url_short); | 60 ui_test_utils::NavigateToURL(browser(), url_short); |
| 41 NavigationEntry* entry = GetLastCommittedEntry(); | 61 NavigationEntry* entry = GetLastCommittedEntry(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 const GURL url(test_server()->GetURL("files/title1.html")); | 113 const GURL url(test_server()->GetURL("files/title1.html")); |
| 94 | 114 |
| 95 ui_test_utils::NavigateToURL(browser(), url); | 115 ui_test_utils::NavigateToURL(browser(), url); |
| 96 NavigationEntry* entry = GetLastCommittedEntry(); | 116 NavigationEntry* entry = GetLastCommittedEntry(); |
| 97 | 117 |
| 98 ASSERT_TRUE(entry != NULL); | 118 ASSERT_TRUE(entry != NULL); |
| 99 EXPECT_EQ(url, entry->GetURL()); | 119 EXPECT_EQ(url, entry->GetURL()); |
| 100 EXPECT_EQ(url, entry->GetVirtualURL()); | 120 EXPECT_EQ(url, entry->GetVirtualURL()); |
| 101 } | 121 } |
| 102 | 122 |
| 123 #if defined(OS_CHROMEOS) | |
| 124 // Test that the disable Easter Egg switch is appended if Chrome OS and | |
| 125 // the device is enterprise enrolled. | |
| 126 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, | |
| 127 ShouldDisableEasterEgg) { | |
| 128 const base::CommandLine& browser_command_line = | |
| 129 *base::CommandLine::ForCurrentProcess(); | |
| 130 | |
| 131 policy::BrowserPolicyConnectorChromeOS* connector = | |
| 132 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | |
| 133 bool is_enterprise_managed = connector->IsEnterpriseManaged(); | |
| 134 | |
| 135 EXPECT_TRUE(is_enterprise_managed); | |
| 136 EXPECT_TRUE(browser_command_line.HasSwitch( | |
|
Andrew T Wilson (Slow)
2015/03/13 13:44:57
This will fail, because you aren't setting the swi
edwardjung
2015/03/13 16:09:06
Okay understood, so how do I go about getting the
Andrew T Wilson (Slow)
2015/03/13 16:52:27
Great question. I don't write many tests that invo
edwardjung
2015/03/16 13:30:59
I've moved this test to errorpage_browsertests sin
| |
| 137 switches::kDisableDinosaurEasterEgg)); | |
| 138 } | |
| 139 #endif | |
| 140 | |
| 103 } // namespace content | 141 } // namespace content |
| OLD | NEW |