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 "base/macros.h" | 8 #include "base/macros.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 async_(async) {} | 35 async_(async) {} |
36 | 36 |
37 ~BitmapFetcherTestDelegate() override { EXPECT_TRUE(called_); } | 37 ~BitmapFetcherTestDelegate() override { EXPECT_TRUE(called_); } |
38 | 38 |
39 // Method inherited from BitmapFetcherDelegate. | 39 // Method inherited from BitmapFetcherDelegate. |
40 void OnFetchComplete(const GURL& url, const SkBitmap* bitmap) override { | 40 void OnFetchComplete(const GURL& url, const SkBitmap* bitmap) override { |
41 called_ = true; | 41 called_ = true; |
42 url_ = url; | 42 url_ = url; |
43 if (bitmap) { | 43 if (bitmap) { |
44 success_ = true; | 44 success_ = true; |
45 bitmap->deepCopyTo(&bitmap_); | 45 if (bitmap_.tryAllocPixels(bitmap->info())) { |
| 46 bitmap->readPixels(bitmap_.info(), bitmap_.getPixels(), |
| 47 bitmap_.rowBytes(), 0, 0); |
| 48 } |
46 } | 49 } |
47 // For async calls, we need to quit the run loop so the test can continue. | 50 // For async calls, we need to quit the run loop so the test can continue. |
48 if (async_) | 51 if (async_) |
49 run_loop_.Quit(); | 52 run_loop_.Quit(); |
50 } | 53 } |
51 | 54 |
52 // Waits until OnFetchComplete() is called. Should only be used for | 55 // Waits until OnFetchComplete() is called. Should only be used for |
53 // async tests. | 56 // async tests. |
54 void Wait() { | 57 void Wait() { |
55 ASSERT_TRUE(async_); | 58 ASSERT_TRUE(async_); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 net::LOAD_NORMAL); | 200 net::LOAD_NORMAL); |
198 fetcher.Start(); | 201 fetcher.Start(); |
199 | 202 |
200 // Blocks until test delegate is notified via a callback. | 203 // Blocks until test delegate is notified via a callback. |
201 delegate.Wait(); | 204 delegate.Wait(); |
202 | 205 |
203 EXPECT_FALSE(delegate.success()); | 206 EXPECT_FALSE(delegate.success()); |
204 } | 207 } |
205 | 208 |
206 } // namespace chrome | 209 } // namespace chrome |
OLD | NEW |