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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_sync_client_unittest.cc

Issue 10554013: Add a CONNECT_REQUESTED state to Network ConnectionState. (Closed) Base URL: http://git.chromium.org/git/chromium/src@master
Patch Set: Fix tests Created 8 years, 6 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 (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/gdata/gdata_sync_client.h" 5 #include "chrome/browser/chromeos/gdata/gdata_sync_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 message_loop_.RunAllPending(); 101 message_loop_.RunAllPending();
102 } 102 }
103 103
104 // Sets up MockNetworkLibrary as if it's connected to wifi network. 104 // Sets up MockNetworkLibrary as if it's connected to wifi network.
105 void ConnectToWifi() { 105 void ConnectToWifi() {
106 active_network_.reset( 106 active_network_.reset(
107 chromeos::Network::CreateForTesting(chromeos::TYPE_WIFI)); 107 chromeos::Network::CreateForTesting(chromeos::TYPE_WIFI));
108 EXPECT_CALL(*mock_network_library_, active_network()) 108 EXPECT_CALL(*mock_network_library_, active_network())
109 .Times(AnyNumber()) 109 .Times(AnyNumber())
110 .WillRepeatedly((Return(active_network_.get()))); 110 .WillRepeatedly((Return(active_network_.get())));
111 chromeos::Network::TestApi(active_network_.get()).SetConnected(true); 111 chromeos::Network::TestApi(active_network_.get()).SetConnected();
112 // Notify the sync client that the network is changed. This is done via 112 // Notify the sync client that the network is changed. This is done via
113 // NetworkLibrary in production, but here, we simulate the behavior by 113 // NetworkLibrary in production, but here, we simulate the behavior by
114 // directly calling OnNetworkManagerChanged(). 114 // directly calling OnNetworkManagerChanged().
115 sync_client_->OnNetworkManagerChanged(mock_network_library_); 115 sync_client_->OnNetworkManagerChanged(mock_network_library_);
116 } 116 }
117 117
118 // Sets up MockNetworkLibrary as if it's connected to cellular network. 118 // Sets up MockNetworkLibrary as if it's connected to cellular network.
119 void ConnectToCellular() { 119 void ConnectToCellular() {
120 active_network_.reset( 120 active_network_.reset(
121 chromeos::Network::CreateForTesting(chromeos::TYPE_CELLULAR)); 121 chromeos::Network::CreateForTesting(chromeos::TYPE_CELLULAR));
122 EXPECT_CALL(*mock_network_library_, active_network()) 122 EXPECT_CALL(*mock_network_library_, active_network())
123 .Times(AnyNumber()) 123 .Times(AnyNumber())
124 .WillRepeatedly((Return(active_network_.get()))); 124 .WillRepeatedly((Return(active_network_.get())));
125 chromeos::Network::TestApi(active_network_.get()).SetConnected(true); 125 chromeos::Network::TestApi(active_network_.get()).SetConnected();
126 sync_client_->OnNetworkManagerChanged(mock_network_library_); 126 sync_client_->OnNetworkManagerChanged(mock_network_library_);
127 } 127 }
128 128
129 // Sets up MockNetworkLibrary as if it's connected to wimax network. 129 // Sets up MockNetworkLibrary as if it's connected to wimax network.
130 void ConnectToWimax() { 130 void ConnectToWimax() {
131 active_network_.reset( 131 active_network_.reset(
132 chromeos::Network::CreateForTesting(chromeos::TYPE_WIMAX)); 132 chromeos::Network::CreateForTesting(chromeos::TYPE_WIMAX));
133 EXPECT_CALL(*mock_network_library_, active_network()) 133 EXPECT_CALL(*mock_network_library_, active_network())
134 .Times(AnyNumber()) 134 .Times(AnyNumber())
135 .WillRepeatedly((Return(active_network_.get()))); 135 .WillRepeatedly((Return(active_network_.get())));
136 chromeos::Network::TestApi(active_network_.get()).SetConnected(true); 136 chromeos::Network::TestApi(active_network_.get()).SetConnected();
137 sync_client_->OnNetworkManagerChanged(mock_network_library_); 137 sync_client_->OnNetworkManagerChanged(mock_network_library_);
138 } 138 }
139 139
140 // Sets up MockNetworkLibrary as if it's disconnected. 140 // Sets up MockNetworkLibrary as if it's disconnected.
141 void ConnectToNone() { 141 void ConnectToNone() {
142 active_network_.reset( 142 active_network_.reset(
143 chromeos::Network::CreateForTesting(chromeos::TYPE_WIFI)); 143 chromeos::Network::CreateForTesting(chromeos::TYPE_WIFI));
144 EXPECT_CALL(*mock_network_library_, active_network()) 144 EXPECT_CALL(*mock_network_library_, active_network())
145 .Times(AnyNumber()) 145 .Times(AnyNumber())
146 .WillRepeatedly((Return(active_network_.get()))); 146 .WillRepeatedly((Return(active_network_.get())));
147 // Here false is passed to make it disconnected. 147 chromeos::Network::TestApi(active_network_.get()).SetDisconnected();
148 chromeos::Network::TestApi(active_network_.get()).SetConnected(false);
149 sync_client_->OnNetworkManagerChanged(mock_network_library_); 148 sync_client_->OnNetworkManagerChanged(mock_network_library_);
150 } 149 }
151 150
152 // Sets up test files in the temporary directory. 151 // Sets up test files in the temporary directory.
153 void SetUpTestFiles() { 152 void SetUpTestFiles() {
154 // Create a directory in the temporary directory for pinned files. 153 // Create a directory in the temporary directory for pinned files.
155 const FilePath pinned_dir = 154 const FilePath pinned_dir =
156 cache_->GetCacheDirectoryPath(GDataCache::CACHE_TYPE_PINNED); 155 cache_->GetCacheDirectoryPath(GDataCache::CACHE_TYPE_PINNED);
157 ASSERT_TRUE(file_util::CreateDirectory(pinned_dir)); 156 ASSERT_TRUE(file_util::CreateDirectory(pinned_dir));
158 157
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 ASSERT_EQ(1U, resource_ids.size()); 419 ASSERT_EQ(1U, resource_ids.size());
421 EXPECT_EQ("resource_id_not_fetched_baz", resource_ids[1]); 420 EXPECT_EQ("resource_id_not_fetched_baz", resource_ids[1]);
422 421
423 sync_client_->OnFileUnpinned("resource_id_not_fetched_baz", "md5"); 422 sync_client_->OnFileUnpinned("resource_id_not_fetched_baz", "md5");
424 // "baz" should be gone. 423 // "baz" should be gone.
425 resource_ids = sync_client_->GetResourceIdsForTesting(); 424 resource_ids = sync_client_->GetResourceIdsForTesting();
426 ASSERT_TRUE(resource_ids.empty()); 425 ASSERT_TRUE(resource_ids.empty());
427 } 426 }
428 427
429 } // namespace gdata 428 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698