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

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

Issue 11280140: Pass calls to GetApplicationInfo through the scheduler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test Created 8 years 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_scheduler.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/threading/sequenced_worker_pool.h" 10 #include "base/threading/sequenced_worker_pool.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 92 }
93 93
94 virtual void GetDocumentEntry(const std::string& resource_id, 94 virtual void GetDocumentEntry(const std::string& resource_id,
95 const GetDataCallback& callback) { 95 const GetDataCallback& callback) {
96 } 96 }
97 97
98 virtual void GetAccountMetadata(const GetDataCallback& callback) { 98 virtual void GetAccountMetadata(const GetDataCallback& callback) {
99 } 99 }
100 100
101 virtual void GetApplicationInfo(const GetDataCallback& callback) { 101 virtual void GetApplicationInfo(const GetDataCallback& callback) {
102 // Make some sample data.
103 const FilePath account_metadata =
104 test_util::GetTestFilePath("gdata/account_metadata.json");
105 std::string contents;
106 file_util::ReadFileToString(account_metadata, &contents);
107 scoped_ptr<base::Value> data(base::JSONReader::Read(contents));
108
109 base::MessageLoopProxy::current()->PostTask(FROM_HERE,
110 base::Bind(callback,
111 HTTP_SUCCESS,
112 base::Passed(&data)));
102 } 113 }
103 114
104 virtual void DeleteDocument(const GURL& document_url, 115 virtual void DeleteDocument(const GURL& document_url,
105 const EntryActionCallback& callback) { 116 const EntryActionCallback& callback) {
106 } 117 }
107 118
108 virtual void DownloadDocument(const FilePath& virtual_path, 119 virtual void DownloadDocument(const FilePath& virtual_path,
109 const FilePath& local_cache_path, 120 const FilePath& local_cache_path,
110 const GURL& content_url, 121 const GURL& content_url,
111 DocumentExportFormat format, 122 DocumentExportFormat format,
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 384
374 DriveFileError error(DRIVE_FILE_ERROR_FAILED); 385 DriveFileError error(DRIVE_FILE_ERROR_FAILED);
375 scheduler_->TransferRegularFile( 386 scheduler_->TransferRegularFile(
376 file_in_root, dest_file, 387 file_in_root, dest_file,
377 base::Bind(&test_util::CopyErrorCodeFromFileOperationCallback, &error)); 388 base::Bind(&test_util::CopyErrorCodeFromFileOperationCallback, &error));
378 google_apis::test_util::RunBlockingPoolTask(); 389 google_apis::test_util::RunBlockingPoolTask();
379 390
380 ASSERT_EQ(DRIVE_FILE_OK, error); 391 ASSERT_EQ(DRIVE_FILE_OK, error);
381 } 392 }
382 393
394 TEST_F(DriveSchedulerTest, GetApplicationInfo) {
395 ConnectToWifi();
396
397 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
398 scoped_ptr<base::Value> value;
399
400 scheduler_->GetApplicationInfo(
401 base::Bind(&google_apis::test_util::CopyResultsFromGetDataCallback,
402 &error,
403 &value));
404 google_apis::test_util::RunBlockingPoolTask();
405
406 ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
407 ASSERT_TRUE(value);
408 }
409
383 TEST_F(DriveSchedulerTest, GetDocuments) { 410 TEST_F(DriveSchedulerTest, GetDocuments) {
384 ConnectToWifi(); 411 ConnectToWifi();
385 412
386 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 413 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
387 scoped_ptr<base::Value> value; 414 scoped_ptr<base::Value> value;
388 415
389 scheduler_->GetDocuments( 416 scheduler_->GetDocuments(
390 GURL("http://example.com/gdata/root_feed.json"), 417 GURL("http://example.com/gdata/root_feed.json"),
391 0, 418 0,
392 std::string(), 419 std::string(),
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 590
564 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); 591 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt"));
565 DriveFileError error; 592 DriveFileError error;
566 scheduler_->Remove( 593 scheduler_->Remove(
567 file_in_root, false, 594 file_in_root, false,
568 base::Bind(&test_util::CopyErrorCodeFromFileOperationCallback, &error)); 595 base::Bind(&test_util::CopyErrorCodeFromFileOperationCallback, &error));
569 google_apis::test_util::RunBlockingPoolTask(); 596 google_apis::test_util::RunBlockingPoolTask();
570 } 597 }
571 598
572 } // namespace drive 599 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698