| 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 "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" | 5 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 explicit BitmapFetcherTestDelegate(bool async) : called_(false), | 31 explicit BitmapFetcherTestDelegate(bool async) : called_(false), |
| 32 success_(false), | 32 success_(false), |
| 33 async_(async) {} | 33 async_(async) {} |
| 34 | 34 |
| 35 virtual ~BitmapFetcherTestDelegate() { | 35 virtual ~BitmapFetcherTestDelegate() { |
| 36 EXPECT_TRUE(called_); | 36 EXPECT_TRUE(called_); |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Method inherited from BitmapFetcherDelegate. | 39 // Method inherited from BitmapFetcherDelegate. |
| 40 virtual void OnFetchComplete(const GURL url, | 40 virtual void OnFetchComplete(const GURL url, |
| 41 const SkBitmap* bitmap) OVERRIDE { | 41 const SkBitmap* bitmap) override { |
| 42 called_ = true; | 42 called_ = true; |
| 43 url_ = url; | 43 url_ = url; |
| 44 if (bitmap) { | 44 if (bitmap) { |
| 45 success_ = true; | 45 success_ = true; |
| 46 bitmap->deepCopyTo(&bitmap_); | 46 bitmap->deepCopyTo(&bitmap_); |
| 47 } | 47 } |
| 48 // For async calls, we need to quit the run loop so the test can continue. | 48 // For async calls, we need to quit the run loop so the test can continue. |
| 49 if (async_) | 49 if (async_) |
| 50 run_loop_.Quit(); | 50 run_loop_.Quit(); |
| 51 } | 51 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 67 GURL url_; | 67 GURL url_; |
| 68 bool success_; | 68 bool success_; |
| 69 bool async_; | 69 bool async_; |
| 70 SkBitmap bitmap_; | 70 SkBitmap bitmap_; |
| 71 | 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(BitmapFetcherTestDelegate); | 72 DISALLOW_COPY_AND_ASSIGN(BitmapFetcherTestDelegate); |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 class BitmapFetcherBrowserTest : public InProcessBrowserTest { | 75 class BitmapFetcherBrowserTest : public InProcessBrowserTest { |
| 76 public: | 76 public: |
| 77 virtual void SetUp() OVERRIDE { | 77 virtual void SetUp() override { |
| 78 url_fetcher_factory_.reset( | 78 url_fetcher_factory_.reset( |
| 79 new net::FakeURLFetcherFactory(&url_fetcher_impl_factory_)); | 79 new net::FakeURLFetcherFactory(&url_fetcher_impl_factory_)); |
| 80 InProcessBrowserTest::SetUp(); | 80 InProcessBrowserTest::SetUp(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 protected: | 83 protected: |
| 84 net::URLFetcherImplFactory url_fetcher_impl_factory_; | 84 net::URLFetcherImplFactory url_fetcher_impl_factory_; |
| 85 scoped_ptr<net::FakeURLFetcherFactory> url_fetcher_factory_; | 85 scoped_ptr<net::FakeURLFetcherFactory> url_fetcher_factory_; |
| 86 }; | 86 }; |
| 87 | 87 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, | 195 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, |
| 196 net::LOAD_NORMAL); | 196 net::LOAD_NORMAL); |
| 197 | 197 |
| 198 // Blocks until test delegate is notified via a callback. | 198 // Blocks until test delegate is notified via a callback. |
| 199 delegate.Wait(); | 199 delegate.Wait(); |
| 200 | 200 |
| 201 EXPECT_FALSE(delegate.success()); | 201 EXPECT_FALSE(delegate.success()); |
| 202 } | 202 } |
| 203 | 203 |
| 204 } // namespace chrome | 204 } // namespace chrome |
| OLD | NEW |