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 #include "net/dns/mock_host_resolver.h" | 11 #include "net/dns/mock_host_resolver.h" |
12 | 12 |
13 namespace extensions { | 13 namespace extensions { |
14 | 14 |
15 class ActivityLogApiTest : public ExtensionApiTest { | 15 class ActivityLogApiTest : public ExtensionApiTest { |
16 public: | 16 public: |
17 ActivityLogApiTest() : saved_cmdline_(CommandLine::NO_PROGRAM) {} | 17 ActivityLogApiTest() : saved_cmdline_(CommandLine::NO_PROGRAM) {} |
18 | 18 |
19 virtual ~ActivityLogApiTest() { | 19 virtual ~ActivityLogApiTest() { |
20 ExtensionApiTest::SetUpCommandLine(&saved_cmdline_); | 20 ExtensionApiTest::SetUpCommandLine(&saved_cmdline_); |
21 *CommandLine::ForCurrentProcess() = saved_cmdline_; | 21 *CommandLine::ForCurrentProcess() = saved_cmdline_; |
22 } | 22 } |
23 | 23 |
24 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 24 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
25 ExtensionApiTest::SetUpCommandLine(command_line); | 25 ExtensionApiTest::SetUpCommandLine(command_line); |
26 saved_cmdline_ = *CommandLine::ForCurrentProcess(); | 26 saved_cmdline_ = *CommandLine::ForCurrentProcess(); |
27 command_line->AppendSwitch(switches::kEnableExtensionActivityLogging); | 27 command_line->AppendSwitch(switches::kEnableExtensionActivityLogging); |
28 command_line->AppendSwitch(switches::kEnableExtensionActivityLogTesting); | |
29 } | 28 } |
30 | 29 |
31 private: | 30 private: |
32 CommandLine saved_cmdline_; | 31 CommandLine saved_cmdline_; |
33 }; | 32 }; |
34 | 33 |
35 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) | 34 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) |
36 // TODO(karenlees): test flaky on windows. See Bug: crbug.com/245594 | 35 // TODO(karenlees): test flaky on windows. See Bug: crbug.com/245594 |
37 #define MAYBE_TriggerEvent DISABLED_TriggerEvent | 36 #define MAYBE_TriggerEvent DISABLED_TriggerEvent |
38 #else | 37 #else |
39 #define MAYBE_TriggerEvent TriggerEvent | 38 #define MAYBE_TriggerEvent TriggerEvent |
40 #endif | 39 #endif |
41 | 40 |
42 // The test extension sends a message to its 'friend'. The test completes | 41 // The test extension sends a message to its 'friend'. The test completes |
43 // if it successfully sees the 'friend' receive the message. | 42 // if it successfully sees the 'friend' receive the message. |
44 IN_PROC_BROWSER_TEST_F(ActivityLogApiTest, MAYBE_TriggerEvent) { | 43 IN_PROC_BROWSER_TEST_F(ActivityLogApiTest, MAYBE_TriggerEvent) { |
45 ActivityLog::GetInstance(profile())->SetWatchdogAppActive(true); | 44 ActivityLog::GetInstance(profile())->SetWatchdogAppActive(true); |
46 host_resolver()->AddRule("*", "127.0.0.1"); | 45 host_resolver()->AddRule("*", "127.0.0.1"); |
47 const Extension* friend_extension = LoadExtensionIncognito( | 46 const Extension* friend_extension = LoadExtensionIncognito( |
48 test_data_dir_.AppendASCII("activity_log_private/friend")); | 47 test_data_dir_.AppendASCII("activity_log_private/friend")); |
49 ASSERT_TRUE(friend_extension); | 48 ASSERT_TRUE(friend_extension); |
50 ASSERT_TRUE(RunExtensionTest("activity_log_private/test")); | 49 ASSERT_TRUE(RunExtensionTest("activity_log_private/test")); |
51 ActivityLog::GetInstance(profile())->SetWatchdogAppActive(false); | 50 ActivityLog::GetInstance(profile())->SetWatchdogAppActive(false); |
52 } | 51 } |
53 | 52 |
54 } // namespace extensions | 53 } // namespace extensions |
55 | 54 |
OLD | NEW |