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

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

Issue 10915002: Convert the history pyauto tests to a browser_tests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: make DEPS clearer/cleaner after discussion with erikwright Created 8 years, 3 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 | Annotate | Revision Log
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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
11 #include "base/string16.h" 11 #include "base/string16.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "base/test/test_file_util.h" 13 #include "base/test/test_file_util.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/autocomplete/autocomplete_controller.h" 15 #include "chrome/browser/autocomplete/autocomplete_controller.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/history/history.h"
18 #include "chrome/browser/history/history_service_factory.h"
19 #include "chrome/browser/infobars/infobar_tab_helper.h" 17 #include "chrome/browser/infobars/infobar_tab_helper.h"
20 #include "chrome/browser/net/url_request_mock_util.h" 18 #include "chrome/browser/net/url_request_mock_util.h"
21 #include "chrome/browser/policy/browser_policy_connector.h" 19 #include "chrome/browser/policy/browser_policy_connector.h"
22 #include "chrome/browser/policy/mock_configuration_policy_provider.h" 20 #include "chrome/browser/policy/mock_configuration_policy_provider.h"
23 #include "chrome/browser/policy/policy_map.h" 21 #include "chrome/browser/policy/policy_map.h"
24 #include "chrome/browser/prefs/pref_service.h" 22 #include "chrome/browser/prefs/pref_service.h"
25 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/net/url_request_mock_util.h" 24 #include "chrome/browser/net/url_request_mock_util.h"
27 #include "chrome/browser/search_engines/template_url.h" 25 #include "chrome/browser/search_engines/template_url.h"
28 #include "chrome/browser/search_engines/template_url_service.h" 26 #include "chrome/browser/search_engines/template_url_service.h"
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 // Verifies that browsing history is not saved. 355 // Verifies that browsing history is not saved.
358 PolicyMap policies; 356 PolicyMap policies;
359 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY, 357 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY,
360 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); 358 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true));
361 provider_.UpdateChromePolicy(policies); 359 provider_.UpdateChromePolicy(policies);
362 GURL url = ui_test_utils::GetTestUrl( 360 GURL url = ui_test_utils::GetTestUrl(
363 FilePath(FilePath::kCurrentDirectory), 361 FilePath(FilePath::kCurrentDirectory),
364 FilePath(FILE_PATH_LITERAL("empty.html"))); 362 FilePath(FILE_PATH_LITERAL("empty.html")));
365 ui_test_utils::NavigateToURL(browser(), url); 363 ui_test_utils::NavigateToURL(browser(), url);
366 // Verify that the navigation wasn't saved in the history. 364 // Verify that the navigation wasn't saved in the history.
367 HistoryService* history = HistoryServiceFactory::GetForProfile( 365 ui_test_utils::HistoryEnumerator enumerator1(browser()->profile());
368 browser()->profile(), Profile::EXPLICIT_ACCESS);
369 ASSERT_TRUE(history);
370 ui_test_utils::HistoryEnumerator enumerator1(history);
371 EXPECT_EQ(0u, enumerator1.urls().size()); 366 EXPECT_EQ(0u, enumerator1.urls().size());
372 367
373 // Now flip the policy and try again. 368 // Now flip the policy and try again.
374 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY, 369 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY,
375 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false)); 370 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false));
376 provider_.UpdateChromePolicy(policies); 371 provider_.UpdateChromePolicy(policies);
377 ui_test_utils::NavigateToURL(browser(), url); 372 ui_test_utils::NavigateToURL(browser(), url);
378 // Verify that the navigation was saved in the history. 373 // Verify that the navigation was saved in the history.
379 ui_test_utils::HistoryEnumerator enumerator2(history); 374 ui_test_utils::HistoryEnumerator enumerator2(browser()->profile());
380 ASSERT_EQ(1u, enumerator2.urls().size()); 375 ASSERT_EQ(1u, enumerator2.urls().size());
381 EXPECT_EQ(url, enumerator2.urls()[0]); 376 EXPECT_EQ(url, enumerator2.urls()[0]);
382 } 377 }
383 378
384 IN_PROC_BROWSER_TEST_F(PolicyTest, TranslateEnabled) { 379 IN_PROC_BROWSER_TEST_F(PolicyTest, TranslateEnabled) {
385 // Verifies that translate can be forced enabled or disabled by policy. 380 // Verifies that translate can be forced enabled or disabled by policy.
386 381
387 // Get the |infobar_helper|, and verify that there are no infobars on startup. 382 // Get the |infobar_helper|, and verify that there are no infobars on startup.
388 content::WebContents* contents = chrome::GetActiveWebContents(browser()); 383 content::WebContents* contents = chrome::GetActiveWebContents(browser());
389 ASSERT_TRUE(contents); 384 ASSERT_TRUE(contents);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY, 474 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY,
480 POLICY_SCOPE_USER, whitelist.DeepCopy()); 475 POLICY_SCOPE_USER, whitelist.DeepCopy());
481 provider_.UpdateChromePolicy(policies); 476 provider_.UpdateChromePolicy(policies);
482 CheckCanOpenURL(browser(), kAAA); 477 CheckCanOpenURL(browser(), kAAA);
483 CheckURLIsBlocked(browser(), kBBB); 478 CheckURLIsBlocked(browser(), kBBB);
484 CheckCanOpenURL(browser(), kSUB_BBB); 479 CheckCanOpenURL(browser(), kSUB_BBB);
485 CheckCanOpenURL(browser(), kBBB_PATH); 480 CheckCanOpenURL(browser(), kBBB_PATH);
486 } 481 }
487 482
488 } // namespace policy 483 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/history/history_browsertest.cc ('k') | chrome/browser/ui/find_bar/find_bar_host_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698