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 "base/files/file_util.h" | 5 #include "base/files/file_util.h" |
6 #include "mojo/public/cpp/application/connect.h" | 6 #include "mojo/public/cpp/application/connect.h" |
7 #include "services/js/test/js_application_test_base.h" | 7 #include "services/js/test/js_application_test_base.h" |
8 #include "services/js/test/network_test_service.mojom.h" | 8 #include "services/js/test/network_test_service.mojom.h" |
9 | 9 |
10 namespace js { | 10 namespace js { |
11 namespace { | 11 namespace { |
12 | 12 |
13 class JSNetworkTest : public test::JSApplicationTestBase { | 13 class JSNetworkTest : public test::JSApplicationTestBase { |
14 public: | 14 public: |
15 JSNetworkTest() : JSApplicationTestBase() {} | 15 JSNetworkTest() : JSApplicationTestBase() {} |
16 ~JSNetworkTest() override {} | 16 ~JSNetworkTest() override {} |
17 | 17 |
18 protected: | 18 protected: |
19 // ApplicationTestBase: | 19 // ApplicationTestBase: |
20 void SetUp() override { | 20 void SetUp() override { |
21 ApplicationTestBase::SetUp(); | 21 ApplicationTestBase::SetUp(); |
22 const std::string& url = JSAppURL("network_test.js"); | 22 const std::string& url = JSAppURL("network_test.js"); |
23 mojo::ConnectToService(application_impl()->shell(), url, | 23 mojo::ConnectToService(shell(), url, GetProxy(&network_test_service_)); |
24 GetProxy(&network_test_service_)); | |
25 } | 24 } |
26 | 25 |
27 NetworkTestServicePtr network_test_service_; | 26 NetworkTestServicePtr network_test_service_; |
28 | 27 |
29 private: | 28 private: |
30 MOJO_DISALLOW_COPY_AND_ASSIGN(JSNetworkTest); | 29 MOJO_DISALLOW_COPY_AND_ASSIGN(JSNetworkTest); |
31 }; | 30 }; |
32 | 31 |
33 struct GetFileSizeCallback { | 32 struct GetFileSizeCallback { |
34 GetFileSizeCallback(bool* b, uint64* s) : ok(b), size(s) {} | 33 GetFileSizeCallback(bool* b, uint64* s) : ok(b), size(s) {} |
(...skipping 20 matching lines...) Expand all Loading... |
55 network_test_service_->GetFileSize(JSAppURL(filename), callback); | 54 network_test_service_->GetFileSize(JSAppURL(filename), callback); |
56 EXPECT_TRUE(network_test_service_.WaitForIncomingResponse()); | 55 EXPECT_TRUE(network_test_service_.WaitForIncomingResponse()); |
57 EXPECT_TRUE(file_size_ok); | 56 EXPECT_TRUE(file_size_ok); |
58 EXPECT_EQ(file_size, static_cast<uint64>(expected_file_size)); | 57 EXPECT_EQ(file_size, static_cast<uint64>(expected_file_size)); |
59 network_test_service_->Quit(); | 58 network_test_service_->Quit(); |
60 } | 59 } |
61 | 60 |
62 } // namespace | 61 } // namespace |
63 } // namespace js | 62 } // namespace js |
64 | 63 |
OLD | NEW |