| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/extensions/activity_log/activity_log.h" | 5 #include "chrome/browser/extensions/activity_log/activity_log.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 } | 423 } |
| 424 | 424 |
| 425 class ActivityLogTestWithoutSwitch : public ActivityLogTest { | 425 class ActivityLogTestWithoutSwitch : public ActivityLogTest { |
| 426 public: | 426 public: |
| 427 ActivityLogTestWithoutSwitch() {} | 427 ActivityLogTestWithoutSwitch() {} |
| 428 ~ActivityLogTestWithoutSwitch() override {} | 428 ~ActivityLogTestWithoutSwitch() override {} |
| 429 bool enable_activity_logging_switch() const override { return false; } | 429 bool enable_activity_logging_switch() const override { return false; } |
| 430 }; | 430 }; |
| 431 | 431 |
| 432 TEST_F(ActivityLogTestWithoutSwitch, TestShouldLog) { | 432 TEST_F(ActivityLogTestWithoutSwitch, TestShouldLog) { |
| 433 static_cast<TestExtensionSystem*>( |
| 434 ExtensionSystem::Get(profile()))->SetReady(); |
| 433 ActivityLog* activity_log = ActivityLog::GetInstance(profile()); | 435 ActivityLog* activity_log = ActivityLog::GetInstance(profile()); |
| 434 scoped_refptr<const Extension> empty_extension = | 436 scoped_refptr<const Extension> empty_extension = |
| 435 test_util::CreateEmptyExtension(); | 437 test_util::CreateEmptyExtension(); |
| 436 extension_service_->AddExtension(empty_extension.get()); | 438 extension_service_->AddExtension(empty_extension.get()); |
| 437 // Since the command line switch for logging isn't enabled and there's no | 439 // Since the command line switch for logging isn't enabled and there's no |
| 438 // watchdog app active, the activity log shouldn't log anything. | 440 // watchdog app active, the activity log shouldn't log anything. |
| 439 EXPECT_FALSE(activity_log->ShouldLog(empty_extension->id())); | 441 EXPECT_FALSE(activity_log->ShouldLog(empty_extension->id())); |
| 440 const char kWhitelistedExtensionId[] = "eplckmlabaanikjjcgnigddmagoglhmp"; | 442 const char kWhitelistedExtensionId[] = "eplckmlabaanikjjcgnigddmagoglhmp"; |
| 441 scoped_refptr<const Extension> activity_log_extension = | 443 scoped_refptr<const Extension> activity_log_extension = |
| 442 test_util::CreateEmptyExtension(kWhitelistedExtensionId); | 444 test_util::CreateEmptyExtension(kWhitelistedExtensionId); |
| 443 extension_service_->AddExtension(activity_log_extension.get()); | 445 extension_service_->AddExtension(activity_log_extension.get()); |
| 444 // Loading a watchdog app means the activity log should log other extension | 446 // Loading a watchdog app means the activity log should log other extension |
| 445 // activities... | 447 // activities... |
| 446 EXPECT_TRUE(activity_log->ShouldLog(empty_extension->id())); | 448 EXPECT_TRUE(activity_log->ShouldLog(empty_extension->id())); |
| 447 // ... but not those of the watchdog app. | 449 // ... but not those of the watchdog app. |
| 448 EXPECT_FALSE(activity_log->ShouldLog(activity_log_extension->id())); | 450 EXPECT_FALSE(activity_log->ShouldLog(activity_log_extension->id())); |
| 449 extension_service_->DisableExtension(activity_log_extension->id(), | 451 extension_service_->DisableExtension(activity_log_extension->id(), |
| 450 Extension::DISABLE_USER_ACTION); | 452 Extension::DISABLE_USER_ACTION); |
| 451 // Disabling the watchdog app means that we're back to never logging anything. | 453 // Disabling the watchdog app means that we're back to never logging anything. |
| 452 EXPECT_FALSE(activity_log->ShouldLog(empty_extension->id())); | 454 EXPECT_FALSE(activity_log->ShouldLog(empty_extension->id())); |
| 453 } | 455 } |
| 454 | 456 |
| 455 } // namespace extensions | 457 } // namespace extensions |
| OLD | NEW |