OLD | NEW |
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/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #endif | 30 #endif |
31 | 31 |
32 using content::BrowserThread; | 32 using content::BrowserThread; |
33 | 33 |
34 namespace extensions { | 34 namespace extensions { |
35 | 35 |
36 class FullStreamUIPolicyTest : public testing::Test { | 36 class FullStreamUIPolicyTest : public testing::Test { |
37 public: | 37 public: |
38 FullStreamUIPolicyTest() | 38 FullStreamUIPolicyTest() |
39 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 39 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
40 saved_cmdline_(CommandLine::NO_PROGRAM) { | 40 saved_cmdline_(base::CommandLine::NO_PROGRAM) { |
41 #if defined OS_CHROMEOS | 41 #if defined OS_CHROMEOS |
42 test_user_manager_.reset(new chromeos::ScopedTestUserManager()); | 42 test_user_manager_.reset(new chromeos::ScopedTestUserManager()); |
43 #endif | 43 #endif |
44 CommandLine command_line(CommandLine::NO_PROGRAM); | 44 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
45 saved_cmdline_ = *CommandLine::ForCurrentProcess(); | 45 saved_cmdline_ = *base::CommandLine::ForCurrentProcess(); |
46 profile_.reset(new TestingProfile()); | 46 profile_.reset(new TestingProfile()); |
47 CommandLine::ForCurrentProcess()->AppendSwitch( | 47 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
48 switches::kEnableExtensionActivityLogging); | 48 switches::kEnableExtensionActivityLogging); |
49 CommandLine::ForCurrentProcess()->AppendSwitch( | 49 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
50 switches::kEnableExtensionActivityLogTesting); | 50 switches::kEnableExtensionActivityLogTesting); |
51 extension_service_ = static_cast<TestExtensionSystem*>( | 51 extension_service_ = static_cast<TestExtensionSystem*>( |
52 ExtensionSystem::Get(profile_.get()))->CreateExtensionService | 52 ExtensionSystem::Get(profile_.get()))->CreateExtensionService |
53 (&command_line, base::FilePath(), false); | 53 (&command_line, base::FilePath(), false); |
54 } | 54 } |
55 | 55 |
56 ~FullStreamUIPolicyTest() override { | 56 ~FullStreamUIPolicyTest() override { |
57 #if defined OS_CHROMEOS | 57 #if defined OS_CHROMEOS |
58 test_user_manager_.reset(); | 58 test_user_manager_.reset(); |
59 #endif | 59 #endif |
60 base::RunLoop().RunUntilIdle(); | 60 base::RunLoop().RunUntilIdle(); |
61 profile_.reset(NULL); | 61 profile_.reset(NULL); |
62 base::RunLoop().RunUntilIdle(); | 62 base::RunLoop().RunUntilIdle(); |
63 // Restore the original command line and undo the affects of SetUp(). | 63 // Restore the original command line and undo the affects of SetUp(). |
64 *CommandLine::ForCurrentProcess() = saved_cmdline_; | 64 *base::CommandLine::ForCurrentProcess() = saved_cmdline_; |
65 } | 65 } |
66 | 66 |
67 // A wrapper function for CheckReadFilteredData, so that we don't need to | 67 // A wrapper function for CheckReadFilteredData, so that we don't need to |
68 // enter empty string values for parameters we don't care about. | 68 // enter empty string values for parameters we don't care about. |
69 void CheckReadData( | 69 void CheckReadData( |
70 ActivityLogDatabasePolicy* policy, | 70 ActivityLogDatabasePolicy* policy, |
71 const std::string& extension_id, | 71 const std::string& extension_id, |
72 int day, | 72 int day, |
73 const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker) { | 73 const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker) { |
74 CheckReadFilteredData( | 74 CheckReadFilteredData( |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 } | 436 } |
437 | 437 |
438 protected: | 438 protected: |
439 ExtensionService* extension_service_; | 439 ExtensionService* extension_service_; |
440 scoped_ptr<TestingProfile> profile_; | 440 scoped_ptr<TestingProfile> profile_; |
441 content::TestBrowserThreadBundle thread_bundle_; | 441 content::TestBrowserThreadBundle thread_bundle_; |
442 // Used to preserve a copy of the original command line. | 442 // Used to preserve a copy of the original command line. |
443 // The test framework will do this itself as well. However, by then, | 443 // The test framework will do this itself as well. However, by then, |
444 // it is too late to call ActivityLog::RecomputeLoggingIsEnabled() in | 444 // it is too late to call ActivityLog::RecomputeLoggingIsEnabled() in |
445 // TearDown(). | 445 // TearDown(). |
446 CommandLine saved_cmdline_; | 446 base::CommandLine saved_cmdline_; |
447 | 447 |
448 #if defined OS_CHROMEOS | 448 #if defined OS_CHROMEOS |
449 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 449 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
450 chromeos::ScopedTestCrosSettings test_cros_settings_; | 450 chromeos::ScopedTestCrosSettings test_cros_settings_; |
451 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_; | 451 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_; |
452 #endif | 452 #endif |
453 }; | 453 }; |
454 | 454 |
455 TEST_F(FullStreamUIPolicyTest, Construct) { | 455 TEST_F(FullStreamUIPolicyTest, Construct) { |
456 ActivityLogDatabasePolicy* policy = new FullStreamUIPolicy(profile_.get()); | 456 ActivityLogDatabasePolicy* policy = new FullStreamUIPolicy(profile_.get()); |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 action_ids.push_back(3); | 1052 action_ids.push_back(3); |
1053 action_ids.push_back(4); | 1053 action_ids.push_back(4); |
1054 CheckRemoveActions( | 1054 CheckRemoveActions( |
1055 policy, action_ids, base::Bind(&FullStreamUIPolicyTest::Action2Deleted)); | 1055 policy, action_ids, base::Bind(&FullStreamUIPolicyTest::Action2Deleted)); |
1056 action_ids.clear(); | 1056 action_ids.clear(); |
1057 | 1057 |
1058 policy->Close(); | 1058 policy->Close(); |
1059 } | 1059 } |
1060 | 1060 |
1061 } // namespace extensions | 1061 } // namespace extensions |
OLD | NEW |