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

Side by Side Diff: components/drive/service/drive_api_service_unittest.cc

Issue 2728323002: Network traffic annotation added to drive/base_requests. (Closed)
Patch Set: NOT_ANNOTATED_YET tag updated. Created 3 years, 9 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/drive/service/drive_api_service.h"
5 #include "base/memory/ptr_util.h" 6 #include "base/memory/ptr_util.h"
6 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
7 #include "base/test/test_simple_task_runner.h" 8 #include "base/test/test_simple_task_runner.h"
8 #include "components/drive/service/drive_api_service.h"
9 #include "google_apis/drive/dummy_auth_service.h" 9 #include "google_apis/drive/dummy_auth_service.h"
10 #include "google_apis/drive/request_sender.h" 10 #include "google_apis/drive/request_sender.h"
11 #include "google_apis/drive/test_util.h" 11 #include "google_apis/drive/test_util.h"
12 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
12 #include "net/url_request/url_request_test_util.h" 13 #include "net/url_request/url_request_test_util.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace drive { 16 namespace drive {
16 namespace { 17 namespace {
17 const char kTestUserAgent[] = "test-user-agent"; 18 const char kTestUserAgent[] = "test-user-agent";
18 } 19 }
19 20
20 class TestAuthService : public google_apis::DummyAuthService { 21 class TestAuthService : public google_apis::DummyAuthService {
21 public: 22 public:
(...skipping 14 matching lines...) Expand all
36 }; 37 };
37 38
38 TEST(DriveAPIServiceTest, BatchRequestConfiguratorWithAuthFailure) { 39 TEST(DriveAPIServiceTest, BatchRequestConfiguratorWithAuthFailure) {
39 const GURL test_base_url("http://localhost/"); 40 const GURL test_base_url("http://localhost/");
40 google_apis::DriveApiUrlGenerator url_generator(test_base_url, test_base_url, 41 google_apis::DriveApiUrlGenerator url_generator(test_base_url, test_base_url,
41 google_apis::TEAM_DRIVES_INTEGRATION_DISABLED); 42 google_apis::TEAM_DRIVES_INTEGRATION_DISABLED);
42 scoped_refptr<base::TestSimpleTaskRunner> task_runner = 43 scoped_refptr<base::TestSimpleTaskRunner> task_runner =
43 new base::TestSimpleTaskRunner(); 44 new base::TestSimpleTaskRunner();
44 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter = 45 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter =
45 new net::TestURLRequestContextGetter(task_runner.get()); 46 new net::TestURLRequestContextGetter(task_runner.get());
46 google_apis::RequestSender sender(new TestAuthService, 47 google_apis::RequestSender sender(
47 request_context_getter.get(), 48 new TestAuthService, request_context_getter.get(), task_runner.get(),
48 task_runner.get(), kTestUserAgent); 49 kTestUserAgent, TRAFFIC_ANNOTATION_FOR_TESTS);
49 std::unique_ptr<google_apis::drive::BatchUploadRequest> request = 50 std::unique_ptr<google_apis::drive::BatchUploadRequest> request =
50 base::MakeUnique<google_apis::drive::BatchUploadRequest>(&sender, 51 base::MakeUnique<google_apis::drive::BatchUploadRequest>(&sender,
51 url_generator); 52 url_generator);
52 google_apis::drive::BatchUploadRequest* request_ptr = request.get(); 53 google_apis::drive::BatchUploadRequest* request_ptr = request.get();
53 sender.StartRequestWithAuthRetry(std::move(request)); 54 sender.StartRequestWithAuthRetry(std::move(request));
54 BatchRequestConfigurator configurator( 55 BatchRequestConfigurator configurator(
55 request_ptr->GetWeakPtrAsBatchUploadRequest(), task_runner.get(), 56 request_ptr->GetWeakPtrAsBatchUploadRequest(), task_runner.get(),
56 url_generator, google_apis::CancelCallback()); 57 url_generator, google_apis::CancelCallback());
57 static_cast<TestAuthService*>(sender.auth_service())->SendHttpError(); 58 static_cast<TestAuthService*>(sender.auth_service())->SendHttpError();
58 59
(...skipping 15 matching lines...) Expand all
74 "text/plain", 10, "resource_id", 75 "text/plain", 10, "resource_id",
75 base::FilePath(FILE_PATH_LITERAL("/file")), UploadExistingFileOptions(), 76 base::FilePath(FILE_PATH_LITERAL("/file")), UploadExistingFileOptions(),
76 google_apis::test_util::CreateCopyResultCallback(&error, 77 google_apis::test_util::CreateCopyResultCallback(&error,
77 &file_resource), 78 &file_resource),
78 google_apis::ProgressCallback()); 79 google_apis::ProgressCallback());
79 EXPECT_EQ(google_apis::DRIVE_OTHER_ERROR, error); 80 EXPECT_EQ(google_apis::DRIVE_OTHER_ERROR, error);
80 } 81 }
81 } 82 }
82 83
83 } // namespace drive 84 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698