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

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 2671743002: Separate state of basic and advanced tab in CBD dialog (Closed)
Patch Set: add test for policy Created 3 years, 9 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 unified diff | Download patch
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 #include "chrome/common/chrome_paths.h" 88 #include "chrome/common/chrome_paths.h"
89 #include "chrome/common/chrome_switches.h" 89 #include "chrome/common/chrome_switches.h"
90 #include "chrome/common/extensions/extension_constants.h" 90 #include "chrome/common/extensions/extension_constants.h"
91 #include "chrome/common/pref_names.h" 91 #include "chrome/common/pref_names.h"
92 #include "chrome/common/url_constants.h" 92 #include "chrome/common/url_constants.h"
93 #include "chrome/grit/generated_resources.h" 93 #include "chrome/grit/generated_resources.h"
94 #include "chrome/test/base/in_process_browser_test.h" 94 #include "chrome/test/base/in_process_browser_test.h"
95 #include "chrome/test/base/search_test_utils.h" 95 #include "chrome/test/base/search_test_utils.h"
96 #include "chrome/test/base/ui_test_utils.h" 96 #include "chrome/test/base/ui_test_utils.h"
97 #include "components/bookmarks/common/bookmark_pref_names.h" 97 #include "components/bookmarks/common/bookmark_pref_names.h"
98 #include "components/browsing_data/core/pref_names.h"
98 #include "components/component_updater/component_updater_service.h" 99 #include "components/component_updater/component_updater_service.h"
99 #include "components/content_settings/core/common/content_settings.h" 100 #include "components/content_settings/core/common/content_settings.h"
100 #include "components/content_settings/core/common/content_settings_pattern.h" 101 #include "components/content_settings/core/common/content_settings_pattern.h"
101 #include "components/content_settings/core/common/pref_names.h" 102 #include "components/content_settings/core/common/pref_names.h"
102 #include "components/infobars/core/infobar.h" 103 #include "components/infobars/core/infobar.h"
103 #include "components/omnibox/browser/autocomplete_controller.h" 104 #include "components/omnibox/browser/autocomplete_controller.h"
104 #include "components/omnibox/browser/omnibox_edit_model.h" 105 #include "components/omnibox/browser/omnibox_edit_model.h"
105 #include "components/omnibox/browser/omnibox_view.h" 106 #include "components/omnibox/browser/omnibox_view.h"
106 #include "components/policy/core/browser/browser_policy_connector.h" 107 #include "components/policy/core/browser/browser_policy_connector.h"
107 #include "components/policy/core/common/external_data_fetcher.h" 108 #include "components/policy/core/common/external_data_fetcher.h"
(...skipping 2108 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 2217 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
2217 base::MakeUnique<base::FundamentalValue>(false), nullptr); 2218 base::MakeUnique<base::FundamentalValue>(false), nullptr);
2218 UpdateProviderPolicy(policies); 2219 UpdateProviderPolicy(policies);
2219 ui_test_utils::NavigateToURL(browser(), url); 2220 ui_test_utils::NavigateToURL(browser(), url);
2220 // Verify that the navigation was saved in the history. 2221 // Verify that the navigation was saved in the history.
2221 ui_test_utils::HistoryEnumerator enumerator2(browser()->profile()); 2222 ui_test_utils::HistoryEnumerator enumerator2(browser()->profile());
2222 ASSERT_EQ(1u, enumerator2.urls().size()); 2223 ASSERT_EQ(1u, enumerator2.urls().size());
2223 EXPECT_EQ(url, enumerator2.urls()[0]); 2224 EXPECT_EQ(url, enumerator2.urls()[0]);
2224 } 2225 }
2225 2226
2227 IN_PROC_BROWSER_TEST_F(PolicyTest, DeletingBrowsingHistoryDisabled) {
2228 // Verifies that deleting the browsing history can be disabled.
2229
2230 PrefService* prefs = browser()->profile()->GetPrefs();
2231 EXPECT_FALSE(prefs->IsManagedPreference(prefs::kAllowDeletingBrowserHistory));
2232 EXPECT_TRUE(prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory));
2233
2234 EXPECT_TRUE(prefs->GetBoolean(browsing_data::prefs::kDeleteBrowsingHistory));
2235 EXPECT_TRUE(prefs->GetBoolean(browsing_data::prefs::kDeleteDownloadHistory));
2236 EXPECT_TRUE(
2237 prefs->GetBoolean(browsing_data::prefs::kDeleteBrowsingHistoryBasic));
2238
2239 PolicyMap policies;
2240 policies.Set(key::kAllowDeletingBrowserHistory, POLICY_LEVEL_MANDATORY,
2241 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
2242 base::MakeUnique<base::FundamentalValue>(true), nullptr);
2243 UpdateProviderPolicy(policies);
2244 EXPECT_TRUE(prefs->IsManagedPreference(prefs::kAllowDeletingBrowserHistory));
2245 EXPECT_TRUE(prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory));
2246
2247 EXPECT_TRUE(prefs->GetBoolean(browsing_data::prefs::kDeleteBrowsingHistory));
2248 EXPECT_TRUE(prefs->GetBoolean(browsing_data::prefs::kDeleteDownloadHistory));
2249 EXPECT_TRUE(
2250 prefs->GetBoolean(browsing_data::prefs::kDeleteBrowsingHistoryBasic));
2251
2252 policies.Set(key::kAllowDeletingBrowserHistory, POLICY_LEVEL_MANDATORY,
2253 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
2254 base::MakeUnique<base::FundamentalValue>(false), nullptr);
2255 UpdateProviderPolicy(policies);
2256 EXPECT_TRUE(prefs->IsManagedPreference(prefs::kAllowDeletingBrowserHistory));
2257 EXPECT_FALSE(prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory));
2258
2259 EXPECT_FALSE(prefs->GetBoolean(browsing_data::prefs::kDeleteBrowsingHistory));
2260 EXPECT_FALSE(prefs->GetBoolean(browsing_data::prefs::kDeleteDownloadHistory));
2261 EXPECT_FALSE(
2262 prefs->GetBoolean(browsing_data::prefs::kDeleteBrowsingHistoryBasic));
2263
2264 policies.Clear();
2265 UpdateProviderPolicy(policies);
2266 EXPECT_FALSE(prefs->IsManagedPreference(prefs::kAllowDeletingBrowserHistory));
2267 EXPECT_TRUE(prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory));
2268
2269 EXPECT_TRUE(prefs->GetBoolean(browsing_data::prefs::kDeleteBrowsingHistory));
2270 EXPECT_TRUE(prefs->GetBoolean(browsing_data::prefs::kDeleteDownloadHistory));
2271 EXPECT_TRUE(
2272 prefs->GetBoolean(browsing_data::prefs::kDeleteBrowsingHistoryBasic));
2273 }
2274
2226 // TODO(port): Test corresponding bubble translate UX: http://crbug.com/383235 2275 // TODO(port): Test corresponding bubble translate UX: http://crbug.com/383235
2227 #if !defined(USE_AURA) 2276 #if !defined(USE_AURA)
2228 // http://crbug.com/241691 PolicyTest.TranslateEnabled is failing regularly. 2277 // http://crbug.com/241691 PolicyTest.TranslateEnabled is failing regularly.
2229 IN_PROC_BROWSER_TEST_F(PolicyTest, DISABLED_TranslateEnabled) { 2278 IN_PROC_BROWSER_TEST_F(PolicyTest, DISABLED_TranslateEnabled) {
2230 // Verifies that translate can be forced enabled or disabled by policy. 2279 // Verifies that translate can be forced enabled or disabled by policy.
2231 2280
2232 // Get the InfoBarService, and verify that there are no infobars on startup. 2281 // Get the InfoBarService, and verify that there are no infobars on startup.
2233 content::WebContents* contents = 2282 content::WebContents* contents =
2234 browser()->tab_strip_model()->GetActiveWebContents(); 2283 browser()->tab_strip_model()->GetActiveWebContents();
2235 ASSERT_TRUE(contents); 2284 ASSERT_TRUE(contents);
(...skipping 2177 matching lines...) Expand 10 before | Expand all | Expand 10 after
4413 4462
4414 SetEmptyPolicy(); 4463 SetEmptyPolicy();
4415 // Policy not set. 4464 // Policy not set.
4416 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); 4465 CheckSystemTimezoneAutomaticDetectionPolicyUnset();
4417 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); 4466 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false));
4418 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); 4467 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests());
4419 } 4468 }
4420 #endif // defined(OS_CHROMEOS) 4469 #endif // defined(OS_CHROMEOS)
4421 4470
4422 } // namespace policy 4471 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698