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_tracker.h" | 5 #include "components/search_provider_logos/logo_tracker.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 215 |
216 virtual const LogoMetadata* GetCachedLogoMetadataInternal() { | 216 virtual const LogoMetadata* GetCachedLogoMetadataInternal() { |
217 return metadata_.get(); | 217 return metadata_.get(); |
218 } | 218 } |
219 | 219 |
220 virtual void SetCachedLogoInternal(const EncodedLogo* logo) { | 220 virtual void SetCachedLogoInternal(const EncodedLogo* logo) { |
221 logo_.reset(logo ? new EncodedLogo(*logo) : NULL); | 221 logo_.reset(logo ? new EncodedLogo(*logo) : NULL); |
222 metadata_.reset(logo ? new LogoMetadata(logo->metadata) : NULL); | 222 metadata_.reset(logo ? new LogoMetadata(logo->metadata) : NULL); |
223 } | 223 } |
224 | 224 |
225 virtual scoped_ptr<EncodedLogo> GetCachedLogo() OVERRIDE { | 225 virtual scoped_ptr<EncodedLogo> GetCachedLogo() override { |
226 OnGetCachedLogo(); | 226 OnGetCachedLogo(); |
227 return make_scoped_ptr(logo_ ? new EncodedLogo(*logo_) : NULL); | 227 return make_scoped_ptr(logo_ ? new EncodedLogo(*logo_) : NULL); |
228 } | 228 } |
229 | 229 |
230 private: | 230 private: |
231 scoped_ptr<LogoMetadata> metadata_; | 231 scoped_ptr<LogoMetadata> metadata_; |
232 scoped_ptr<EncodedLogo> logo_; | 232 scoped_ptr<EncodedLogo> logo_; |
233 }; | 233 }; |
234 | 234 |
235 class MockLogoObserver : public LogoObserver { | 235 class MockLogoObserver : public LogoObserver { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 MOCK_METHOD0(OnObserverRemoved, void()); | 274 MOCK_METHOD0(OnObserverRemoved, void()); |
275 }; | 275 }; |
276 | 276 |
277 class TestLogoDelegate : public LogoDelegate { | 277 class TestLogoDelegate : public LogoDelegate { |
278 public: | 278 public: |
279 TestLogoDelegate() {} | 279 TestLogoDelegate() {} |
280 virtual ~TestLogoDelegate() {} | 280 virtual ~TestLogoDelegate() {} |
281 | 281 |
282 virtual void DecodeUntrustedImage( | 282 virtual void DecodeUntrustedImage( |
283 const scoped_refptr<base::RefCountedString>& encoded_image, | 283 const scoped_refptr<base::RefCountedString>& encoded_image, |
284 base::Callback<void(const SkBitmap&)> image_decoded_callback) OVERRIDE { | 284 base::Callback<void(const SkBitmap&)> image_decoded_callback) override { |
285 SkBitmap bitmap = | 285 SkBitmap bitmap = |
286 gfx::Image::CreateFrom1xPNGBytes(encoded_image->front(), | 286 gfx::Image::CreateFrom1xPNGBytes(encoded_image->front(), |
287 encoded_image->size()).AsBitmap(); | 287 encoded_image->size()).AsBitmap(); |
288 base::MessageLoopProxy::current()->PostTask( | 288 base::MessageLoopProxy::current()->PostTask( |
289 FROM_HERE, base::Bind(image_decoded_callback, bitmap)); | 289 FROM_HERE, base::Bind(image_decoded_callback, bitmap)); |
290 } | 290 } |
291 }; | 291 }; |
292 | 292 |
293 class LogoTrackerTest : public ::testing::Test { | 293 class LogoTrackerTest : public ::testing::Test { |
294 protected: | 294 protected: |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 MockLogoObserver listener2; | 668 MockLogoObserver listener2; |
669 listener2.ExpectFreshLogo(&logo); | 669 listener2.ExpectFreshLogo(&logo); |
670 logo_tracker_->GetLogo(&listener2); | 670 logo_tracker_->GetLogo(&listener2); |
671 | 671 |
672 base::RunLoop().RunUntilIdle(); | 672 base::RunLoop().RunUntilIdle(); |
673 } | 673 } |
674 | 674 |
675 } // namespace | 675 } // namespace |
676 | 676 |
677 } // namespace search_provider_logos | 677 } // namespace search_provider_logos |
OLD | NEW |