| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/activity_log/activity_log.h" | 7 #include "chrome/browser/extensions/activity_log/activity_log.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/common/extensions/extension_builder.h" | 10 #include "chrome/common/extensions/extension_builder.h" |
| 11 | 11 |
| 12 namespace extensions { | 12 namespace extensions { |
| 13 | 13 |
| 14 class ActivityLogApiTest : public ExtensionApiTest { | 14 class ActivityLogApiTest : public ExtensionApiTest { |
| 15 public: | 15 public: |
| 16 ActivityLogApiTest() {} | 16 ActivityLogApiTest() : saved_cmdline_(CommandLine::NO_PROGRAM) {} |
| 17 |
| 18 virtual ~ActivityLogApiTest() { |
| 19 ExtensionApiTest::SetUpCommandLine(&saved_cmdline_); |
| 20 *CommandLine::ForCurrentProcess() = saved_cmdline_; |
| 21 } |
| 17 | 22 |
| 18 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 23 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 19 ExtensionApiTest::SetUpCommandLine(command_line); | 24 ExtensionApiTest::SetUpCommandLine(command_line); |
| 25 saved_cmdline_ = *CommandLine::ForCurrentProcess(); |
| 20 command_line->AppendSwitch(switches::kEnableExtensionActivityLogging); | 26 command_line->AppendSwitch(switches::kEnableExtensionActivityLogging); |
| 21 command_line->AppendSwitch(switches::kEnableExtensionActivityLogTesting); | 27 command_line->AppendSwitch(switches::kEnableExtensionActivityLogTesting); |
| 22 } | 28 } |
| 29 |
| 30 private: |
| 31 CommandLine saved_cmdline_; |
| 23 }; | 32 }; |
| 24 | 33 |
| 25 // The test extension sends a message to its 'friend'. The test completes | 34 // The test extension sends a message to its 'friend'. The test completes |
| 26 // if it successfully sees the 'friend' receive the message. | 35 // if it successfully sees the 'friend' receive the message. |
| 27 IN_PROC_BROWSER_TEST_F(ActivityLogApiTest, TriggerEvent) { | 36 IN_PROC_BROWSER_TEST_F(ActivityLogApiTest, TriggerEvent) { |
| 28 const Extension* friend_extension = | 37 const Extension* friend_extension = |
| 29 LoadExtension(test_data_dir_.AppendASCII("activity_log_private/friend")); | 38 LoadExtension(test_data_dir_.AppendASCII("activity_log_private/friend")); |
| 30 ASSERT_TRUE(friend_extension); | 39 ASSERT_TRUE(friend_extension); |
| 31 ASSERT_TRUE(RunExtensionTest("activity_log_private/test")); | 40 ASSERT_TRUE(RunExtensionTest("activity_log_private/test")); |
| 32 } | 41 } |
| 33 | 42 |
| 34 } // namespace extensions | 43 } // namespace extensions |
| 35 | 44 |
| OLD | NEW |