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 "components/search_provider_logos/logo_cache.h" | 5 #include "components/search_provider_logos/logo_cache.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 class LogoCacheTest : public ::testing::Test { | 101 class LogoCacheTest : public ::testing::Test { |
102 protected: | 102 protected: |
103 void SetUp() override { | 103 void SetUp() override { |
104 ASSERT_TRUE(cache_parent_dir_.CreateUniqueTempDir()); | 104 ASSERT_TRUE(cache_parent_dir_.CreateUniqueTempDir()); |
105 InitCache(); | 105 InitCache(); |
106 } | 106 } |
107 | 107 |
108 void InitCache() { | 108 void InitCache() { |
109 cache_.reset(new LogoCache( | 109 cache_.reset(new LogoCache( |
110 cache_parent_dir_.path().Append(FILE_PATH_LITERAL("cache")))); | 110 cache_parent_dir_.GetPath().Append(FILE_PATH_LITERAL("cache")))); |
111 } | 111 } |
112 | 112 |
113 void ExpectMetadata(const LogoMetadata* expected_metadata) { | 113 void ExpectMetadata(const LogoMetadata* expected_metadata) { |
114 const LogoMetadata* retrieved_metadata = cache_->GetCachedLogoMetadata(); | 114 const LogoMetadata* retrieved_metadata = cache_->GetCachedLogoMetadata(); |
115 if (expected_metadata) { | 115 if (expected_metadata) { |
116 ASSERT_TRUE(retrieved_metadata != NULL); | 116 ASSERT_TRUE(retrieved_metadata != NULL); |
117 ExpectMetadataEqual(*expected_metadata, *retrieved_metadata); | 117 ExpectMetadataEqual(*expected_metadata, *retrieved_metadata); |
118 } else { | 118 } else { |
119 ASSERT_TRUE(retrieved_metadata == NULL); | 119 ASSERT_TRUE(retrieved_metadata == NULL); |
120 } | 120 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 ExpectLogo(NULL); | 248 ExpectLogo(NULL); |
249 // Once the logo is noticed to be NULL, the metadata should also be cleared. | 249 // Once the logo is noticed to be NULL, the metadata should also be cleared. |
250 ExpectMetadata(NULL); | 250 ExpectMetadata(NULL); |
251 | 251 |
252 // Ensure corrupt cache files are deleted. | 252 // Ensure corrupt cache files are deleted. |
253 EXPECT_FALSE(base::PathExists(cache_->GetMetadataPath())); | 253 EXPECT_FALSE(base::PathExists(cache_->GetMetadataPath())); |
254 EXPECT_FALSE(base::PathExists(cache_->GetLogoPath())); | 254 EXPECT_FALSE(base::PathExists(cache_->GetLogoPath())); |
255 } | 255 } |
256 | 256 |
257 } // namespace search_provider_logos | 257 } // namespace search_provider_logos |
OLD | NEW |