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

Side by Side Diff: chrome/browser/chromeos/drive/drive_scheduler_unittest.cc

Issue 13445002: Remove fake uploader from Drive tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 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
« no previous file with comments | « chrome/browser/chromeos/drive/drive_file_system_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chromeos/drive/drive_scheduler.h" 5 #include "chrome/browser/chromeos/drive/drive_scheduler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 18 matching lines...) Expand all
29 namespace drive { 29 namespace drive {
30 30
31 namespace { 31 namespace {
32 32
33 class MockNetworkChangeNotifier : public net::NetworkChangeNotifier { 33 class MockNetworkChangeNotifier : public net::NetworkChangeNotifier {
34 public: 34 public:
35 MOCK_CONST_METHOD0(GetCurrentConnectionType, 35 MOCK_CONST_METHOD0(GetCurrentConnectionType,
36 net::NetworkChangeNotifier::ConnectionType()); 36 net::NetworkChangeNotifier::ConnectionType());
37 }; 37 };
38 38
39 class FakeDriveUploader : public google_apis::DriveUploaderInterface {
40 public:
41 FakeDriveUploader() {}
42 virtual ~FakeDriveUploader() {}
43
44 // DriveUploaderInterface overrides.
45 virtual void UploadNewFile(
46 const std::string& parent_resource_id,
47 const base::FilePath& drive_file_path,
48 const base::FilePath& local_file_path,
49 const std::string& title,
50 const std::string& content_type,
51 const google_apis::UploadCompletionCallback& callback) OVERRIDE {
52 }
53
54 virtual void UploadExistingFile(
55 const std::string& resource_id,
56 const base::FilePath& drive_file_path,
57 const base::FilePath& local_file_path,
58 const std::string& content_type,
59 const std::string& etag,
60 const google_apis::UploadCompletionCallback& callback) OVERRIDE {
61 }
62 };
63
64 void CopyResourceIdFromGetResourceEntryCallback( 39 void CopyResourceIdFromGetResourceEntryCallback(
65 std::vector<std::string>* id_list_out, 40 std::vector<std::string>* id_list_out,
66 const std::string& requested_id, 41 const std::string& requested_id,
67 google_apis::GDataErrorCode error_in, 42 google_apis::GDataErrorCode error_in,
68 scoped_ptr<google_apis::ResourceEntry> resource_entry_in) { 43 scoped_ptr<google_apis::ResourceEntry> resource_entry_in) {
69 id_list_out->push_back(requested_id); 44 id_list_out->push_back(requested_id);
70 } 45 }
71 46
72 } // namespace 47 } // namespace
73 48
74 class DriveSchedulerTest : public testing::Test { 49 class DriveSchedulerTest : public testing::Test {
75 public: 50 public:
76 DriveSchedulerTest() 51 DriveSchedulerTest()
77 : ui_thread_(content::BrowserThread::UI, &message_loop_), 52 : ui_thread_(content::BrowserThread::UI, &message_loop_),
78 profile_(new TestingProfile) { 53 profile_(new TestingProfile) {
79 } 54 }
80 55
81 virtual void SetUp() OVERRIDE { 56 virtual void SetUp() OVERRIDE {
82 mock_network_change_notifier_.reset(new MockNetworkChangeNotifier); 57 mock_network_change_notifier_.reset(new MockNetworkChangeNotifier);
83 58
84 fake_drive_service_.reset(new google_apis::FakeDriveService()); 59 fake_drive_service_.reset(new google_apis::FakeDriveService());
85 fake_drive_service_->LoadResourceListForWapi( 60 fake_drive_service_->LoadResourceListForWapi(
86 "chromeos/gdata/root_feed.json"); 61 "chromeos/gdata/root_feed.json");
87 fake_drive_service_->LoadAccountMetadataForWapi( 62 fake_drive_service_->LoadAccountMetadataForWapi(
88 "chromeos/gdata/account_metadata.json"); 63 "chromeos/gdata/account_metadata.json");
89 fake_drive_service_->LoadAppListForDriveApi( 64 fake_drive_service_->LoadAppListForDriveApi(
90 "chromeos/drive/applist.json"); 65 "chromeos/drive/applist.json");
91 fake_uploader_.reset(new FakeDriveUploader);
92 66
93 scheduler_.reset(new DriveScheduler(profile_.get(), 67 scheduler_.reset(new DriveScheduler(profile_.get(),
94 fake_drive_service_.get(), 68 fake_drive_service_.get(),
95 fake_uploader_.get())); 69 NULL));
96 70
97 scheduler_->Initialize(); 71 scheduler_->Initialize();
98 scheduler_->SetDisableThrottling(true); 72 scheduler_->SetDisableThrottling(true);
99 } 73 }
100 74
101 virtual void TearDown() OVERRIDE { 75 virtual void TearDown() OVERRIDE {
102 // The scheduler should be deleted before NetworkLibrary, as it 76 // The scheduler should be deleted before NetworkLibrary, as it
103 // registers itself as observer of NetworkLibrary. 77 // registers itself as observer of NetworkLibrary.
104 scheduler_.reset(); 78 scheduler_.reset();
105 google_apis::test_util::RunBlockingPoolTask(); 79 google_apis::test_util::RunBlockingPoolTask();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 ChangeConnectionType(net::NetworkChangeNotifier::CONNECTION_NONE); 112 ChangeConnectionType(net::NetworkChangeNotifier::CONNECTION_NONE);
139 } 113 }
140 114
141 protected: 115 protected:
142 MessageLoopForUI message_loop_; 116 MessageLoopForUI message_loop_;
143 content::TestBrowserThread ui_thread_; 117 content::TestBrowserThread ui_thread_;
144 scoped_ptr<TestingProfile> profile_; 118 scoped_ptr<TestingProfile> profile_;
145 scoped_ptr<DriveScheduler> scheduler_; 119 scoped_ptr<DriveScheduler> scheduler_;
146 scoped_ptr<MockNetworkChangeNotifier> mock_network_change_notifier_; 120 scoped_ptr<MockNetworkChangeNotifier> mock_network_change_notifier_;
147 scoped_ptr<google_apis::FakeDriveService> fake_drive_service_; 121 scoped_ptr<google_apis::FakeDriveService> fake_drive_service_;
148 scoped_ptr<FakeDriveUploader> fake_uploader_;
149 }; 122 };
150 123
151 TEST_F(DriveSchedulerTest, GetAboutResource) { 124 TEST_F(DriveSchedulerTest, GetAboutResource) {
152 ConnectToWifi(); 125 ConnectToWifi();
153 126
154 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 127 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
155 scoped_ptr<google_apis::AboutResource> about_resource; 128 scoped_ptr<google_apis::AboutResource> about_resource;
156 scheduler_->GetAboutResource( 129 scheduler_->GetAboutResource(
157 google_apis::test_util::CreateCopyResultCallback( 130 google_apis::test_util::CreateCopyResultCallback(
158 &error, &about_resource)); 131 &error, &about_resource));
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 // Check the download 552 // Check the download
580 EXPECT_EQ(google_apis::HTTP_SUCCESS, download_error); 553 EXPECT_EQ(google_apis::HTTP_SUCCESS, download_error);
581 std::string content; 554 std::string content;
582 EXPECT_EQ(output_file_path, kOutputFilePath); 555 EXPECT_EQ(output_file_path, kOutputFilePath);
583 ASSERT_TRUE(file_util::ReadFileToString(output_file_path, &content)); 556 ASSERT_TRUE(file_util::ReadFileToString(output_file_path, &content));
584 // The content is "x"s of the file size specified in root_feed.json. 557 // The content is "x"s of the file size specified in root_feed.json.
585 EXPECT_EQ("xxxxxxxxxx", content); 558 EXPECT_EQ("xxxxxxxxxx", content);
586 } 559 }
587 560
588 } // namespace drive 561 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_file_system_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698