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

Side by Side Diff: chrome/browser/extensions/activity_log/counting_policy_unittest.cc

Issue 819133004: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/cancelable_callback.h" 5 #include "base/cancelable_callback.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 20 matching lines...) Expand all
31 #endif 31 #endif
32 32
33 using content::BrowserThread; 33 using content::BrowserThread;
34 34
35 namespace extensions { 35 namespace extensions {
36 36
37 class CountingPolicyTest : public testing::Test { 37 class CountingPolicyTest : public testing::Test {
38 public: 38 public:
39 CountingPolicyTest() 39 CountingPolicyTest()
40 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), 40 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
41 saved_cmdline_(CommandLine::NO_PROGRAM) { 41 saved_cmdline_(base::CommandLine::NO_PROGRAM) {
42 #if defined OS_CHROMEOS 42 #if defined OS_CHROMEOS
43 test_user_manager_.reset(new chromeos::ScopedTestUserManager()); 43 test_user_manager_.reset(new chromeos::ScopedTestUserManager());
44 #endif 44 #endif
45 CommandLine command_line(CommandLine::NO_PROGRAM); 45 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
46 saved_cmdline_ = *CommandLine::ForCurrentProcess(); 46 saved_cmdline_ = *base::CommandLine::ForCurrentProcess();
47 profile_.reset(new TestingProfile()); 47 profile_.reset(new TestingProfile());
48 CommandLine::ForCurrentProcess()->AppendSwitch( 48 base::CommandLine::ForCurrentProcess()->AppendSwitch(
49 switches::kEnableExtensionActivityLogging); 49 switches::kEnableExtensionActivityLogging);
50 extension_service_ = static_cast<TestExtensionSystem*>( 50 extension_service_ = static_cast<TestExtensionSystem*>(
51 ExtensionSystem::Get(profile_.get()))->CreateExtensionService 51 ExtensionSystem::Get(profile_.get()))->CreateExtensionService
52 (&command_line, base::FilePath(), false); 52 (&command_line, base::FilePath(), false);
53 } 53 }
54 54
55 ~CountingPolicyTest() override { 55 ~CountingPolicyTest() override {
56 #if defined OS_CHROMEOS 56 #if defined OS_CHROMEOS
57 test_user_manager_.reset(); 57 test_user_manager_.reset();
58 #endif 58 #endif
59 base::RunLoop().RunUntilIdle(); 59 base::RunLoop().RunUntilIdle();
60 profile_.reset(NULL); 60 profile_.reset(NULL);
61 base::RunLoop().RunUntilIdle(); 61 base::RunLoop().RunUntilIdle();
62 // Restore the original command line and undo the affects of SetUp(). 62 // Restore the original command line and undo the affects of SetUp().
63 *CommandLine::ForCurrentProcess() = saved_cmdline_; 63 *base::CommandLine::ForCurrentProcess() = saved_cmdline_;
64 } 64 }
65 65
66 // Wait for the task queue for the specified thread to empty. 66 // Wait for the task queue for the specified thread to empty.
67 void WaitOnThread(const BrowserThread::ID& thread) { 67 void WaitOnThread(const BrowserThread::ID& thread) {
68 BrowserThread::PostTaskAndReply( 68 BrowserThread::PostTaskAndReply(
69 thread, 69 thread,
70 FROM_HERE, 70 FROM_HERE,
71 base::Bind(&base::DoNothing), 71 base::Bind(&base::DoNothing),
72 base::MessageLoop::current()->QuitClosure()); 72 base::MessageLoop::current()->QuitClosure());
73 base::MessageLoop::current()->Run(); 73 base::MessageLoop::current()->Run();
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 } 519 }
520 520
521 protected: 521 protected:
522 ExtensionService* extension_service_; 522 ExtensionService* extension_service_;
523 scoped_ptr<TestingProfile> profile_; 523 scoped_ptr<TestingProfile> profile_;
524 content::TestBrowserThreadBundle thread_bundle_; 524 content::TestBrowserThreadBundle thread_bundle_;
525 // Used to preserve a copy of the original command line. 525 // Used to preserve a copy of the original command line.
526 // The test framework will do this itself as well. However, by then, 526 // The test framework will do this itself as well. However, by then,
527 // it is too late to call ActivityLog::RecomputeLoggingIsEnabled() in 527 // it is too late to call ActivityLog::RecomputeLoggingIsEnabled() in
528 // TearDown(). 528 // TearDown().
529 CommandLine saved_cmdline_; 529 base::CommandLine saved_cmdline_;
530 530
531 #if defined OS_CHROMEOS 531 #if defined OS_CHROMEOS
532 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; 532 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
533 chromeos::ScopedTestCrosSettings test_cros_settings_; 533 chromeos::ScopedTestCrosSettings test_cros_settings_;
534 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_; 534 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_;
535 #endif 535 #endif
536 }; 536 };
537 537
538 TEST_F(CountingPolicyTest, Construct) { 538 TEST_F(CountingPolicyTest, Construct) {
539 ActivityLogDatabasePolicy* policy = new CountingPolicy(profile_.get()); 539 ActivityLogDatabasePolicy* policy = new CountingPolicy(profile_.get());
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 1414
1415 action_ids.push_back(2); 1415 action_ids.push_back(2);
1416 CheckRemoveActions( 1416 CheckRemoveActions(
1417 policy, action_ids, base::Bind(&CountingPolicyTest::Action2Deleted)); 1417 policy, action_ids, base::Bind(&CountingPolicyTest::Action2Deleted));
1418 action_ids.clear(); 1418 action_ids.clear();
1419 1419
1420 policy->Close(); 1420 policy->Close();
1421 } 1421 }
1422 1422
1423 } // namespace extensions 1423 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698