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> |
| 8 #include <stdint.h> |
| 9 |
7 #include <string> | 10 #include <string> |
8 | 11 |
9 #include "base/bind.h" | 12 #include "base/bind.h" |
10 #include "base/callback.h" | 13 #include "base/callback.h" |
11 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
12 #include "base/files/scoped_temp_dir.h" | 15 #include "base/files/scoped_temp_dir.h" |
13 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
14 #include "base/time/time.h" | 17 #include "base/time/time.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
16 | 19 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 const EncodedLogo& actual_logo) { | 86 const EncodedLogo& actual_logo) { |
84 ASSERT_TRUE(expected_logo.encoded_image.get()); | 87 ASSERT_TRUE(expected_logo.encoded_image.get()); |
85 ASSERT_TRUE(actual_logo.encoded_image.get()); | 88 ASSERT_TRUE(actual_logo.encoded_image.get()); |
86 EXPECT_TRUE(expected_logo.encoded_image->Equals(actual_logo.encoded_image)); | 89 EXPECT_TRUE(expected_logo.encoded_image->Equals(actual_logo.encoded_image)); |
87 ExpectMetadataEqual(expected_logo.metadata, actual_logo.metadata); | 90 ExpectMetadataEqual(expected_logo.metadata, actual_logo.metadata); |
88 } | 91 } |
89 | 92 |
90 // Removes 1 byte from the end of the file at |path|. | 93 // Removes 1 byte from the end of the file at |path|. |
91 void ShortenFile(base::FilePath path) { | 94 void ShortenFile(base::FilePath path) { |
92 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); |
93 int64 file_length = file.GetLength(); | 96 int64_t file_length = file.GetLength(); |
94 ASSERT_NE(file_length, 0); | 97 ASSERT_NE(file_length, 0); |
95 file.SetLength(file_length - 1); | 98 file.SetLength(file_length - 1); |
96 } | 99 } |
97 | 100 |
98 class LogoCacheTest : public ::testing::Test { | 101 class LogoCacheTest : public ::testing::Test { |
99 protected: | 102 protected: |
100 void SetUp() override { | 103 void SetUp() override { |
101 ASSERT_TRUE(cache_parent_dir_.CreateUniqueTempDir()); | 104 ASSERT_TRUE(cache_parent_dir_.CreateUniqueTempDir()); |
102 InitCache(); | 105 InitCache(); |
103 } | 106 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 ExpectLogo(NULL); | 248 ExpectLogo(NULL); |
246 // 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. |
247 ExpectMetadata(NULL); | 250 ExpectMetadata(NULL); |
248 | 251 |
249 // Ensure corrupt cache files are deleted. | 252 // Ensure corrupt cache files are deleted. |
250 EXPECT_FALSE(base::PathExists(cache_->GetMetadataPath())); | 253 EXPECT_FALSE(base::PathExists(cache_->GetMetadataPath())); |
251 EXPECT_FALSE(base::PathExists(cache_->GetLogoPath())); | 254 EXPECT_FALSE(base::PathExists(cache_->GetLogoPath())); |
252 } | 255 } |
253 | 256 |
254 } // namespace search_provider_logos | 257 } // namespace search_provider_logos |
OLD | NEW |