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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 EXPECT_EQ(expected_metadata.can_show_after_expiration, | 72 EXPECT_EQ(expected_metadata.can_show_after_expiration, |
73 actual_metadata.can_show_after_expiration); | 73 actual_metadata.can_show_after_expiration); |
74 EXPECT_EQ(expected_metadata.expiration_time, actual_metadata.expiration_time); | 74 EXPECT_EQ(expected_metadata.expiration_time, actual_metadata.expiration_time); |
75 EXPECT_EQ(expected_metadata.on_click_url, actual_metadata.on_click_url); | 75 EXPECT_EQ(expected_metadata.on_click_url, actual_metadata.on_click_url); |
76 EXPECT_EQ(expected_metadata.alt_text, actual_metadata.alt_text); | 76 EXPECT_EQ(expected_metadata.alt_text, actual_metadata.alt_text); |
77 EXPECT_EQ(expected_metadata.mime_type, actual_metadata.mime_type); | 77 EXPECT_EQ(expected_metadata.mime_type, actual_metadata.mime_type); |
78 } | 78 } |
79 | 79 |
80 void ExpectLogosEqual(const EncodedLogo& expected_logo, | 80 void ExpectLogosEqual(const EncodedLogo& expected_logo, |
81 const EncodedLogo& actual_logo) { | 81 const EncodedLogo& actual_logo) { |
82 ASSERT_TRUE(expected_logo.encoded_image); | 82 ASSERT_TRUE(expected_logo.encoded_image.get()); |
83 ASSERT_TRUE(actual_logo.encoded_image); | 83 ASSERT_TRUE(actual_logo.encoded_image.get()); |
84 EXPECT_TRUE(expected_logo.encoded_image->Equals(actual_logo.encoded_image)); | 84 EXPECT_TRUE(expected_logo.encoded_image->Equals(actual_logo.encoded_image)); |
85 ExpectMetadataEqual(expected_logo.metadata, actual_logo.metadata); | 85 ExpectMetadataEqual(expected_logo.metadata, actual_logo.metadata); |
86 } | 86 } |
87 | 87 |
88 // Removes 1 byte from the end of the file at |path|. | 88 // Removes 1 byte from the end of the file at |path|. |
89 void ShortenFile(base::FilePath path) { | 89 void ShortenFile(base::FilePath path) { |
90 base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_WRITE); | 90 base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_WRITE); |
91 int64 file_length = file.GetLength(); | 91 int64 file_length = file.GetLength(); |
92 ASSERT_NE(file_length, 0); | 92 ASSERT_NE(file_length, 0); |
93 file.SetLength(file_length - 1); | 93 file.SetLength(file_length - 1); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 ExpectLogo(NULL); | 243 ExpectLogo(NULL); |
244 // Once the logo is noticed to be NULL, the metadata should also be cleared. | 244 // Once the logo is noticed to be NULL, the metadata should also be cleared. |
245 ExpectMetadata(NULL); | 245 ExpectMetadata(NULL); |
246 | 246 |
247 // Ensure corrupt cache files are deleted. | 247 // Ensure corrupt cache files are deleted. |
248 EXPECT_FALSE(base::PathExists(cache_->GetMetadataPath())); | 248 EXPECT_FALSE(base::PathExists(cache_->GetMetadataPath())); |
249 EXPECT_FALSE(base::PathExists(cache_->GetLogoPath())); | 249 EXPECT_FALSE(base::PathExists(cache_->GetLogoPath())); |
250 } | 250 } |
251 | 251 |
252 } // namespace search_provider_logos | 252 } // namespace search_provider_logos |
OLD | NEW |