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

Side by Side Diff: chrome/browser/chromeos/network_state_notifier_browsertest.cc

Issue 5734002: Continuation of CL 5685007, rename the singleton accessor method in more files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/network_state_notifier.h" 5 #include "chrome/browser/chromeos/network_state_notifier.h"
6 6
7 #include "chrome/browser/browser_thread.h" 7 #include "chrome/browser/browser_thread.h"
8 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" 8 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h"
9 #include "chrome/browser/chromeos/cros/mock_network_library.h" 9 #include "chrome/browser/chromeos/cros/mock_network_library.h"
10 #include "chrome/common/notification_registrar.h" 10 #include "chrome/common/notification_registrar.h"
(...skipping 18 matching lines...) Expand all
29 cros_mock_->InitStatusAreaMocks(); 29 cros_mock_->InitStatusAreaMocks();
30 cros_mock_->SetStatusAreaMocksExpectations(); 30 cros_mock_->SetStatusAreaMocksExpectations();
31 // Initialize network state notifier. 31 // Initialize network state notifier.
32 ASSERT_TRUE(CrosLibrary::Get()->EnsureLoaded()); 32 ASSERT_TRUE(CrosLibrary::Get()->EnsureLoaded());
33 mock_network_library_ = cros_mock_->mock_network_library(); 33 mock_network_library_ = cros_mock_->mock_network_library();
34 ASSERT_TRUE(mock_network_library_); 34 ASSERT_TRUE(mock_network_library_);
35 EXPECT_CALL(*mock_network_library_, Connected()) 35 EXPECT_CALL(*mock_network_library_, Connected())
36 .Times(1) 36 .Times(1)
37 .WillRepeatedly((Return(true))) 37 .WillRepeatedly((Return(true)))
38 .RetiresOnSaturation(); 38 .RetiresOnSaturation();
39 NetworkStateNotifier::Get(); 39 NetworkStateNotifier::GetInstance();
40 } 40 }
41 41
42 // NotificationObserver overrides. 42 // NotificationObserver overrides.
43 virtual void Observe(NotificationType type, 43 virtual void Observe(NotificationType type,
44 const NotificationSource& source, 44 const NotificationSource& source,
45 const NotificationDetails& details) { 45 const NotificationDetails& details) {
46 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); 46 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
47 EXPECT_TRUE(NotificationType::NETWORK_STATE_CHANGED == type); 47 EXPECT_TRUE(NotificationType::NETWORK_STATE_CHANGED == type);
48 chromeos::NetworkStateDetails* state_details = 48 chromeos::NetworkStateDetails* state_details =
49 Details<chromeos::NetworkStateDetails>(details).ptr(); 49 Details<chromeos::NetworkStateDetails>(details).ptr();
(...skipping 12 matching lines...) Expand all
62 62
63 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestConnected) { 63 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestConnected) {
64 // NETWORK_STATE_CHAGNED has to be registered in UI thread. 64 // NETWORK_STATE_CHAGNED has to be registered in UI thread.
65 NotificationRegistrar registrar; 65 NotificationRegistrar registrar;
66 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED, 66 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED,
67 NotificationService::AllSources()); 67 NotificationService::AllSources());
68 EXPECT_CALL(*mock_network_library_, Connected()) 68 EXPECT_CALL(*mock_network_library_, Connected())
69 .Times(1) 69 .Times(1)
70 .WillRepeatedly((Return(true))) 70 .WillRepeatedly((Return(true)))
71 .RetiresOnSaturation(); 71 .RetiresOnSaturation();
72 NetworkStateNotifier* notifier = NetworkStateNotifier::Get(); 72 NetworkStateNotifier* notifier = NetworkStateNotifier::GetInstance();
73 notifier->OnNetworkManagerChanged(mock_network_library_); 73 notifier->OnNetworkManagerChanged(mock_network_library_);
74 WaitForNotification(); 74 WaitForNotification();
75 EXPECT_EQ(chromeos::NetworkStateDetails::CONNECTED, state_); 75 EXPECT_EQ(chromeos::NetworkStateDetails::CONNECTED, state_);
76 } 76 }
77 77
78 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestConnecting) { 78 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestConnecting) {
79 NotificationRegistrar registrar; 79 NotificationRegistrar registrar;
80 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED, 80 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED,
81 NotificationService::AllSources()); 81 NotificationService::AllSources());
82 EXPECT_CALL(*mock_network_library_, Connected()) 82 EXPECT_CALL(*mock_network_library_, Connected())
83 .Times(1) 83 .Times(1)
84 .WillOnce((Return(false))) 84 .WillOnce((Return(false)))
85 .RetiresOnSaturation(); 85 .RetiresOnSaturation();
86 EXPECT_CALL(*mock_network_library_, Connecting()) 86 EXPECT_CALL(*mock_network_library_, Connecting())
87 .Times(1) 87 .Times(1)
88 .WillOnce((Return(true))) 88 .WillOnce((Return(true)))
89 .RetiresOnSaturation(); 89 .RetiresOnSaturation();
90 NetworkStateNotifier* notifier = NetworkStateNotifier::Get(); 90 NetworkStateNotifier* notifier = NetworkStateNotifier::GetInstance();
91 notifier->OnNetworkManagerChanged(mock_network_library_); 91 notifier->OnNetworkManagerChanged(mock_network_library_);
92 WaitForNotification(); 92 WaitForNotification();
93 EXPECT_EQ(chromeos::NetworkStateDetails::CONNECTING, state_); 93 EXPECT_EQ(chromeos::NetworkStateDetails::CONNECTING, state_);
94 } 94 }
95 95
96 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestDisconnected) { 96 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestDisconnected) {
97 NotificationRegistrar registrar; 97 NotificationRegistrar registrar;
98 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED, 98 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED,
99 NotificationService::AllSources()); 99 NotificationService::AllSources());
100 EXPECT_CALL(*mock_network_library_, Connected()) 100 EXPECT_CALL(*mock_network_library_, Connected())
101 .Times(1) 101 .Times(1)
102 .WillOnce((Return(false))) 102 .WillOnce((Return(false)))
103 .RetiresOnSaturation(); 103 .RetiresOnSaturation();
104 EXPECT_CALL(*mock_network_library_, Connecting()) 104 EXPECT_CALL(*mock_network_library_, Connecting())
105 .Times(1) 105 .Times(1)
106 .WillOnce((Return(false))) 106 .WillOnce((Return(false)))
107 .RetiresOnSaturation(); 107 .RetiresOnSaturation();
108 NetworkStateNotifier* notifier = NetworkStateNotifier::Get(); 108 NetworkStateNotifier* notifier = NetworkStateNotifier::GetInstance();
109 notifier->OnNetworkManagerChanged(mock_network_library_); 109 notifier->OnNetworkManagerChanged(mock_network_library_);
110 WaitForNotification(); 110 WaitForNotification();
111 EXPECT_EQ(chromeos::NetworkStateDetails::DISCONNECTED, state_); 111 EXPECT_EQ(chromeos::NetworkStateDetails::DISCONNECTED, state_);
112 } 112 }
113 113
114 } // namespace chromeos 114 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698