| 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 "net/tools/flip_server/mem_cache.h" | 5 #include "net/tools/flip_server/mem_cache.h" |
| 6 | 6 |
| 7 #include "net/tools/balsa/balsa_headers.h" | 7 #include "net/tools/balsa/balsa_headers.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 class MemoryCacheWithFakeReadToString : public MemoryCache { | 14 class MemoryCacheWithFakeReadToString : public MemoryCache { |
| 15 public: | 15 public: |
| 16 virtual ~MemoryCacheWithFakeReadToString() {} | 16 virtual ~MemoryCacheWithFakeReadToString() {} |
| 17 | 17 |
| 18 virtual void ReadToString(const char* filename, | 18 virtual void ReadToString(const char* filename, |
| 19 std::string* output) OVERRIDE { | 19 std::string* output) override { |
| 20 *output = data_map_[filename]; | 20 *output = data_map_[filename]; |
| 21 } | 21 } |
| 22 | 22 |
| 23 std::map<std::string, std::string> data_map_; | 23 std::map<std::string, std::string> data_map_; |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 class FlipMemoryCacheTest : public ::testing::Test { | 26 class FlipMemoryCacheTest : public ::testing::Test { |
| 27 public: | 27 public: |
| 28 FlipMemoryCacheTest() : mem_cache_(new MemoryCacheWithFakeReadToString) {} | 28 FlipMemoryCacheTest() : mem_cache_(new MemoryCacheWithFakeReadToString) {} |
| 29 | 29 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 mem_cache_->ReadAndStoreFileContents("./hello.http"); | 93 mem_cache_->ReadAndStoreFileContents("./hello.http"); |
| 94 hello_html = mem_cache_->GetFileData("hello.html"); | 94 hello_html = mem_cache_->GetFileData("hello.html"); |
| 95 ASSERT_FALSE(NULL == hello_html); | 95 ASSERT_FALSE(NULL == hello_html); |
| 96 ASSERT_EQ(hello_html, mem_cache_->GetFileData("hello.http")); | 96 ASSERT_EQ(hello_html, mem_cache_->GetFileData("hello.http")); |
| 97 } | 97 } |
| 98 | 98 |
| 99 } // namespace | 99 } // namespace |
| 100 | 100 |
| 101 } // namespace net | 101 } // namespace net |
| OLD | NEW |