| 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 | |
| 26 namespace extensions { | 20 namespace extensions { |
| 27 | 21 |
| 28 const char kExtensionID[] = "eplckmlabaanikjjcgnigddmagoglhmp"; | 22 const char kExtensionID[] = "eplckmlabaanikjjcgnigddmagoglhmp"; |
| 29 | 23 |
| 30 class ActivityLogEnabledTest : public ChromeRenderViewHostTestHarness { | 24 class ActivityLogEnabledTest : public ChromeRenderViewHostTestHarness { |
| 31 protected: | 25 protected: |
| 32 void SetUp() override { | 26 void SetUp() override { |
| 33 ChromeRenderViewHostTestHarness::SetUp(); | 27 ChromeRenderViewHostTestHarness::SetUp(); |
| 34 #if defined OS_CHROMEOS | |
| 35 test_user_manager_.reset(new chromeos::ScopedTestUserManager()); | |
| 36 #endif | |
| 37 } | 28 } |
| 38 | 29 |
| 39 void TearDown() override { | 30 void TearDown() override { |
| 40 #if defined OS_CHROMEOS | |
| 41 test_user_manager_.reset(); | |
| 42 #endif | |
| 43 ChromeRenderViewHostTestHarness::TearDown(); | 31 ChromeRenderViewHostTestHarness::TearDown(); |
| 44 } | 32 } |
| 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 | |
| 51 }; | 33 }; |
| 52 | 34 |
| 53 TEST_F(ActivityLogEnabledTest, NoSwitch) { | 35 TEST_F(ActivityLogEnabledTest, NoSwitch) { |
| 54 std::unique_ptr<TestingProfile> profile( | 36 std::unique_ptr<TestingProfile> profile( |
| 55 static_cast<TestingProfile*>(CreateBrowserContext())); | 37 static_cast<TestingProfile*>(CreateBrowserContext())); |
| 56 EXPECT_FALSE( | 38 EXPECT_FALSE( |
| 57 profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); | 39 profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); |
| 58 | 40 |
| 59 ActivityLog* activity_log = ActivityLog::GetInstance(profile.get()); | 41 ActivityLog* activity_log = ActivityLog::GetInstance(profile.get()); |
| 60 | 42 |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 .SetID(kExtensionID) | 302 .SetID(kExtensionID) |
| 321 .Build(); | 303 .Build(); |
| 322 extension_service->AddExtension(extension.get()); | 304 extension_service->AddExtension(extension.get()); |
| 323 | 305 |
| 324 EXPECT_EQ( | 306 EXPECT_EQ( |
| 325 1, profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); | 307 1, profile->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive)); |
| 326 EXPECT_TRUE(activity_log->is_active()); | 308 EXPECT_TRUE(activity_log->is_active()); |
| 327 } | 309 } |
| 328 | 310 |
| 329 } // namespace extensions | 311 } // namespace extensions |
| OLD | NEW |