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