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

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

Issue 660123003: Standardize usage of virtual/override/final in chrome/browser/policy/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 DISALLOW_COPY_AND_ASSIGN(TestAudioObserver); 503 DISALLOW_COPY_AND_ASSIGN(TestAudioObserver);
504 }; 504 };
505 #endif 505 #endif
506 506
507 // This class waits until either a load stops or the WebContents is destroyed. 507 // This class waits until either a load stops or the WebContents is destroyed.
508 class WebContentsLoadedOrDestroyedWatcher 508 class WebContentsLoadedOrDestroyedWatcher
509 : public content::WebContentsObserver { 509 : public content::WebContentsObserver {
510 public: 510 public:
511 explicit WebContentsLoadedOrDestroyedWatcher( 511 explicit WebContentsLoadedOrDestroyedWatcher(
512 content::WebContents* web_contents); 512 content::WebContents* web_contents);
513 virtual ~WebContentsLoadedOrDestroyedWatcher(); 513 ~WebContentsLoadedOrDestroyedWatcher() override;
514 514
515 // Waits until the WebContents's load is done or until it is destroyed. 515 // Waits until the WebContents's load is done or until it is destroyed.
516 void Wait(); 516 void Wait();
517 517
518 // Overridden WebContentsObserver methods. 518 // Overridden WebContentsObserver methods.
519 virtual void WebContentsDestroyed() override; 519 void WebContentsDestroyed() override;
520 virtual void DidStopLoading( 520 void DidStopLoading(content::RenderViewHost* render_view_host) override;
521 content::RenderViewHost* render_view_host) override;
522 521
523 private: 522 private:
524 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 523 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
525 524
526 DISALLOW_COPY_AND_ASSIGN(WebContentsLoadedOrDestroyedWatcher); 525 DISALLOW_COPY_AND_ASSIGN(WebContentsLoadedOrDestroyedWatcher);
527 }; 526 };
528 527
529 WebContentsLoadedOrDestroyedWatcher::WebContentsLoadedOrDestroyedWatcher( 528 WebContentsLoadedOrDestroyedWatcher::WebContentsLoadedOrDestroyedWatcher(
530 content::WebContents* web_contents) 529 content::WebContents* web_contents)
531 : content::WebContentsObserver(web_contents), 530 : content::WebContentsObserver(web_contents),
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 class PolicyTest : public InProcessBrowserTest { 596 class PolicyTest : public InProcessBrowserTest {
598 protected: 597 protected:
599 PolicyTest() {} 598 PolicyTest() {}
600 virtual ~PolicyTest() {} 599 virtual ~PolicyTest() {}
601 600
602 virtual void SetUp() override { 601 virtual void SetUp() override {
603 test_extension_cache_.reset(new extensions::ExtensionCacheFake()); 602 test_extension_cache_.reset(new extensions::ExtensionCacheFake());
604 InProcessBrowserTest::SetUp(); 603 InProcessBrowserTest::SetUp();
605 } 604 }
606 605
607 virtual void SetUpInProcessBrowserTestFixture() override { 606 void SetUpInProcessBrowserTestFixture() override {
608 CommandLine::ForCurrentProcess()->AppendSwitch("noerrdialogs"); 607 CommandLine::ForCurrentProcess()->AppendSwitch("noerrdialogs");
609 EXPECT_CALL(provider_, IsInitializationComplete(_)) 608 EXPECT_CALL(provider_, IsInitializationComplete(_))
610 .WillRepeatedly(Return(true)); 609 .WillRepeatedly(Return(true));
611 BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); 610 BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
612 } 611 }
613 612
614 virtual void SetUpOnMainThread() override { 613 void SetUpOnMainThread() override {
615 BrowserThread::PostTask( 614 BrowserThread::PostTask(
616 BrowserThread::IO, FROM_HERE, 615 BrowserThread::IO, FROM_HERE,
617 base::Bind(chrome_browser_net::SetUrlRequestMocksEnabled, true)); 616 base::Bind(chrome_browser_net::SetUrlRequestMocksEnabled, true));
618 if (extension_service()->updater()) { 617 if (extension_service()->updater()) {
619 extension_service()->updater()->SetExtensionCacheForTesting( 618 extension_service()->updater()->SetExtensionCacheForTesting(
620 test_extension_cache_.get()); 619 test_extension_cache_.get());
621 } 620 }
622 } 621 }
623 622
624 // Makes URLRequestMockHTTPJobs serve data from content::DIR_TEST_DATA 623 // Makes URLRequestMockHTTPJobs serve data from content::DIR_TEST_DATA
(...skipping 2168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2793 virtual ~RestoreOnStartupPolicyTest() {} 2792 virtual ~RestoreOnStartupPolicyTest() {}
2794 2793
2795 #if defined(OS_CHROMEOS) 2794 #if defined(OS_CHROMEOS)
2796 virtual void SetUpCommandLine(CommandLine* command_line) override { 2795 virtual void SetUpCommandLine(CommandLine* command_line) override {
2797 // TODO(nkostylev): Investigate if we can remove this switch. 2796 // TODO(nkostylev): Investigate if we can remove this switch.
2798 command_line->AppendSwitch(switches::kCreateBrowserOnStartupForTests); 2797 command_line->AppendSwitch(switches::kCreateBrowserOnStartupForTests);
2799 PolicyTest::SetUpCommandLine(command_line); 2798 PolicyTest::SetUpCommandLine(command_line);
2800 } 2799 }
2801 #endif 2800 #endif
2802 2801
2803 virtual void SetUpInProcessBrowserTestFixture() override { 2802 void SetUpInProcessBrowserTestFixture() override {
2804 PolicyTest::SetUpInProcessBrowserTestFixture(); 2803 PolicyTest::SetUpInProcessBrowserTestFixture();
2805 // Set early policies now, before the browser is created. 2804 // Set early policies now, before the browser is created.
2806 (this->*(GetParam()))(); 2805 (this->*(GetParam()))();
2807 2806
2808 // Remove the non-switch arguments, so that session restore kicks in for 2807 // Remove the non-switch arguments, so that session restore kicks in for
2809 // these tests. 2808 // these tests.
2810 CommandLine* command_line = CommandLine::ForCurrentProcess(); 2809 CommandLine* command_line = CommandLine::ForCurrentProcess();
2811 CommandLine::StringVector argv = command_line->argv(); 2810 CommandLine::StringVector argv = command_line->argv();
2812 argv.erase(std::remove_if(++argv.begin(), argv.end(), IsNonSwitchArgument), 2811 argv.erase(std::remove_if(++argv.begin(), argv.end(), IsNonSwitchArgument),
2813 argv.end()); 2812 argv.end());
2814 command_line->InitFromArgv(argv); 2813 command_line->InitFromArgv(argv);
2815 ASSERT_TRUE(std::equal(argv.begin(), argv.end(), 2814 ASSERT_TRUE(std::equal(argv.begin(), argv.end(),
2816 command_line->argv().begin())); 2815 command_line->argv().begin()));
2817 } 2816 }
2818 2817
2819 virtual void SetUpOnMainThread() override { 2818 void SetUpOnMainThread() override {
2820 BrowserThread::PostTask( 2819 BrowserThread::PostTask(
2821 BrowserThread::IO, 2820 BrowserThread::IO,
2822 FROM_HERE, 2821 FROM_HERE,
2823 base::Bind( 2822 base::Bind(
2824 RedirectHostsToTestData, kRestoredURLs, arraysize(kRestoredURLs))); 2823 RedirectHostsToTestData, kRestoredURLs, arraysize(kRestoredURLs)));
2825 } 2824 }
2826 2825
2827 void HomepageIsNotNTP() { 2826 void HomepageIsNotNTP() {
2828 // Verifies that policy can set the startup pages to the homepage, when 2827 // Verifies that policy can set the startup pages to the homepage, when
2829 // the homepage is not the NTP. 2828 // the homepage is not the NTP.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2957 &RestoreOnStartupPolicyTest::NTP, 2956 &RestoreOnStartupPolicyTest::NTP,
2958 &RestoreOnStartupPolicyTest::Last)); 2957 &RestoreOnStartupPolicyTest::Last));
2959 2958
2960 // Similar to PolicyTest but sets a couple of policies before the browser is 2959 // Similar to PolicyTest but sets a couple of policies before the browser is
2961 // started. 2960 // started.
2962 class PolicyStatisticsCollectorTest : public PolicyTest { 2961 class PolicyStatisticsCollectorTest : public PolicyTest {
2963 public: 2962 public:
2964 PolicyStatisticsCollectorTest() {} 2963 PolicyStatisticsCollectorTest() {}
2965 virtual ~PolicyStatisticsCollectorTest() {} 2964 virtual ~PolicyStatisticsCollectorTest() {}
2966 2965
2967 virtual void SetUpInProcessBrowserTestFixture() override { 2966 void SetUpInProcessBrowserTestFixture() override {
2968 PolicyTest::SetUpInProcessBrowserTestFixture(); 2967 PolicyTest::SetUpInProcessBrowserTestFixture();
2969 PolicyMap policies; 2968 PolicyMap policies;
2970 policies.Set(key::kShowHomeButton, 2969 policies.Set(key::kShowHomeButton,
2971 POLICY_LEVEL_MANDATORY, 2970 POLICY_LEVEL_MANDATORY,
2972 POLICY_SCOPE_USER, 2971 POLICY_SCOPE_USER,
2973 new base::FundamentalValue(true), 2972 new base::FundamentalValue(true),
2974 NULL); 2973 NULL);
2975 policies.Set(key::kBookmarkBarEnabled, 2974 policies.Set(key::kBookmarkBarEnabled,
2976 POLICY_LEVEL_MANDATORY, 2975 POLICY_LEVEL_MANDATORY,
2977 POLICY_SCOPE_USER, 2976 POLICY_SCOPE_USER,
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
3247 3246
3248 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, 3247 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance,
3249 MediaStreamDevicesControllerBrowserTest, 3248 MediaStreamDevicesControllerBrowserTest,
3250 testing::Bool()); 3249 testing::Bool());
3251 3250
3252 #if !defined(OS_CHROMEOS) 3251 #if !defined(OS_CHROMEOS)
3253 // Similar to PolicyTest but sets the proper policy before the browser is 3252 // Similar to PolicyTest but sets the proper policy before the browser is
3254 // started. 3253 // started.
3255 class PolicyVariationsServiceTest : public PolicyTest { 3254 class PolicyVariationsServiceTest : public PolicyTest {
3256 public: 3255 public:
3257 virtual void SetUpInProcessBrowserTestFixture() override { 3256 void SetUpInProcessBrowserTestFixture() override {
3258 PolicyTest::SetUpInProcessBrowserTestFixture(); 3257 PolicyTest::SetUpInProcessBrowserTestFixture();
3259 PolicyMap policies; 3258 PolicyMap policies;
3260 policies.Set(key::kVariationsRestrictParameter, 3259 policies.Set(key::kVariationsRestrictParameter,
3261 POLICY_LEVEL_MANDATORY, 3260 POLICY_LEVEL_MANDATORY,
3262 POLICY_SCOPE_USER, 3261 POLICY_SCOPE_USER,
3263 new base::StringValue("restricted"), 3262 new base::StringValue("restricted"),
3264 NULL); 3263 NULL);
3265 provider_.UpdateChromePolicy(policies); 3264 provider_.UpdateChromePolicy(policies);
3266 } 3265 }
3267 }; 3266 };
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
3350 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 3349 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
3351 browser2->tab_strip_model()->GetActiveWebContents(), 3350 browser2->tab_strip_model()->GetActiveWebContents(),
3352 "domAutomationController.send(window.showModalDialog !== undefined);", 3351 "domAutomationController.send(window.showModalDialog !== undefined);",
3353 &result)); 3352 &result));
3354 EXPECT_TRUE(result); 3353 EXPECT_TRUE(result);
3355 } 3354 }
3356 3355
3357 #endif // !defined(CHROME_OS) 3356 #endif // !defined(CHROME_OS)
3358 3357
3359 } // namespace policy 3358 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/network_prediction_policy_handler.h ('k') | chrome/browser/policy/policy_prefs_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698