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/api/activity_log_private/activity_log_privat
e_api.h" | 9 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat
e_api.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/extensions/test_extension_system.h" | 11 #include "chrome/browser/extensions/test_extension_system.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
15 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
16 #include "components/prefs/pref_service.h" | 16 #include "components/prefs/pref_service.h" |
17 #include "extensions/browser/uninstall_reason.h" | 17 #include "extensions/browser/uninstall_reason.h" |
18 #include "extensions/common/extension_builder.h" | 18 #include "extensions/common/extension_builder.h" |
19 | 19 |
| 20 #if defined OS_CHROMEOS |
| 21 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" |
| 22 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 23 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 24 #endif |
| 25 |
20 namespace extensions { | 26 namespace extensions { |
21 | 27 |
22 const char kExtensionID[] = "eplckmlabaanikjjcgnigddmagoglhmp"; | 28 const char kExtensionID[] = "eplckmlabaanikjjcgnigddmagoglhmp"; |
23 | 29 |
24 class ActivityLogEnabledTest : public ChromeRenderViewHostTestHarness { | 30 class ActivityLogEnabledTest : public ChromeRenderViewHostTestHarness { |
25 protected: | 31 protected: |
26 void SetUp() override { | 32 void SetUp() override { |
27 ChromeRenderViewHostTestHarness::SetUp(); | 33 ChromeRenderViewHostTestHarness::SetUp(); |
| 34 #if defined OS_CHROMEOS |
| 35 test_user_manager_.reset(new chromeos::ScopedTestUserManager()); |
| 36 #endif |
28 } | 37 } |
29 | 38 |
30 void TearDown() override { | 39 void TearDown() override { |
| 40 #if defined OS_CHROMEOS |
| 41 test_user_manager_.reset(); |
| 42 #endif |
31 ChromeRenderViewHostTestHarness::TearDown(); | 43 ChromeRenderViewHostTestHarness::TearDown(); |
32 } | 44 } |
| 45 |
| 46 #if defined OS_CHROMEOS |
| 47 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| 48 chromeos::ScopedTestCrosSettings test_cros_settings_; |
| 49 std::unique_ptr<chromeos::ScopedTestUserManager> test_user_manager_; |
| 50 #endif |
33 }; | 51 }; |
34 | 52 |
35 TEST_F(ActivityLogEnabledTest, NoSwitch) { | 53 TEST_F(ActivityLogEnabledTest, NoSwitch) { |
36 std::unique_ptr<TestingProfile> profile( | 54 std::unique_ptr<TestingProfile> profile( |
37 static_cast<TestingProfile*>(CreateBrowserContext())); | 55 static_cast<TestingProfile*>(CreateBrowserContext())); |
38 EXPECT_FALSE( | 56 EXPECT_FALSE( |
39 profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); | 57 profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); |
40 | 58 |
41 ActivityLog* activity_log = ActivityLog::GetInstance(profile.get()); | 59 ActivityLog* activity_log = ActivityLog::GetInstance(profile.get()); |
42 | 60 |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 .SetID(kExtensionID) | 320 .SetID(kExtensionID) |
303 .Build(); | 321 .Build(); |
304 extension_service->AddExtension(extension.get()); | 322 extension_service->AddExtension(extension.get()); |
305 | 323 |
306 EXPECT_EQ( | 324 EXPECT_EQ( |
307 1, profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); | 325 1, profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); |
308 EXPECT_TRUE(activity_log->is_active()); | 326 EXPECT_TRUE(activity_log->is_active()); |
309 } | 327 } |
310 | 328 |
311 } // namespace extensions | 329 } // namespace extensions |
OLD | NEW |