Chromium Code Reviews| 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.h" | 5 #include "chrome/browser/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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 // Set up a delegate to wait for the callback. | 106 // Set up a delegate to wait for the callback. |
| 107 BitmapFetcherTestDelegate delegate(kAsyncCall); | 107 BitmapFetcherTestDelegate delegate(kAsyncCall); |
| 108 | 108 |
| 109 BitmapFetcher fetcher(url, &delegate); | 109 BitmapFetcher fetcher(url, &delegate); |
| 110 | 110 |
| 111 url_fetcher_factory_->SetFakeResponse( | 111 url_fetcher_factory_->SetFakeResponse( |
| 112 url, image_string, net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 112 url, image_string, net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 113 | 113 |
| 114 // We expect that the image decoder will get called and return | 114 // We expect that the image decoder will get called and return |
| 115 // an image in a callback to OnImageDecoded(). | 115 // an image in a callback to OnImageDecoded(). |
| 116 fetcher.Start(browser()->profile()->GetRequestContext()); | 116 fetcher.Start( |
| 117 browser()->profile()->GetRequestContext(), | |
| 118 "", | |
|
sky
2014/05/06 15:24:20
""->std::string() here and every where.
Kibeom Kim (inactive)
2014/05/06 18:07:14
Done.
| |
| 119 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, | |
| 120 net::LOAD_NORMAL); | |
| 117 | 121 |
| 118 // Blocks until test delegate is notified via a callback. | 122 // Blocks until test delegate is notified via a callback. |
| 119 content::RunMessageLoop(); | 123 content::RunMessageLoop(); |
| 120 | 124 |
| 121 ASSERT_TRUE(delegate.success()); | 125 ASSERT_TRUE(delegate.success()); |
| 122 | 126 |
| 123 // Make sure we get back the bitmap we expect. | 127 // Make sure we get back the bitmap we expect. |
| 124 const SkBitmap& found_image = delegate.bitmap(); | 128 const SkBitmap& found_image = delegate.bitmap(); |
| 125 EXPECT_TRUE(gfx::BitmapsAreEqual(image, found_image)); | 129 EXPECT_TRUE(gfx::BitmapsAreEqual(image, found_image)); |
| 126 } | 130 } |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 155 // Set up a delegate to wait for the callback. | 159 // Set up a delegate to wait for the callback. |
| 156 BitmapFetcherTestDelegate delegate(kAsyncCall); | 160 BitmapFetcherTestDelegate delegate(kAsyncCall); |
| 157 | 161 |
| 158 BitmapFetcher fetcher(url, &delegate); | 162 BitmapFetcher fetcher(url, &delegate); |
| 159 | 163 |
| 160 url_fetcher_factory_->SetFakeResponse(url, | 164 url_fetcher_factory_->SetFakeResponse(url, |
| 161 std::string(), | 165 std::string(), |
| 162 net::HTTP_INTERNAL_SERVER_ERROR, | 166 net::HTTP_INTERNAL_SERVER_ERROR, |
| 163 net::URLRequestStatus::FAILED); | 167 net::URLRequestStatus::FAILED); |
| 164 | 168 |
| 165 fetcher.Start(browser()->profile()->GetRequestContext()); | 169 fetcher.Start( |
| 170 browser()->profile()->GetRequestContext(), | |
| 171 "", | |
| 172 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, | |
| 173 net::LOAD_NORMAL); | |
| 166 | 174 |
| 167 // Blocks until test delegate is notified via a callback. | 175 // Blocks until test delegate is notified via a callback. |
| 168 content::RunMessageLoop(); | 176 content::RunMessageLoop(); |
| 169 | 177 |
| 170 EXPECT_FALSE(delegate.success()); | 178 EXPECT_FALSE(delegate.success()); |
| 171 } | 179 } |
| 172 | 180 |
| 173 // Flaky on Win XP Debug: crbug.com/316488 | 181 // Flaky on Win XP Debug: crbug.com/316488 |
| 174 #if defined(OS_WIN) && !defined(NDEBUG) | 182 #if defined(OS_WIN) && !defined(NDEBUG) |
| 175 #define MAYBE_HandleImageFailedTest DISABLED_HandleImageFailedTest | 183 #define MAYBE_HandleImageFailedTest DISABLED_HandleImageFailedTest |
| 176 #else | 184 #else |
| 177 #define MAYBE_HandleImageFailedTest HandleImageFailedTest | 185 #define MAYBE_HandleImageFailedTest HandleImageFailedTest |
| 178 #endif | 186 #endif |
| 179 | 187 |
| 180 IN_PROC_BROWSER_TEST_F(BitmapFetcherBrowserTest, MAYBE_HandleImageFailedTest) { | 188 IN_PROC_BROWSER_TEST_F(BitmapFetcherBrowserTest, MAYBE_HandleImageFailedTest) { |
| 181 GURL url("http://example.com/this-should-be-a-decode-failure"); | 189 GURL url("http://example.com/this-should-be-a-decode-failure"); |
| 182 BitmapFetcherTestDelegate delegate(kAsyncCall); | 190 BitmapFetcherTestDelegate delegate(kAsyncCall); |
| 183 BitmapFetcher fetcher(url, &delegate); | 191 BitmapFetcher fetcher(url, &delegate); |
| 184 url_fetcher_factory_->SetFakeResponse(url, | 192 url_fetcher_factory_->SetFakeResponse(url, |
| 185 std::string("Not a real bitmap"), | 193 std::string("Not a real bitmap"), |
| 186 net::HTTP_OK, | 194 net::HTTP_OK, |
| 187 net::URLRequestStatus::SUCCESS); | 195 net::URLRequestStatus::SUCCESS); |
| 188 | 196 |
| 189 fetcher.Start(browser()->profile()->GetRequestContext()); | 197 fetcher.Start( |
| 198 browser()->profile()->GetRequestContext(), | |
| 199 "", | |
| 200 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, | |
| 201 net::LOAD_NORMAL); | |
| 190 | 202 |
| 191 // Blocks until test delegate is notified via a callback. | 203 // Blocks until test delegate is notified via a callback. |
| 192 content::RunMessageLoop(); | 204 content::RunMessageLoop(); |
| 193 | 205 |
| 194 EXPECT_FALSE(delegate.success()); | 206 EXPECT_FALSE(delegate.success()); |
| 195 } | 207 } |
| 196 | 208 |
| 197 } // namespace chrome | 209 } // namespace chrome |
| OLD | NEW |