| 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 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "chrome/browser/extensions/activity_log/activity_log.h" | 9 #include "chrome/browser/extensions/activity_log/activity_log.h" |
| 10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 ~ActivityLogApiTest() override { | 32 ~ActivityLogApiTest() override { |
| 33 *base::CommandLine::ForCurrentProcess() = saved_cmdline_; | 33 *base::CommandLine::ForCurrentProcess() = saved_cmdline_; |
| 34 } | 34 } |
| 35 | 35 |
| 36 void SetUpCommandLine(base::CommandLine* command_line) override { | 36 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 37 ExtensionApiTest::SetUpCommandLine(command_line); | 37 ExtensionApiTest::SetUpCommandLine(command_line); |
| 38 saved_cmdline_ = *base::CommandLine::ForCurrentProcess(); | 38 saved_cmdline_ = *base::CommandLine::ForCurrentProcess(); |
| 39 command_line->AppendSwitch(switches::kEnableExtensionActivityLogging); | 39 command_line->AppendSwitch(switches::kEnableExtensionActivityLogging); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void SetUpOnMainThread() override { |
| 43 ExtensionApiTest::SetUpOnMainThread(); |
| 44 host_resolver()->AddRule("*", "127.0.0.1"); |
| 45 } |
| 46 |
| 42 std::unique_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { | 47 std::unique_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { |
| 43 std::unique_ptr<BasicHttpResponse> response(new BasicHttpResponse); | 48 std::unique_ptr<BasicHttpResponse> response(new BasicHttpResponse); |
| 44 response->set_code(net::HTTP_OK); | 49 response->set_code(net::HTTP_OK); |
| 45 response->set_content("<html><head><title>ActivityLogTest</title>" | 50 response->set_content("<html><head><title>ActivityLogTest</title>" |
| 46 "</head><body>Hello World</body></html>"); | 51 "</head><body>Hello World</body></html>"); |
| 47 return std::move(response); | 52 return std::move(response); |
| 48 } | 53 } |
| 49 | 54 |
| 50 private: | 55 private: |
| 51 base::CommandLine saved_cmdline_; | 56 base::CommandLine saved_cmdline_; |
| 52 }; | 57 }; |
| 53 | 58 |
| 54 #if defined(OS_WIN) | 59 #if defined(OS_WIN) |
| 55 // TODO(pmarch): fix flakiness on win debug - http://crbug.com/299393 | 60 // TODO(pmarch): fix flakiness on win debug - http://crbug.com/299393 |
| 56 #define MAYBE_TriggerEvent DISABLED_TriggerEvent | 61 #define MAYBE_TriggerEvent DISABLED_TriggerEvent |
| 57 #else | 62 #else |
| 58 #define MAYBE_TriggerEvent TriggerEvent | 63 #define MAYBE_TriggerEvent TriggerEvent |
| 59 #endif | 64 #endif |
| 60 | 65 |
| 61 // The test extension sends a message to its 'friend'. The test completes | 66 // The test extension sends a message to its 'friend'. The test completes |
| 62 // if it successfully sees the 'friend' receive the message. | 67 // if it successfully sees the 'friend' receive the message. |
| 63 IN_PROC_BROWSER_TEST_F(ActivityLogApiTest, MAYBE_TriggerEvent) { | 68 IN_PROC_BROWSER_TEST_F(ActivityLogApiTest, MAYBE_TriggerEvent) { |
| 64 ActivityLog::GetInstance(profile())->SetWatchdogAppActiveForTesting(true); | 69 ActivityLog::GetInstance(profile())->SetWatchdogAppActiveForTesting(true); |
| 65 | 70 |
| 66 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 67 embedded_test_server()->RegisterRequestHandler( | 71 embedded_test_server()->RegisterRequestHandler( |
| 68 base::Bind(&ActivityLogApiTest::HandleRequest, base::Unretained(this))); | 72 base::Bind(&ActivityLogApiTest::HandleRequest, base::Unretained(this))); |
| 69 ASSERT_TRUE(StartEmbeddedTestServer()); | 73 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 70 | 74 |
| 71 const Extension* friend_extension = LoadExtensionIncognito( | 75 const Extension* friend_extension = LoadExtensionIncognito( |
| 72 test_data_dir_.AppendASCII("activity_log_private/friend")); | 76 test_data_dir_.AppendASCII("activity_log_private/friend")); |
| 73 ASSERT_TRUE(friend_extension); | 77 ASSERT_TRUE(friend_extension); |
| 74 ASSERT_TRUE(RunExtensionTest("activity_log_private/test")); | 78 ASSERT_TRUE(RunExtensionTest("activity_log_private/test")); |
| 75 ActivityLog::GetInstance(profile())->SetWatchdogAppActiveForTesting(false); | 79 ActivityLog::GetInstance(profile())->SetWatchdogAppActiveForTesting(false); |
| 76 } | 80 } |
| 77 | 81 |
| 78 } // namespace extensions | 82 } // namespace extensions |
| 79 | 83 |
| OLD | NEW |