Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: chrome/browser/bitmap_fetcher_browsertest.cc

Issue 253623002: Remove BitmapFetcher's dependency on Profile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
9 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
10 #include "content/public/test/test_utils.h" 11 #include "content/public/test/test_utils.h"
11 #include "net/http/http_status_code.h" 12 #include "net/http/http_status_code.h"
12 #include "net/url_request/test_url_fetcher_factory.h" 13 #include "net/url_request/test_url_fetcher_factory.h"
13 #include "net/url_request/url_fetcher.h" 14 #include "net/url_request/url_fetcher.h"
14 #include "net/url_request/url_request_status.h" 15 #include "net/url_request/url_request_status.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/skia/include/core/SkBitmap.h" 17 #include "third_party/skia/include/core/SkBitmap.h"
17 #include "ui/gfx/codec/png_codec.h" 18 #include "ui/gfx/codec/png_codec.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // Set up a delegate to wait for the callback. 106 // Set up a delegate to wait for the callback.
106 BitmapFetcherTestDelegate delegate(kAsyncCall); 107 BitmapFetcherTestDelegate delegate(kAsyncCall);
107 108
108 BitmapFetcher fetcher(url, &delegate); 109 BitmapFetcher fetcher(url, &delegate);
109 110
110 url_fetcher_factory_->SetFakeResponse( 111 url_fetcher_factory_->SetFakeResponse(
111 url, image_string, net::HTTP_OK, net::URLRequestStatus::SUCCESS); 112 url, image_string, net::HTTP_OK, net::URLRequestStatus::SUCCESS);
112 113
113 // We expect that the image decoder will get called and return 114 // We expect that the image decoder will get called and return
114 // an image in a callback to OnImageDecoded(). 115 // an image in a callback to OnImageDecoded().
115 fetcher.Start(browser()->profile()); 116 fetcher.Start(browser()->profile()->GetRequestContext());
116 117
117 // Blocks until test delegate is notified via a callback. 118 // Blocks until test delegate is notified via a callback.
118 content::RunMessageLoop(); 119 content::RunMessageLoop();
119 120
120 ASSERT_TRUE(delegate.success()); 121 ASSERT_TRUE(delegate.success());
121 122
122 // Make sure we get back the bitmap we expect. 123 // Make sure we get back the bitmap we expect.
123 const SkBitmap& found_image = delegate.bitmap(); 124 const SkBitmap& found_image = delegate.bitmap();
124 EXPECT_TRUE(gfx::BitmapsAreEqual(image, found_image)); 125 EXPECT_TRUE(gfx::BitmapsAreEqual(image, found_image));
125 } 126 }
(...skipping 28 matching lines...) Expand all
154 // Set up a delegate to wait for the callback. 155 // Set up a delegate to wait for the callback.
155 BitmapFetcherTestDelegate delegate(kAsyncCall); 156 BitmapFetcherTestDelegate delegate(kAsyncCall);
156 157
157 BitmapFetcher fetcher(url, &delegate); 158 BitmapFetcher fetcher(url, &delegate);
158 159
159 url_fetcher_factory_->SetFakeResponse(url, 160 url_fetcher_factory_->SetFakeResponse(url,
160 std::string(), 161 std::string(),
161 net::HTTP_INTERNAL_SERVER_ERROR, 162 net::HTTP_INTERNAL_SERVER_ERROR,
162 net::URLRequestStatus::FAILED); 163 net::URLRequestStatus::FAILED);
163 164
164 fetcher.Start(browser()->profile()); 165 fetcher.Start(browser()->profile()->GetRequestContext());
165 166
166 // Blocks until test delegate is notified via a callback. 167 // Blocks until test delegate is notified via a callback.
167 content::RunMessageLoop(); 168 content::RunMessageLoop();
168 169
169 EXPECT_FALSE(delegate.success()); 170 EXPECT_FALSE(delegate.success());
170 } 171 }
171 172
172 // Flaky on Win XP Debug: crbug.com/316488 173 // Flaky on Win XP Debug: crbug.com/316488
173 #if defined(OS_WIN) && !defined(NDEBUG) 174 #if defined(OS_WIN) && !defined(NDEBUG)
174 #define MAYBE_HandleImageFailedTest DISABLED_HandleImageFailedTest 175 #define MAYBE_HandleImageFailedTest DISABLED_HandleImageFailedTest
175 #else 176 #else
176 #define MAYBE_HandleImageFailedTest HandleImageFailedTest 177 #define MAYBE_HandleImageFailedTest HandleImageFailedTest
177 #endif 178 #endif
178 179
179 IN_PROC_BROWSER_TEST_F(BitmapFetcherBrowserTest, MAYBE_HandleImageFailedTest) { 180 IN_PROC_BROWSER_TEST_F(BitmapFetcherBrowserTest, MAYBE_HandleImageFailedTest) {
180 GURL url("http://example.com/this-should-be-a-decode-failure"); 181 GURL url("http://example.com/this-should-be-a-decode-failure");
181 BitmapFetcherTestDelegate delegate(kAsyncCall); 182 BitmapFetcherTestDelegate delegate(kAsyncCall);
182 BitmapFetcher fetcher(url, &delegate); 183 BitmapFetcher fetcher(url, &delegate);
183 url_fetcher_factory_->SetFakeResponse(url, 184 url_fetcher_factory_->SetFakeResponse(url,
184 std::string("Not a real bitmap"), 185 std::string("Not a real bitmap"),
185 net::HTTP_OK, 186 net::HTTP_OK,
186 net::URLRequestStatus::SUCCESS); 187 net::URLRequestStatus::SUCCESS);
187 188
188 fetcher.Start(browser()->profile()); 189 fetcher.Start(browser()->profile()->GetRequestContext());
189 190
190 // Blocks until test delegate is notified via a callback. 191 // Blocks until test delegate is notified via a callback.
191 content::RunMessageLoop(); 192 content::RunMessageLoop();
192 193
193 EXPECT_FALSE(delegate.success()); 194 EXPECT_FALSE(delegate.success());
194 } 195 }
195 196
196 } // namespace chrome 197 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/bitmap_fetcher.cc ('k') | chrome/browser/notifications/sync_notifier/image_holder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698