Index: chrome/browser/ui/webui/policy_ui_browsertest.cc |
diff --git a/chrome/browser/ui/webui/policy_ui_browsertest.cc b/chrome/browser/ui/webui/policy_ui_browsertest.cc |
index b7ae8a166d84317a718e80f13e59083c0c474126..6d7b49f1ea5bb574fb1889855205b4f8a49f6316 100644 |
--- a/chrome/browser/ui/webui/policy_ui_browsertest.cc |
+++ b/chrome/browser/ui/webui/policy_ui_browsertest.cc |
@@ -5,6 +5,7 @@ |
#include <vector> |
#include "base/callback.h" |
+#include "base/command_line.h" |
#include "base/files/scoped_temp_dir.h" |
#include "base/json/json_reader.h" |
#include "base/run_loop.h" |
@@ -14,6 +15,7 @@ |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/tabs/tab_strip_model.h" |
+#include "chrome/common/chrome_switches.h" |
#include "chrome/common/url_constants.h" |
#include "chrome/test/base/in_process_browser_test.h" |
#include "chrome/test/base/ui_test_utils.h" |
@@ -38,6 +40,16 @@ using testing::_; |
namespace { |
+struct UrlForFlag { |
bartfab (slow)
2015/09/23 17:17:13
Nit: This is nifty but a bit over-engineered. A Bo
fhorschig
2015/09/25 08:27:15
Done.
|
+ bool has_flag; |
+ const char* url; |
+}; |
+ |
+const UrlForFlag kUrlsForFlags[] = { |
+ { true, chrome::kChromeUIPolicyInternalsURL}, |
bartfab (slow)
2015/09/23 17:17:13
Nit: s/}/ }/
fhorschig
2015/09/25 08:27:15
Done.
|
+ { false, chrome::kChromeUIPolicyURL} |
bartfab (slow)
2015/09/23 17:17:13
Nit: s/}/ }/
fhorschig
2015/09/25 08:27:15
Done.
|
+}; |
+ |
std::vector<std::string> PopulateExpectedPolicy( |
const std::string& name, |
const std::string& value, |
@@ -88,11 +100,18 @@ std::vector<std::string> PopulateExpectedPolicy( |
} // namespace |
-class PolicyUITest : public InProcessBrowserTest { |
+class PolicyUITest |
+ : public InProcessBrowserTest, |
+ public testing::WithParamInterface<UrlForFlag> { |
public: |
PolicyUITest(); |
~PolicyUITest() override; |
+ // InProcessBrowserTest implementation. |
bartfab (slow)
2015/09/23 17:17:13
Nit: The new style is simply // InProcessBrowserTe
fhorschig
2015/09/25 08:27:15
Done.
|
+ void SetUpCommandLine(base::CommandLine* command_line) override; |
+ |
+ const char* url() const { return test_condition.url; } |
bartfab (slow)
2015/09/23 17:17:13
Nit: Always pass around URLs as GURL instances.
fhorschig
2015/09/25 08:27:15
Done.
|
+ |
protected: |
// InProcessBrowserTest implementation. |
void SetUpInProcessBrowserTestFixture() override; |
@@ -105,15 +124,23 @@ class PolicyUITest : public InProcessBrowserTest { |
policy::MockConfigurationPolicyProvider provider_; |
private: |
+ UrlForFlag test_condition; |
bartfab (slow)
2015/09/23 17:17:13
Nit 1: Add _ suffix to member name.
Nit 2: Add bla
fhorschig
2015/09/25 08:27:15
Done.
|
DISALLOW_COPY_AND_ASSIGN(PolicyUITest); |
}; |
PolicyUITest::PolicyUITest() { |
+ test_condition = GetParam(); |
} |
PolicyUITest::~PolicyUITest() { |
} |
+void PolicyUITest::SetUpCommandLine(base::CommandLine* command_line) { |
+ InProcessBrowserTest::SetUpCommandLine(command_line); |
+ if (test_condition.has_flag) |
+ command_line->AppendSwitch(switches::kEnableMaterialDesignPolicyPage); |
+} |
+ |
void PolicyUITest::SetUpInProcessBrowserTestFixture() { |
EXPECT_CALL(provider_, IsInitializationComplete(_)) |
.WillRepeatedly(Return(true)); |
@@ -128,7 +155,7 @@ void PolicyUITest::UpdateProviderPolicy(const policy::PolicyMap& policy) { |
void PolicyUITest::VerifyPolicies( |
const std::vector<std::vector<std::string> >& expected_policies) { |
- ui_test_utils::NavigateToURL(browser(), GURL("chrome://policy")); |
+ ui_test_utils::NavigateToURL(browser(), GURL(url())); |
// Retrieve the text contents of the policy table cells for all policies. |
const std::string javascript = |
@@ -176,7 +203,7 @@ void PolicyUITest::VerifyPolicies( |
} |
} |
-IN_PROC_BROWSER_TEST_F(PolicyUITest, SendPolicyNames) { |
+IN_PROC_BROWSER_TEST_P(PolicyUITest, SendPolicyNames) { |
// Verifies that the names of known policies are sent to the UI and processed |
// there correctly by checking that the policy table contains all policies in |
// the correct order. |
@@ -199,7 +226,7 @@ IN_PROC_BROWSER_TEST_F(PolicyUITest, SendPolicyNames) { |
VerifyPolicies(expected_policies); |
} |
-IN_PROC_BROWSER_TEST_F(PolicyUITest, SendPolicyValues) { |
+IN_PROC_BROWSER_TEST_P(PolicyUITest, SendPolicyValues) { |
// Verifies that policy values are sent to the UI and processed there |
// correctly by setting the values of four known and one unknown policy and |
// checking that the policy table contains the policy names, values and |
@@ -287,8 +314,8 @@ IN_PROC_BROWSER_TEST_F(PolicyUITest, SendPolicyValues) { |
VerifyPolicies(expected_policies); |
} |
-IN_PROC_BROWSER_TEST_F(PolicyUITest, ExtensionLoadAndSendPolicy) { |
- ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIPolicyURL)); |
+IN_PROC_BROWSER_TEST_P(PolicyUITest, ExtensionLoadAndSendPolicy) { |
+ ui_test_utils::NavigateToURL(browser(), GURL(url())); |
base::ScopedTempDir temp_dir_; |
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
@@ -340,3 +367,11 @@ IN_PROC_BROWSER_TEST_F(PolicyUITest, ExtensionLoadAndSendPolicy) { |
// Verify if policy UI includes policy that extension have. |
VerifyPolicies(expected_policies); |
} |
+ |
+INSTANTIATE_TEST_CASE_P(WithFlagPolicyUITest, |
+ PolicyUITest, |
+ testing::Values(kUrlsForFlags[0])); |
+ |
+INSTANTIATE_TEST_CASE_P(NoFlagPolicyUITest, |
+ PolicyUITest, |
+ testing::Values(kUrlsForFlags[1])); |