OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/rand_util.h" | 6 #include "base/rand_util.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "mojo/public/cpp/application/application_impl.h" | |
10 #include "mojo/public/cpp/application/application_test_base.h" | 9 #include "mojo/public/cpp/application/application_test_base.h" |
11 #include "mojo/public/cpp/application/connect.h" | 10 #include "mojo/public/cpp/application/connect.h" |
12 #include "mojo/public/cpp/system/data_pipe.h" | 11 #include "mojo/public/cpp/system/data_pipe.h" |
13 #include "mojo/services/network/interfaces/url_loader.mojom.h" | 12 #include "mojo/services/network/interfaces/url_loader.mojom.h" |
14 #include "mojo/services/url_response_disk_cache/interfaces/url_response_disk_cac
he.mojom.h" | 13 #include "mojo/services/url_response_disk_cache/interfaces/url_response_disk_cac
he.mojom.h" |
15 #include "services/url_response_disk_cache/kTestData.h" | 14 #include "services/url_response_disk_cache/kTestData.h" |
16 | 15 |
17 namespace mojo { | 16 namespace mojo { |
18 | 17 |
19 namespace { | 18 namespace { |
20 | 19 |
21 class URLResponseDiskCacheAppTest : public mojo::test::ApplicationTestBase { | 20 class URLResponseDiskCacheAppTest : public mojo::test::ApplicationTestBase { |
22 public: | 21 public: |
23 URLResponseDiskCacheAppTest() : ApplicationTestBase() {} | 22 URLResponseDiskCacheAppTest() : ApplicationTestBase() {} |
24 ~URLResponseDiskCacheAppTest() override {} | 23 ~URLResponseDiskCacheAppTest() override {} |
25 | 24 |
26 void SetUp() override { | 25 void SetUp() override { |
27 test::ApplicationTestBase::SetUp(); | 26 test::ApplicationTestBase::SetUp(); |
28 ConnectToService(application_impl()->shell(), | 27 ConnectToService(shell(), "mojo:url_response_disk_cache", |
29 "mojo:url_response_disk_cache", | |
30 GetProxy(&url_response_disk_cache_)); | 28 GetProxy(&url_response_disk_cache_)); |
31 } | 29 } |
32 | 30 |
33 protected: | 31 protected: |
34 URLResponseDiskCachePtr url_response_disk_cache_; | 32 URLResponseDiskCachePtr url_response_disk_cache_; |
35 | 33 |
36 DISALLOW_COPY_AND_ASSIGN(URLResponseDiskCacheAppTest); | 34 DISALLOW_COPY_AND_ASSIGN(URLResponseDiskCacheAppTest); |
37 }; | 35 }; |
38 | 36 |
39 base::FilePath toPath(Array<uint8_t> path) { | 37 base::FilePath toPath(Array<uint8_t> path) { |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 }); | 321 }); |
324 url_response_disk_cache_.WaitForIncomingResponse(); | 322 url_response_disk_cache_.WaitForIncomingResponse(); |
325 ASSERT_FALSE(file.empty()); | 323 ASSERT_FALSE(file.empty()); |
326 ASSERT_TRUE(base::ReadFileToString(file, &received_content)); | 324 ASSERT_TRUE(base::ReadFileToString(file, &received_content)); |
327 EXPECT_EQ(new_content, received_content); | 325 EXPECT_EQ(new_content, received_content); |
328 saved_file = cache_dir.Append("file"); | 326 saved_file = cache_dir.Append("file"); |
329 EXPECT_FALSE(base::PathExists(saved_file)); | 327 EXPECT_FALSE(base::PathExists(saved_file)); |
330 } | 328 } |
331 | 329 |
332 } // namespace mojo | 330 } // namespace mojo |
OLD | NEW |