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

Unified Diff: chrome/browser/bitmap_fetcher_browsertest.cc

Issue 155273002: Repurpose NotificationBitmapFetcher to BitmapFetcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing comments Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/bitmap_fetcher_browsertest.cc
diff --git a/chrome/browser/notifications/sync_notifier/notification_bitmap_fetcher_browsertest.cc b/chrome/browser/bitmap_fetcher_browsertest.cc
similarity index 74%
rename from chrome/browser/notifications/sync_notifier/notification_bitmap_fetcher_browsertest.cc
rename to chrome/browser/bitmap_fetcher_browsertest.cc
index 43092428278ca8a48fd303a2b804f50ebbe6887f..a67ded721d7a79c8d5ab6fdb4bc14ad61a33bec2 100644
--- a/chrome/browser/notifications/sync_notifier/notification_bitmap_fetcher_browsertest.cc
+++ b/chrome/browser/bitmap_fetcher_browsertest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/notifications/sync_notifier/notification_bitmap_fetcher.h"
+#include "chrome/browser/bitmap_fetcher.h"
#include "base/compiler_specific.h"
#include "chrome/browser/ui/browser.h"
@@ -24,20 +24,17 @@ const bool kAsyncCall = true;
const bool kSyncCall = false;
} // namespace
-namespace notifier {
+namespace chrome {
-// Class to catch events from the NotificationBitmapFetcher for testing.
-class NotificationBitmapFetcherTestDelegate
- : public NotificationBitmapFetcherDelegate {
+// Class to catch events from the BitmapFetcher for testing.
+class BitmapFetcherTestDelegate : public BitmapFetcherDelegate {
public:
- explicit NotificationBitmapFetcherTestDelegate(bool async)
+ explicit BitmapFetcherTestDelegate(bool async)
: called_(false), success_(false), async_(async) {}
- virtual ~NotificationBitmapFetcherTestDelegate() {
- EXPECT_TRUE(called_);
- }
+ virtual ~BitmapFetcherTestDelegate() { EXPECT_TRUE(called_); }
- // Method inherited from NotificationBitmapFetcherDelegate.
+ // Method inherited from BitmapFetcherDelegate.
virtual void OnFetchComplete(const GURL url,
const SkBitmap* bitmap) OVERRIDE {
called_ = true;
@@ -64,10 +61,10 @@ class NotificationBitmapFetcherTestDelegate
bool async_;
SkBitmap bitmap_;
- DISALLOW_COPY_AND_ASSIGN(NotificationBitmapFetcherTestDelegate);
+ DISALLOW_COPY_AND_ASSIGN(BitmapFetcherTestDelegate);
};
-class NotificationBitmapFetcherBrowserTest : public InProcessBrowserTest {
+class BitmapFetcherBrowserTest : public InProcessBrowserTest {
public:
virtual void SetUp() OVERRIDE {
url_fetcher_factory_.reset(new net::FakeURLFetcherFactory(NULL));
@@ -88,8 +85,7 @@ class NotificationBitmapFetcherBrowserTest : public InProcessBrowserTest {
// --single-process. The reason is that the sandbox does not get created
// for us by the test process if --single-process is used.
-IN_PROC_BROWSER_TEST_F(NotificationBitmapFetcherBrowserTest,
- MAYBE_StartTest) {
+IN_PROC_BROWSER_TEST_F(BitmapFetcherBrowserTest, MAYBE_StartTest) {
GURL url("http://example.com/this-should-work");
// Put some realistic looking bitmap data into the url_fetcher.
@@ -108,12 +104,12 @@ IN_PROC_BROWSER_TEST_F(NotificationBitmapFetcherBrowserTest,
std::string image_string(compressed.begin(), compressed.end());
// Set up a delegate to wait for the callback.
- NotificationBitmapFetcherTestDelegate delegate(kAsyncCall);
+ BitmapFetcherTestDelegate delegate(kAsyncCall);
- NotificationBitmapFetcher fetcher(url, &delegate);
+ BitmapFetcher fetcher(url, &delegate);
- url_fetcher_factory_->SetFakeResponse(url, image_string, net::HTTP_OK,
- net::URLRequestStatus::SUCCESS);
+ url_fetcher_factory_->SetFakeResponse(
+ url, image_string, net::HTTP_OK, net::URLRequestStatus::SUCCESS);
// We expect that the image decoder will get called and return
// an image in a callback to OnImageDecoded().
@@ -129,8 +125,7 @@ IN_PROC_BROWSER_TEST_F(NotificationBitmapFetcherBrowserTest,
EXPECT_TRUE(gfx::BitmapsAreEqual(image, found_image));
}
-IN_PROC_BROWSER_TEST_F(NotificationBitmapFetcherBrowserTest,
- OnImageDecodedTest) {
+IN_PROC_BROWSER_TEST_F(BitmapFetcherBrowserTest, OnImageDecodedTest) {
GURL url("http://example.com/this-should-work-as-well");
SkBitmap image;
@@ -139,9 +134,9 @@ IN_PROC_BROWSER_TEST_F(NotificationBitmapFetcherBrowserTest,
image.allocPixels();
image.eraseColor(SK_ColorGREEN);
- NotificationBitmapFetcherTestDelegate delegate(kSyncCall);
+ BitmapFetcherTestDelegate delegate(kSyncCall);
- NotificationBitmapFetcher fetcher(url, &delegate);
+ BitmapFetcher fetcher(url, &delegate);
fetcher.OnImageDecoded(NULL, image);
@@ -152,16 +147,15 @@ IN_PROC_BROWSER_TEST_F(NotificationBitmapFetcherBrowserTest,
EXPECT_TRUE(gfx::BitmapsAreEqual(image, delegate.bitmap()));
}
-IN_PROC_BROWSER_TEST_F(NotificationBitmapFetcherBrowserTest,
- OnURLFetchFailureTest) {
+IN_PROC_BROWSER_TEST_F(BitmapFetcherBrowserTest, OnURLFetchFailureTest) {
GURL url("http://example.com/this-should-be-fetch-failure");
// We intentionally put no data into the bitmap to simulate a failure.
// Set up a delegate to wait for the callback.
- NotificationBitmapFetcherTestDelegate delegate(kAsyncCall);
+ BitmapFetcherTestDelegate delegate(kAsyncCall);
- NotificationBitmapFetcher fetcher(url, &delegate);
+ BitmapFetcher fetcher(url, &delegate);
url_fetcher_factory_->SetFakeResponse(url,
std::string(),
@@ -183,14 +177,14 @@ IN_PROC_BROWSER_TEST_F(NotificationBitmapFetcherBrowserTest,
#define MAYBE_HandleImageFailedTest HandleImageFailedTest
#endif
-IN_PROC_BROWSER_TEST_F(NotificationBitmapFetcherBrowserTest,
- MAYBE_HandleImageFailedTest) {
+IN_PROC_BROWSER_TEST_F(BitmapFetcherBrowserTest, MAYBE_HandleImageFailedTest) {
GURL url("http://example.com/this-should-be-a-decode-failure");
- NotificationBitmapFetcherTestDelegate delegate(kAsyncCall);
- NotificationBitmapFetcher fetcher(url, &delegate);
- url_fetcher_factory_->SetFakeResponse(
- url, std::string("Not a real bitmap"),
- net::HTTP_OK, net::URLRequestStatus::SUCCESS);
+ BitmapFetcherTestDelegate delegate(kAsyncCall);
+ BitmapFetcher fetcher(url, &delegate);
+ url_fetcher_factory_->SetFakeResponse(url,
+ std::string("Not a real bitmap"),
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
fetcher.Start(browser()->profile());
@@ -200,4 +194,4 @@ IN_PROC_BROWSER_TEST_F(NotificationBitmapFetcherBrowserTest,
EXPECT_FALSE(delegate.success());
}
-} // namespace notifier
+} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698