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

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: Rebase 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 message_loop_.RunAllPending(); 94 message_loop_.RunAllPending();
95 } 95 }
96 96
97 // Sets up MockNetworkLibrary as if it's connected to wifi network. 97 // Sets up MockNetworkLibrary as if it's connected to wifi network.
98 void ConnectToWifi() { 98 void ConnectToWifi() {
99 active_network_.reset( 99 active_network_.reset(
100 chromeos::Network::CreateForTesting(chromeos::TYPE_WIFI)); 100 chromeos::Network::CreateForTesting(chromeos::TYPE_WIFI));
101 EXPECT_CALL(*mock_network_library_, active_network()) 101 EXPECT_CALL(*mock_network_library_, active_network())
102 .Times(AnyNumber()) 102 .Times(AnyNumber())
103 .WillRepeatedly((Return(active_network_.get()))); 103 .WillRepeatedly((Return(active_network_.get())));
104 chromeos::Network::TestApi(active_network_.get()).SetConnected(true); 104 chromeos::Network::TestApi(active_network_.get()).SetConnected();
105 // Notify the sync client that the network is changed. This is done via 105 // Notify the sync client that the network is changed. This is done via
106 // NetworkLibrary in production, but here, we simulate the behavior by 106 // NetworkLibrary in production, but here, we simulate the behavior by
107 // directly calling OnNetworkManagerChanged(). 107 // directly calling OnNetworkManagerChanged().
108 sync_client_->OnNetworkManagerChanged(mock_network_library_); 108 sync_client_->OnNetworkManagerChanged(mock_network_library_);
109 } 109 }
110 110
111 // Sets up MockNetworkLibrary as if it's connected to cellular network. 111 // Sets up MockNetworkLibrary as if it's connected to cellular network.
112 void ConnectToCellular() { 112 void ConnectToCellular() {
113 active_network_.reset( 113 active_network_.reset(
114 chromeos::Network::CreateForTesting(chromeos::TYPE_CELLULAR)); 114 chromeos::Network::CreateForTesting(chromeos::TYPE_CELLULAR));
115 EXPECT_CALL(*mock_network_library_, active_network()) 115 EXPECT_CALL(*mock_network_library_, active_network())
116 .Times(AnyNumber()) 116 .Times(AnyNumber())
117 .WillRepeatedly((Return(active_network_.get()))); 117 .WillRepeatedly((Return(active_network_.get())));
118 chromeos::Network::TestApi(active_network_.get()).SetConnected(true); 118 chromeos::Network::TestApi(active_network_.get()).SetConnected();
119 sync_client_->OnNetworkManagerChanged(mock_network_library_); 119 sync_client_->OnNetworkManagerChanged(mock_network_library_);
120 } 120 }
121 121
122 // Sets up MockNetworkLibrary as if it's connected to wimax network. 122 // Sets up MockNetworkLibrary as if it's connected to wimax network.
123 void ConnectToWimax() { 123 void ConnectToWimax() {
124 active_network_.reset( 124 active_network_.reset(
125 chromeos::Network::CreateForTesting(chromeos::TYPE_WIMAX)); 125 chromeos::Network::CreateForTesting(chromeos::TYPE_WIMAX));
126 EXPECT_CALL(*mock_network_library_, active_network()) 126 EXPECT_CALL(*mock_network_library_, active_network())
127 .Times(AnyNumber()) 127 .Times(AnyNumber())
128 .WillRepeatedly((Return(active_network_.get()))); 128 .WillRepeatedly((Return(active_network_.get())));
129 chromeos::Network::TestApi(active_network_.get()).SetConnected(true); 129 chromeos::Network::TestApi(active_network_.get()).SetConnected();
130 sync_client_->OnNetworkManagerChanged(mock_network_library_); 130 sync_client_->OnNetworkManagerChanged(mock_network_library_);
131 } 131 }
132 132
133 // Sets up MockNetworkLibrary as if it's disconnected. 133 // Sets up MockNetworkLibrary as if it's disconnected.
134 void ConnectToNone() { 134 void ConnectToNone() {
135 active_network_.reset( 135 active_network_.reset(
136 chromeos::Network::CreateForTesting(chromeos::TYPE_WIFI)); 136 chromeos::Network::CreateForTesting(chromeos::TYPE_WIFI));
137 EXPECT_CALL(*mock_network_library_, active_network()) 137 EXPECT_CALL(*mock_network_library_, active_network())
138 .Times(AnyNumber()) 138 .Times(AnyNumber())
139 .WillRepeatedly((Return(active_network_.get()))); 139 .WillRepeatedly((Return(active_network_.get())));
140 // Here false is passed to make it disconnected. 140 chromeos::Network::TestApi(active_network_.get()).SetDisconnected();
141 chromeos::Network::TestApi(active_network_.get()).SetConnected(false);
142 sync_client_->OnNetworkManagerChanged(mock_network_library_); 141 sync_client_->OnNetworkManagerChanged(mock_network_library_);
143 } 142 }
144 143
145 // Sets up test files in the temporary directory. 144 // Sets up test files in the temporary directory.
146 void SetUpTestFiles() { 145 void SetUpTestFiles() {
147 // Create a directory in the temporary directory for pinned files. 146 // Create a directory in the temporary directory for pinned files.
148 const FilePath pinned_dir = 147 const FilePath pinned_dir =
149 cache_->GetCacheDirectoryPath(GDataCache::CACHE_TYPE_PINNED); 148 cache_->GetCacheDirectoryPath(GDataCache::CACHE_TYPE_PINNED);
150 ASSERT_TRUE(file_util::CreateDirectory(pinned_dir)); 149 ASSERT_TRUE(file_util::CreateDirectory(pinned_dir));
151 150
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 ASSERT_EQ(1U, resource_ids.size()); 412 ASSERT_EQ(1U, resource_ids.size());
414 EXPECT_EQ("resource_id_not_fetched_baz", resource_ids[1]); 413 EXPECT_EQ("resource_id_not_fetched_baz", resource_ids[1]);
415 414
416 sync_client_->OnCacheUnpinned("resource_id_not_fetched_baz", "md5"); 415 sync_client_->OnCacheUnpinned("resource_id_not_fetched_baz", "md5");
417 // "baz" should be gone. 416 // "baz" should be gone.
418 resource_ids = sync_client_->GetResourceIdsForTesting(); 417 resource_ids = sync_client_->GetResourceIdsForTesting();
419 ASSERT_TRUE(resource_ids.empty()); 418 ASSERT_TRUE(resource_ids.empty());
420 } 419 }
421 420
422 } // namespace gdata 421 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/network_parser.cc ('k') | chrome/browser/chromeos/status/network_menu_icon.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698