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

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

Issue 11106007: drive: Rename 'gdata' namespace to 'drive' in chrome/browser/chromeos/drive (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 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
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_sync_client.h" 5 #include "chrome/browser/chromeos/drive/drive_sync_client.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 16 matching lines...) Expand all
27 #include "content/public/test/test_browser_thread.h" 27 #include "content/public/test/test_browser_thread.h"
28 #include "testing/gmock/include/gmock/gmock.h" 28 #include "testing/gmock/include/gmock/gmock.h"
29 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
30 30
31 using ::testing::AnyNumber; 31 using ::testing::AnyNumber;
32 using ::testing::DoAll; 32 using ::testing::DoAll;
33 using ::testing::Return; 33 using ::testing::Return;
34 using ::testing::StrictMock; 34 using ::testing::StrictMock;
35 using ::testing::_; 35 using ::testing::_;
36 36
37 namespace gdata { 37 namespace drive {
38 38
39 namespace { 39 namespace {
40 40
41 // Action used to set mock expectations for GetFileByResourceId(). 41 // Action used to set mock expectations for GetFileByResourceId().
42 ACTION_P4(MockGetFileByResourceId, error, local_path, mime_type, file_type) { 42 ACTION_P4(MockGetFileByResourceId, error, local_path, mime_type, file_type) {
43 arg1.Run(error, local_path, mime_type, file_type); 43 arg1.Run(error, local_path, mime_type, file_type);
44 } 44 }
45 45
46 // Action used to set mock expectations for UpdateFileByResourceId(). 46 // Action used to set mock expectations for UpdateFileByResourceId().
47 ACTION_P(MockUpdateFileByResourceId, error) { 47 ACTION_P(MockUpdateFileByResourceId, error) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // Disable delaying so that DoSyncLoop() starts immediately. 95 // Disable delaying so that DoSyncLoop() starts immediately.
96 sync_client_->set_delay_for_testing(base::TimeDelta::FromSeconds(0)); 96 sync_client_->set_delay_for_testing(base::TimeDelta::FromSeconds(0));
97 sync_client_->Initialize(); 97 sync_client_->Initialize();
98 } 98 }
99 99
100 virtual void TearDown() OVERRIDE { 100 virtual void TearDown() OVERRIDE {
101 // The sync client should be deleted before NetworkLibrary, as the sync 101 // The sync client should be deleted before NetworkLibrary, as the sync
102 // client registers itself as observer of NetworkLibrary. 102 // client registers itself as observer of NetworkLibrary.
103 sync_client_.reset(); 103 sync_client_.reset();
104 cache_->DestroyOnUIThread(); 104 cache_->DestroyOnUIThread();
105 test_util::RunBlockingPoolTask(); 105 gdata::test_util::RunBlockingPoolTask();
106 mock_network_change_notifier_.reset(); 106 mock_network_change_notifier_.reset();
107 } 107 }
108 108
109 // Sets up MockNetworkChangeNotifier as if it's connected to a network with 109 // Sets up MockNetworkChangeNotifier as if it's connected to a network with
110 // the specified connection type. 110 // the specified connection type.
111 void ChangeConnectionType(net::NetworkChangeNotifier::ConnectionType type) { 111 void ChangeConnectionType(net::NetworkChangeNotifier::ConnectionType type) {
112 EXPECT_CALL(*mock_network_change_notifier_, GetCurrentConnectionType()) 112 EXPECT_CALL(*mock_network_change_notifier_, GetCurrentConnectionType())
113 .WillRepeatedly(Return(type)); 113 .WillRepeatedly(Return(type));
114 // Notify the sync client that the network is changed. This is done via 114 // Notify the sync client that the network is changed. This is done via
115 // NetworkChangeNotifier in production, but here, we simulate the behavior 115 // NetworkChangeNotifier in production, but here, we simulate the behavior
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 278
279 // Kick off the cache initialization. This will scan the contents in the 279 // Kick off the cache initialization. This will scan the contents in the
280 // test cache directory. 280 // test cache directory.
281 bool success = false; 281 bool success = false;
282 cache_->RequestInitializeOnUIThread( 282 cache_->RequestInitializeOnUIThread(
283 base::Bind(&test_util::CopyResultFromInitializeCacheCallback, 283 base::Bind(&test_util::CopyResultFromInitializeCacheCallback,
284 &success)); 284 &success));
285 // Start processing the files in the backlog. This will collect the 285 // Start processing the files in the backlog. This will collect the
286 // resource IDs of these files. 286 // resource IDs of these files.
287 sync_client_->StartProcessingBacklog(); 287 sync_client_->StartProcessingBacklog();
288 test_util::RunBlockingPoolTask(); 288 gdata::test_util::RunBlockingPoolTask();
289 ASSERT_TRUE(success); 289 ASSERT_TRUE(success);
290 290
291 // Check the contents of the queue for fetching. 291 // Check the contents of the queue for fetching.
292 std::vector<std::string> resource_ids = 292 std::vector<std::string> resource_ids =
293 GetResourceIdsToBeFetched(); 293 GetResourceIdsToBeFetched();
294 ASSERT_EQ(3U, resource_ids.size()); 294 ASSERT_EQ(3U, resource_ids.size());
295 // Since these are the list of file names read from the disk, the order is 295 // Since these are the list of file names read from the disk, the order is
296 // not guaranteed, hence sort it. 296 // not guaranteed, hence sort it.
297 sort(resource_ids.begin(), resource_ids.end()); 297 sort(resource_ids.begin(), resource_ids.end());
298 EXPECT_EQ("resource_id_not_fetched_bar", resource_ids[0]); 298 EXPECT_EQ("resource_id_not_fetched_bar", resource_ids[0]);
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 // Set the expectation so that the MockDriveFileSystem returns "some_md5" 538 // Set the expectation so that the MockDriveFileSystem returns "some_md5"
539 // for "resource_id_dirty". The MD5 on the server is always different from 539 // for "resource_id_dirty". The MD5 on the server is always different from
540 // the MD5 of a dirty file, which is set to "local". We should not collect 540 // the MD5 of a dirty file, which is set to "local". We should not collect
541 // this by StartCheckingExistingPinnedFiles(). 541 // this by StartCheckingExistingPinnedFiles().
542 SetExpectationForGetFileInfoByResourceId("resource_id_dirty", 542 SetExpectationForGetFileInfoByResourceId("resource_id_dirty",
543 "some_md5"); 543 "some_md5");
544 544
545 // Start checking the existing pinned files. This will collect the resource 545 // Start checking the existing pinned files. This will collect the resource
546 // IDs of pinned files, with stale local cache files. 546 // IDs of pinned files, with stale local cache files.
547 sync_client_->StartCheckingExistingPinnedFiles(); 547 sync_client_->StartCheckingExistingPinnedFiles();
548 test_util::RunBlockingPoolTask(); 548 gdata::test_util::RunBlockingPoolTask();
549 ASSERT_TRUE(initialization_success); 549 ASSERT_TRUE(initialization_success);
550 550
551 // Check the contents of the queue for fetching. 551 // Check the contents of the queue for fetching.
552 std::vector<std::string> resource_ids = 552 std::vector<std::string> resource_ids =
553 GetResourceIdsToBeFetched(); 553 GetResourceIdsToBeFetched();
554 ASSERT_EQ(1U, resource_ids.size()); 554 ASSERT_EQ(1U, resource_ids.size());
555 EXPECT_EQ("resource_id_fetched", resource_ids[0]); 555 EXPECT_EQ("resource_id_fetched", resource_ids[0]);
556 // resource_id_dirty is not collected in the queue. 556 // resource_id_dirty is not collected in the queue.
557 557
558 // Check the contents of the queue for uploading. 558 // Check the contents of the queue for uploading.
559 resource_ids = GetResourceIdsToBeUploaded(); 559 resource_ids = GetResourceIdsToBeUploaded();
560 ASSERT_TRUE(resource_ids.empty()); 560 ASSERT_TRUE(resource_ids.empty());
561 } 561 }
562 562
563 } // namespace gdata 563 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_sync_client.cc ('k') | chrome/browser/chromeos/drive/drive_system_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698