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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 ASSERT_TRUE(expected_logo.encoded_image.get()); | 87 ASSERT_TRUE(expected_logo.encoded_image.get()); |
88 ASSERT_TRUE(actual_logo.encoded_image.get()); | 88 ASSERT_TRUE(actual_logo.encoded_image.get()); |
89 EXPECT_TRUE(expected_logo.encoded_image->Equals(actual_logo.encoded_image)); | 89 EXPECT_TRUE(expected_logo.encoded_image->Equals(actual_logo.encoded_image)); |
90 ExpectMetadataEqual(expected_logo.metadata, actual_logo.metadata); | 90 ExpectMetadataEqual(expected_logo.metadata, actual_logo.metadata); |
91 } | 91 } |
92 | 92 |
93 // Removes 1 byte from the end of the file at |path|. | 93 // Removes 1 byte from the end of the file at |path|. |
94 void ShortenFile(base::FilePath path) { | 94 void ShortenFile(base::FilePath path) { |
95 base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_WRITE); | 95 base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_WRITE); |
96 int64_t file_length = file.GetLength(); | 96 int64_t file_length = file.GetLength(); |
97 ASSERT_NE(file_length, 0); | 97 ASSERT_GT(file_length, 0); |
98 file.SetLength(file_length - 1); | 98 file.SetLength(file_length - 1); |
99 } | 99 } |
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 |
(...skipping 140 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 |