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

Unified Diff: chrome/browser/bitmap_fetcher/bitmap_fetcher_service_unittest.cc

Issue 2682263002: Network traffic annotation added to chrome::BitmapFetcher. (Closed)
Patch Set: Unittests added. Created 3 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/bitmap_fetcher_service_unittest.cc
diff --git a/chrome/browser/bitmap_fetcher/bitmap_fetcher_service_unittest.cc b/chrome/browser/bitmap_fetcher/bitmap_fetcher_service_unittest.cc
index 5c1bf07af33f31f132371b168ba873ddba905182..5cd53abea32b10114dc0580d9293d0353e472515 100644
--- a/chrome/browser/bitmap_fetcher/bitmap_fetcher_service_unittest.cc
+++ b/chrome/browser/bitmap_fetcher/bitmap_fetcher_service_unittest.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread_bundle.h"
+#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -48,8 +49,10 @@ class TestService : public BitmapFetcherService {
// Create a fetcher, but don't start downloading. That allows side-stepping
// the decode step, which requires a utility process.
std::unique_ptr<chrome::BitmapFetcher> CreateFetcher(
- const GURL& url) override {
- return base::MakeUnique<chrome::BitmapFetcher>(url, this);
+ const GURL& url,
+ const net::NetworkTrafficAnnotationTag & traffic_annotation) override {
+ return base::MakeUnique<chrome::BitmapFetcher>(
+ url, this, traffic_annotation);
}
};
@@ -129,7 +132,9 @@ TEST_F(BitmapFetcherServiceTest, RequestInvalidUrl) {
ASSERT_FALSE(invalid_url.is_valid());
BitmapFetcherService::RequestId request_id =
- service_->RequestImage(invalid_url, new TestObserver(this));
+ service_->RequestImage(invalid_url,
+ new TestObserver(this),
+ TRAFFIC_ANNOTATION_FOR_TESTS);
EXPECT_EQ(invalid_request_id, request_id);
}
@@ -141,18 +146,24 @@ TEST_F(BitmapFetcherServiceTest, CancelInvalidRequest) {
TEST_F(BitmapFetcherServiceTest, OnlyFirstRequestCreatesFetcher) {
EXPECT_EQ(0U, active_fetchers().size());
- service_->RequestImage(url1_, new TestObserver(this));
+ service_->RequestImage(
+ url1_, new TestObserver(this), TRAFFIC_ANNOTATION_FOR_TESTS);
EXPECT_EQ(1U, active_fetchers().size());
- service_->RequestImage(url1_, new TestObserver(this));
+ service_->RequestImage(
+ url1_, new TestObserver(this), TRAFFIC_ANNOTATION_FOR_TESTS);
EXPECT_EQ(1U, active_fetchers().size());
}
TEST_F(BitmapFetcherServiceTest, CompletedFetchNotifiesAllObservers) {
- service_->RequestImage(url1_, new TestObserver(this));
- service_->RequestImage(url1_, new TestObserver(this));
- service_->RequestImage(url1_, new TestObserver(this));
- service_->RequestImage(url1_, new TestObserver(this));
+ service_->RequestImage(
+ url1_, new TestObserver(this), TRAFFIC_ANNOTATION_FOR_TESTS);
+ service_->RequestImage(
+ url1_, new TestObserver(this), TRAFFIC_ANNOTATION_FOR_TESTS);
+ service_->RequestImage(
+ url1_, new TestObserver(this), TRAFFIC_ANNOTATION_FOR_TESTS);
+ service_->RequestImage(
+ url1_, new TestObserver(this), TRAFFIC_ANNOTATION_FOR_TESTS);
EXPECT_EQ(1U, active_fetchers().size());
EXPECT_EQ(4U, requests().size());
@@ -162,12 +173,17 @@ TEST_F(BitmapFetcherServiceTest, CompletedFetchNotifiesAllObservers) {
}
TEST_F(BitmapFetcherServiceTest, CancelRequest) {
- service_->RequestImage(url1_, new TestObserver(this));
- service_->RequestImage(url1_, new TestObserver(this));
+ service_->RequestImage(
+ url1_, new TestObserver(this), TRAFFIC_ANNOTATION_FOR_TESTS);
+ service_->RequestImage(
+ url1_, new TestObserver(this), TRAFFIC_ANNOTATION_FOR_TESTS);
BitmapFetcherService::RequestId requestId =
- service_->RequestImage(url2_, new TestObserver(this));
- service_->RequestImage(url1_, new TestObserver(this));
- service_->RequestImage(url1_, new TestObserver(this));
+ service_->RequestImage(
+ url2_, new TestObserver(this), TRAFFIC_ANNOTATION_FOR_TESTS);
+ service_->RequestImage(
+ url1_, new TestObserver(this), TRAFFIC_ANNOTATION_FOR_TESTS);
+ service_->RequestImage(
+ url1_, new TestObserver(this), TRAFFIC_ANNOTATION_FOR_TESTS);
EXPECT_EQ(5U, requests().size());
service_->CancelRequest(requestId);
@@ -181,8 +197,10 @@ TEST_F(BitmapFetcherServiceTest, CancelRequest) {
}
TEST_F(BitmapFetcherServiceTest, FailedNullRequestsAreHandled) {
- service_->RequestImage(url1_, new TestObserver(this));
- service_->RequestImage(url2_, new TestObserver(this));
+ service_->RequestImage(
+ url1_, new TestObserver(this), TRAFFIC_ANNOTATION_FOR_TESTS);
+ service_->RequestImage(
+ url2_, new TestObserver(this), TRAFFIC_ANNOTATION_FOR_TESTS);
EXPECT_EQ(0U, cache_size());
CompleteFetch(url1_);
@@ -192,8 +210,10 @@ TEST_F(BitmapFetcherServiceTest, FailedNullRequestsAreHandled) {
EXPECT_EQ(1U, cache_size());
}
TEST_F(BitmapFetcherServiceTest, FailedRequestsDontEnterCache) {
- service_->RequestImage(url1_, new TestObserver(this));
- service_->RequestImage(url2_, new TestObserver(this));
+ service_->RequestImage(
+ url1_, new TestObserver(this), TRAFFIC_ANNOTATION_FOR_TESTS);
+ service_->RequestImage(
+ url2_, new TestObserver(this), TRAFFIC_ANNOTATION_FOR_TESTS);
EXPECT_EQ(0U, cache_size());
CompleteFetch(url1_);

Powered by Google App Engine
This is Rietveld 408576698