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

Side by Side Diff: chrome/browser/drive/drive_api_service_unittest.cc

Issue 1190203002: Move (most of) chrome/browser/drive into components/drive/service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing... Created 5 years, 5 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
« no previous file with comments | « chrome/browser/drive/drive_api_service.cc ('k') | chrome/browser/drive/drive_api_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/message_loop/message_loop.h"
6 #include "base/test/test_simple_task_runner.h"
7 #include "chrome/browser/drive/drive_api_service.h"
8 #include "google_apis/drive/dummy_auth_service.h"
9 #include "google_apis/drive/request_sender.h"
10 #include "google_apis/drive/test_util.h"
11 #include "net/url_request/url_request_test_util.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace drive {
15 namespace {
16 const char kTestUserAgent[] = "test-user-agent";
17 }
18
19 class TestAuthService : public google_apis::DummyAuthService {
20 public:
21 void StartAuthentication(
22 const google_apis::AuthStatusCallback& callback) override {
23 callback_ = callback;
24 }
25
26 bool HasAccessToken() const override { return false; }
27
28 void SendHttpError() {
29 ASSERT_FALSE(callback_.is_null());
30 callback_.Run(google_apis::HTTP_UNAUTHORIZED, "");
31 }
32
33 private:
34 google_apis::AuthStatusCallback callback_;
35 };
36
37 TEST(DriveAPIServiceTest, BatchRequestConfiguratorWithAuthFailure) {
38 const GURL test_base_url("http://localhost/");
39 google_apis::DriveApiUrlGenerator url_generator(test_base_url, test_base_url);
40 scoped_refptr<base::TestSimpleTaskRunner> task_runner =
41 new base::TestSimpleTaskRunner();
42 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter =
43 new net::TestURLRequestContextGetter(task_runner.get());
44 google_apis::RequestSender sender(new TestAuthService,
45 request_context_getter.get(),
46 task_runner.get(), kTestUserAgent);
47 google_apis::drive::BatchUploadRequest* const request =
48 new google_apis::drive::BatchUploadRequest(&sender, url_generator);
49 sender.StartRequestWithAuthRetry(request);
50 BatchRequestConfigurator configurator(
51 request->GetWeakPtrAsBatchUploadRequest(), task_runner.get(),
52 url_generator, google_apis::CancelCallback());
53 static_cast<TestAuthService*>(sender.auth_service())->SendHttpError();
54
55 {
56 google_apis::DriveApiErrorCode error = google_apis::HTTP_SUCCESS;
57 scoped_ptr<google_apis::FileResource> file_resource;
58 configurator.MultipartUploadNewFile(
59 "text/plain", 10, "", "title",
60 base::FilePath(FILE_PATH_LITERAL("/file")), UploadNewFileOptions(),
61 google_apis::test_util::CreateCopyResultCallback(&error,
62 &file_resource),
63 google_apis::ProgressCallback());
64 EXPECT_EQ(google_apis::DRIVE_OTHER_ERROR, error);
65 }
66 {
67 google_apis::DriveApiErrorCode error = google_apis::HTTP_SUCCESS;
68 scoped_ptr<google_apis::FileResource> file_resource;
69 configurator.MultipartUploadExistingFile(
70 "text/plain", 10, "resource_id",
71 base::FilePath(FILE_PATH_LITERAL("/file")), UploadExistingFileOptions(),
72 google_apis::test_util::CreateCopyResultCallback(&error,
73 &file_resource),
74 google_apis::ProgressCallback());
75 EXPECT_EQ(google_apis::DRIVE_OTHER_ERROR, error);
76 }
77 }
78
79 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/drive/drive_api_service.cc ('k') | chrome/browser/drive/drive_api_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698