OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 | 7 |
7 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
9 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
11 #include "chromeos/dbus/dbus_thread_manager.h" | 12 #include "chromeos/dbus/dbus_thread_manager.h" |
12 #include "chromeos/dbus/fake_debug_daemon_client.h" | 13 #include "chromeos/dbus/fake_debug_daemon_client.h" |
13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
14 #include "extensions/common/extension_builder.h" | 15 #include "extensions/common/extension_builder.h" |
15 #include "net/dns/mock_host_resolver.h" | 16 #include "net/dns/mock_host_resolver.h" |
(...skipping 11 matching lines...) Expand all Loading... |
27 public: | 28 public: |
28 explicit TestDebugDaemonClient(const base::FilePath& test_file) | 29 explicit TestDebugDaemonClient(const base::FilePath& test_file) |
29 : test_file_(test_file) {} | 30 : test_file_(test_file) {} |
30 | 31 |
31 ~TestDebugDaemonClient() override {} | 32 ~TestDebugDaemonClient() override {} |
32 | 33 |
33 void DumpDebugLogs(bool is_compressed, | 34 void DumpDebugLogs(bool is_compressed, |
34 base::File file, | 35 base::File file, |
35 scoped_refptr<base::TaskRunner> task_runner, | 36 scoped_refptr<base::TaskRunner> task_runner, |
36 const GetDebugLogsCallback& callback) override { | 37 const GetDebugLogsCallback& callback) override { |
37 base::File* file_param = new base::File(file.Pass()); | 38 base::File* file_param = new base::File(std::move(file)); |
38 task_runner->PostTaskAndReply( | 39 task_runner->PostTaskAndReply( |
39 FROM_HERE, | 40 FROM_HERE, |
40 base::Bind( | 41 base::Bind( |
41 &GenerateTestLogDumpFile, test_file_, base::Owned(file_param)), | 42 &GenerateTestLogDumpFile, test_file_, base::Owned(file_param)), |
42 base::Bind(callback, true)); | 43 base::Bind(callback, true)); |
43 } | 44 } |
44 | 45 |
45 static void GenerateTestLogDumpFile(const base::FilePath& test_tar_file, | 46 static void GenerateTestLogDumpFile(const base::FilePath& test_tar_file, |
46 base::File* file) { | 47 base::File* file) { |
47 std::string test_file_content; | 48 std::string test_file_content; |
(...skipping 27 matching lines...) Expand all Loading... |
75 new TestDebugDaemonClient(tar_file_path))); | 76 new TestDebugDaemonClient(tar_file_path))); |
76 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 77 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
77 } | 78 } |
78 | 79 |
79 scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { | 80 scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { |
80 scoped_ptr<BasicHttpResponse> response(new BasicHttpResponse); | 81 scoped_ptr<BasicHttpResponse> response(new BasicHttpResponse); |
81 response->set_code(net::HTTP_OK); | 82 response->set_code(net::HTTP_OK); |
82 response->set_content( | 83 response->set_content( |
83 "<html><head><title>LogPrivateTest</title>" | 84 "<html><head><title>LogPrivateTest</title>" |
84 "</head><body>Hello!</body></html>"); | 85 "</head><body>Hello!</body></html>"); |
85 return response.Pass(); | 86 return std::move(response); |
86 } | 87 } |
87 }; | 88 }; |
88 | 89 |
89 IN_PROC_BROWSER_TEST_F(LogPrivateApiTest, DumpLogsAndCaptureEvents) { | 90 IN_PROC_BROWSER_TEST_F(LogPrivateApiTest, DumpLogsAndCaptureEvents) { |
90 // Setup dummy HTTP server. | 91 // Setup dummy HTTP server. |
91 host_resolver()->AddRule("www.test.com", "127.0.0.1"); | 92 host_resolver()->AddRule("www.test.com", "127.0.0.1"); |
92 ASSERT_TRUE(StartEmbeddedTestServer()); | 93 ASSERT_TRUE(StartEmbeddedTestServer()); |
93 embedded_test_server()->RegisterRequestHandler( | 94 embedded_test_server()->RegisterRequestHandler( |
94 base::Bind(&LogPrivateApiTest::HandleRequest, base::Unretained(this))); | 95 base::Bind(&LogPrivateApiTest::HandleRequest, base::Unretained(this))); |
95 | 96 |
96 ASSERT_TRUE(RunExtensionTest("log_private/dump_logs")); | 97 ASSERT_TRUE(RunExtensionTest("log_private/dump_logs")); |
97 } | 98 } |
98 | 99 |
99 } // namespace extensions | 100 } // namespace extensions |
OLD | NEW |