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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/test/scoped_command_line.h" | 7 #include "base/test/scoped_command_line.h" |
8 #include "chrome/browser/extensions/activity_log/activity_log.h" | 8 #include "chrome/browser/extensions/activity_log/activity_log.h" |
| 9 #include "chrome/browser/extensions/activity_log/activity_log_task_runner.h" |
9 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat
e_api.h" | 10 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat
e_api.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/extensions/test_extension_system.h" | 12 #include "chrome/browser/extensions/test_extension_system.h" |
12 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 15 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
15 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
16 #include "components/prefs/pref_service.h" | 17 #include "components/prefs/pref_service.h" |
17 #include "extensions/browser/uninstall_reason.h" | 18 #include "extensions/browser/uninstall_reason.h" |
18 #include "extensions/common/extension_builder.h" | 19 #include "extensions/common/extension_builder.h" |
19 | 20 |
20 namespace extensions { | 21 namespace extensions { |
21 | 22 |
22 const char kExtensionID[] = "eplckmlabaanikjjcgnigddmagoglhmp"; | 23 const char kExtensionID[] = "eplckmlabaanikjjcgnigddmagoglhmp"; |
23 | 24 |
24 class ActivityLogEnabledTest : public ChromeRenderViewHostTestHarness { | 25 class ActivityLogEnabledTest : public ChromeRenderViewHostTestHarness { |
25 protected: | 26 protected: |
26 void SetUp() override { | 27 void SetUp() override { |
27 ChromeRenderViewHostTestHarness::SetUp(); | 28 ChromeRenderViewHostTestHarness::SetUp(); |
| 29 SetActivityLogTaskRunnerForTesting( |
| 30 base::ThreadTaskRunnerHandle::Get().get()); |
28 } | 31 } |
29 | 32 |
30 void TearDown() override { | 33 void TearDown() override { |
31 ChromeRenderViewHostTestHarness::TearDown(); | 34 ChromeRenderViewHostTestHarness::TearDown(); |
| 35 SetActivityLogTaskRunnerForTesting(nullptr); |
32 } | 36 } |
33 }; | 37 }; |
34 | 38 |
35 TEST_F(ActivityLogEnabledTest, NoSwitch) { | 39 TEST_F(ActivityLogEnabledTest, NoSwitch) { |
36 std::unique_ptr<TestingProfile> profile( | 40 std::unique_ptr<TestingProfile> profile( |
37 static_cast<TestingProfile*>(CreateBrowserContext())); | 41 static_cast<TestingProfile*>(CreateBrowserContext())); |
38 EXPECT_FALSE( | 42 EXPECT_FALSE( |
39 profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); | 43 profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); |
40 | 44 |
41 ActivityLog* activity_log = ActivityLog::GetInstance(profile.get()); | 45 ActivityLog* activity_log = ActivityLog::GetInstance(profile.get()); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 .SetID(kExtensionID) | 306 .SetID(kExtensionID) |
303 .Build(); | 307 .Build(); |
304 extension_service->AddExtension(extension.get()); | 308 extension_service->AddExtension(extension.get()); |
305 | 309 |
306 EXPECT_EQ( | 310 EXPECT_EQ( |
307 1, profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); | 311 1, profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); |
308 EXPECT_TRUE(activity_log->is_active()); | 312 EXPECT_TRUE(activity_log->is_active()); |
309 } | 313 } |
310 | 314 |
311 } // namespace extensions | 315 } // namespace extensions |
OLD | NEW |