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 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 class TestDebugDaemonClient : public chromeos::FakeDebugDaemonClient { | 26 class TestDebugDaemonClient : public chromeos::FakeDebugDaemonClient { |
27 public: | 27 public: |
28 explicit TestDebugDaemonClient(const base::FilePath& test_file) | 28 explicit TestDebugDaemonClient(const base::FilePath& test_file) |
29 : test_file_(test_file) {} | 29 : test_file_(test_file) {} |
30 | 30 |
31 virtual ~TestDebugDaemonClient() {} | 31 virtual ~TestDebugDaemonClient() {} |
32 | 32 |
33 virtual void DumpDebugLogs(bool is_compressed, | 33 virtual void DumpDebugLogs(bool is_compressed, |
34 base::File file, | 34 base::File file, |
35 scoped_refptr<base::TaskRunner> task_runner, | 35 scoped_refptr<base::TaskRunner> task_runner, |
36 const GetDebugLogsCallback& callback) OVERRIDE { | 36 const GetDebugLogsCallback& callback) override { |
37 base::File* file_param = new base::File(file.Pass()); | 37 base::File* file_param = new base::File(file.Pass()); |
38 task_runner->PostTaskAndReply( | 38 task_runner->PostTaskAndReply( |
39 FROM_HERE, | 39 FROM_HERE, |
40 base::Bind( | 40 base::Bind( |
41 &GenerateTestLogDumpFile, test_file_, base::Owned(file_param)), | 41 &GenerateTestLogDumpFile, test_file_, base::Owned(file_param)), |
42 base::Bind(callback, true)); | 42 base::Bind(callback, true)); |
43 } | 43 } |
44 | 44 |
45 static void GenerateTestLogDumpFile(const base::FilePath& test_tar_file, | 45 static void GenerateTestLogDumpFile(const base::FilePath& test_tar_file, |
46 base::File* file) { | 46 base::File* file) { |
(...skipping 13 matching lines...) Expand all Loading... |
60 } // namespace | 60 } // namespace |
61 | 61 |
62 namespace extensions { | 62 namespace extensions { |
63 | 63 |
64 class LogPrivateApiTest : public ExtensionApiTest { | 64 class LogPrivateApiTest : public ExtensionApiTest { |
65 public: | 65 public: |
66 LogPrivateApiTest() {} | 66 LogPrivateApiTest() {} |
67 | 67 |
68 virtual ~LogPrivateApiTest() {} | 68 virtual ~LogPrivateApiTest() {} |
69 | 69 |
70 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 70 virtual void SetUpInProcessBrowserTestFixture() override { |
71 base::FilePath tar_file_path = | 71 base::FilePath tar_file_path = |
72 test_data_dir_.Append("log_private/dump_logs/system_logs.tar"); | 72 test_data_dir_.Append("log_private/dump_logs/system_logs.tar"); |
73 chromeos::DBusThreadManager::GetSetterForTesting()->SetDebugDaemonClient( | 73 chromeos::DBusThreadManager::GetSetterForTesting()->SetDebugDaemonClient( |
74 scoped_ptr<chromeos::DebugDaemonClient>( | 74 scoped_ptr<chromeos::DebugDaemonClient>( |
75 new TestDebugDaemonClient(tar_file_path))); | 75 new TestDebugDaemonClient(tar_file_path))); |
76 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 76 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
77 } | 77 } |
78 | 78 |
79 scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { | 79 scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { |
80 scoped_ptr<BasicHttpResponse> response(new BasicHttpResponse); | 80 scoped_ptr<BasicHttpResponse> response(new BasicHttpResponse); |
81 response->set_code(net::HTTP_OK); | 81 response->set_code(net::HTTP_OK); |
82 response->set_content( | 82 response->set_content( |
83 "<html><head><title>LogPrivateTest</title>" | 83 "<html><head><title>LogPrivateTest</title>" |
84 "</head><body>Hello!</body></html>"); | 84 "</head><body>Hello!</body></html>"); |
85 return response.PassAs<HttpResponse>(); | 85 return response.PassAs<HttpResponse>(); |
86 } | 86 } |
87 }; | 87 }; |
88 | 88 |
89 IN_PROC_BROWSER_TEST_F(LogPrivateApiTest, DumpLogsAndCaptureEvents) { | 89 IN_PROC_BROWSER_TEST_F(LogPrivateApiTest, DumpLogsAndCaptureEvents) { |
90 // Setup dummy HTTP server. | 90 // Setup dummy HTTP server. |
91 host_resolver()->AddRule("www.test.com", "127.0.0.1"); | 91 host_resolver()->AddRule("www.test.com", "127.0.0.1"); |
92 ASSERT_TRUE(StartEmbeddedTestServer()); | 92 ASSERT_TRUE(StartEmbeddedTestServer()); |
93 embedded_test_server()->RegisterRequestHandler( | 93 embedded_test_server()->RegisterRequestHandler( |
94 base::Bind(&LogPrivateApiTest::HandleRequest, base::Unretained(this))); | 94 base::Bind(&LogPrivateApiTest::HandleRequest, base::Unretained(this))); |
95 | 95 |
96 ASSERT_TRUE(RunExtensionTest("log_private/dump_logs")); | 96 ASSERT_TRUE(RunExtensionTest("log_private/dump_logs")); |
97 } | 97 } |
98 | 98 |
99 } // namespace extensions | 99 } // namespace extensions |
OLD | NEW |