Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8558)

Unified Diff: chrome/browser/policy/policy_browsertest.cc

Issue 2913343002: Start removing deprecated Options UI code (Closed)
Patch Set: thestig@ review Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/policy_browsertest.cc
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index cfcd519ba6c47d294a638cb078f766bc7e6cd360..231febad39fe6588b1a0e0330251133c6ff77d8a 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -33,7 +33,6 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/test/scoped_feature_list.h"
#include "base/test/test_file_util.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread_restrictions.h"
@@ -89,7 +88,6 @@
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/location_bar/location_bar.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
-#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -4359,151 +4357,6 @@ IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcLocationServiceEnabled) {
}
}
-namespace {
-const char kTestUser1[] = "test1@domain.com";
-} // anonymous namespace
-
-class ChromeOSPolicyTest : public PolicyTest {
- public:
- ChromeOSPolicyTest() {}
-
- void SetUpCommandLine(base::CommandLine* command_line) override {
- PolicyTest::SetUpCommandLine(command_line);
- command_line->AppendSwitchASCII(chromeos::switches::kLoginUser,
- cryptohome_id1_.id());
- command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "hash");
- command_line->AppendSwitch(
- chromeos::switches::kAllowFailedPolicyFetchForTest);
- }
-
- protected:
- const AccountId test_account_id1_ = AccountId::FromUserEmail(kTestUser1);
- const cryptohome::Identification cryptohome_id1_ =
- cryptohome::Identification(test_account_id1_);
-
- // Logs in |account_id|.
- void LogIn(const AccountId& account_id, const std::string& user_id_hash) {
- user_manager::UserManager::Get()->UserLoggedIn(account_id, user_id_hash,
- false);
- base::RunLoop().RunUntilIdle();
- }
-
- void NavigateToUrl(const GURL& url) {
- ui_test_utils::NavigateToURL(browser(), url);
- base::RunLoop().RunUntilIdle();
- }
-
- void CheckSystemTimezoneAutomaticDetectionPolicyUnset() {
- PrefService* local_state = g_browser_process->local_state();
- EXPECT_FALSE(local_state->IsManagedPreference(
- prefs::kSystemTimezoneAutomaticDetectionPolicy));
- EXPECT_EQ(0, local_state->GetInteger(
- prefs::kSystemTimezoneAutomaticDetectionPolicy));
- }
-
- void SetAndTestSystemTimezoneAutomaticDetectionPolicy(int policy_value) {
- PolicyMap policies;
- policies.Set(key::kSystemTimezoneAutomaticDetection, POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
- base::MakeUnique<base::Value>(policy_value), nullptr);
- UpdateProviderPolicy(policies);
-
- PrefService* local_state = g_browser_process->local_state();
-
- EXPECT_TRUE(local_state->IsManagedPreference(
- prefs::kSystemTimezoneAutomaticDetectionPolicy));
- EXPECT_EQ(policy_value,
- local_state->GetInteger(
- prefs::kSystemTimezoneAutomaticDetectionPolicy));
- }
-
- void SetEmptyPolicy() { UpdateProviderPolicy(PolicyMap()); }
-
- bool CheckResolveTimezoneByGeolocation(bool checked, bool disabled) {
- checker.set_web_contents(
- browser()->tab_strip_model()->GetActiveWebContents());
- const std::string expression = base::StringPrintf(
- "(function () {\n"
- " var checkbox = "
- "document.getElementById('resolve-timezone-by-geolocation');\n"
- " if (!checkbox) {\n"
- " console.log('resolve-timezone-by-geolocation not found.');\n"
- " return false;\n"
- " }\n"
- " var expected_checked = %s;\n"
- " var expected_disabled = %s;\n"
- " var checked = checkbox.checked;\n"
- " var disabled = checkbox.disabled;\n"
- " if (checked != expected_checked)\n"
- " console.log('ERROR: expected_checked=' + expected_checked + ' != "
- "checked=' + checked);\n"
- "\n"
- " if (disabled != expected_disabled)\n"
- " console.log('ERROR: expected_disabled=' + expected_disabled + ' "
- "!= disabled=' + disabled);\n"
- "\n"
- " return (checked == expected_checked && disabled == "
- "expected_disabled);\n"
- "})()",
- checked ? "true" : "false", disabled ? "true" : "false");
- return checker.GetBool(expression);
- }
-
- private:
- chromeos::test::JSChecker checker;
-
- DISALLOW_COPY_AND_ASSIGN(ChromeOSPolicyTest);
-};
-
-IN_PROC_BROWSER_TEST_F(ChromeOSPolicyTest, SystemTimezoneAutomaticDetection) {
- base::test::ScopedFeatureList disable_md_settings;
- disable_md_settings.InitAndDisableFeature(features::kMaterialDesignSettings);
-
- ui_test_utils::NavigateToURL(browser(), GURL("chrome://settings"));
- chromeos::system::TimeZoneResolverManager* manager =
- g_browser_process->platform_part()->GetTimezoneResolverManager();
-
- // Policy not set.
- CheckSystemTimezoneAutomaticDetectionPolicyUnset();
- EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false));
- EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests());
-
- int policy_value = 0 /* USERS_DECIDE */;
- SetAndTestSystemTimezoneAutomaticDetectionPolicy(policy_value);
- EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false));
- EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests());
-
- policy_value = 1 /* DISABLED */;
- SetAndTestSystemTimezoneAutomaticDetectionPolicy(policy_value);
- EXPECT_TRUE(CheckResolveTimezoneByGeolocation(false, true));
- EXPECT_FALSE(manager->TimeZoneResolverShouldBeRunningForTests());
-
- policy_value = 2 /* IP_ONLY */;
- SetAndTestSystemTimezoneAutomaticDetectionPolicy(policy_value);
- EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, true));
- EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests());
-
- policy_value = 3 /* SEND_WIFI_ACCESS_POINTS */;
- SetAndTestSystemTimezoneAutomaticDetectionPolicy(policy_value);
- EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, true));
- EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests());
-
- policy_value = 4 /* SEND_ALL_LOCATION_INFO */;
- SetAndTestSystemTimezoneAutomaticDetectionPolicy(policy_value);
- EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, true));
- EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests());
-
- policy_value = 1 /* DISABLED */;
- SetAndTestSystemTimezoneAutomaticDetectionPolicy(policy_value);
- EXPECT_TRUE(CheckResolveTimezoneByGeolocation(false, true));
- EXPECT_FALSE(manager->TimeZoneResolverShouldBeRunningForTests());
-
- SetEmptyPolicy();
- // Policy not set.
- CheckSystemTimezoneAutomaticDetectionPolicyUnset();
- EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false));
- EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests());
-}
#endif // defined(OS_CHROMEOS)
class NetworkTimePolicyTest : public PolicyTest {

Powered by Google App Engine
This is Rietveld 408576698