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

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

Issue 2931005: Show offline interstitial page when offline and reload when reconnected to network. (Closed)
Patch Set: " Created 10 years, 5 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) 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/chrome_thread.h" 7 #include "chrome/browser/chrome_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_service.h" 10 #include "chrome/common/notification_service.h"
(...skipping 12 matching lines...) Expand all
23 public: 23 public:
24 NetworkStateNotifierTest() 24 NetworkStateNotifierTest()
25 : notification_received_(false) { 25 : notification_received_(false) {
26 } 26 }
27 27
28 protected: 28 protected:
29 virtual void SetUpInProcessBrowserTestFixture() { 29 virtual void SetUpInProcessBrowserTestFixture() {
30 InitStatusAreaMocks(); 30 InitStatusAreaMocks();
31 SetStatusAreaMocksExpectations(); 31 SetStatusAreaMocksExpectations();
32 // Initialize network state notifier. 32 // Initialize network state notifier.
33 ASSERT_TRUE(CrosLibrary::Get()->EnsureLoaded());
34 ASSERT_TRUE(mock_network_library_);
33 EXPECT_CALL(*mock_network_library_, Connected()) 35 EXPECT_CALL(*mock_network_library_, Connected())
34 .Times(1) 36 .Times(1)
35 .WillRepeatedly((Return(true))) 37 .WillRepeatedly((Return(true)))
36 .RetiresOnSaturation(); 38 .RetiresOnSaturation();
37 NetworkStateNotifier::Get(); 39 NetworkStateNotifier::Get();
38 } 40 }
39 41
40 // NotificationObserver overrides. 42 // NotificationObserver overrides.
41 virtual void Observe(NotificationType type, 43 virtual void Observe(NotificationType type,
42 const NotificationSource& source, 44 const NotificationSource& source,
(...skipping 21 matching lines...) Expand all
64 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestConnected) { 66 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestConnected) {
65 // NETWORK_STATE_CHAGNED has to be registered in UI thread. 67 // NETWORK_STATE_CHAGNED has to be registered in UI thread.
66 NotificationRegistrar registrar; 68 NotificationRegistrar registrar;
67 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED, 69 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED,
68 NotificationService::AllSources()); 70 NotificationService::AllSources());
69 EXPECT_CALL(*mock_network_library_, Connected()) 71 EXPECT_CALL(*mock_network_library_, Connected())
70 .Times(1) 72 .Times(1)
71 .WillRepeatedly((Return(true))) 73 .WillRepeatedly((Return(true)))
72 .RetiresOnSaturation(); 74 .RetiresOnSaturation();
73 NetworkStateNotifier* notifier = NetworkStateNotifier::Get(); 75 NetworkStateNotifier* notifier = NetworkStateNotifier::Get();
74 DCHECK(CrosLibrary::Get()->EnsureLoaded());
75 notifier->NetworkChanged(mock_network_library_); 76 notifier->NetworkChanged(mock_network_library_);
76 WaitForNotification(); 77 WaitForNotification();
77 EXPECT_EQ(chromeos::NetworkStateDetails::CONNECTED, state_); 78 EXPECT_EQ(chromeos::NetworkStateDetails::CONNECTED, state_);
78 } 79 }
79 80
80 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestConnecting) { 81 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestConnecting) {
81 NotificationRegistrar registrar; 82 NotificationRegistrar registrar;
82 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED, 83 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED,
83 NotificationService::AllSources()); 84 NotificationService::AllSources());
84 EXPECT_CALL(*mock_network_library_, Connected()) 85 EXPECT_CALL(*mock_network_library_, Connected())
85 .Times(1) 86 .Times(1)
86 .WillOnce((Return(false))) 87 .WillOnce((Return(false)))
87 .RetiresOnSaturation(); 88 .RetiresOnSaturation();
88 EXPECT_CALL(*mock_network_library_, Connecting()) 89 EXPECT_CALL(*mock_network_library_, Connecting())
89 .Times(1) 90 .Times(1)
90 .WillOnce((Return(true))) 91 .WillOnce((Return(true)))
91 .RetiresOnSaturation(); 92 .RetiresOnSaturation();
92 NetworkStateNotifier* notifier = NetworkStateNotifier::Get(); 93 NetworkStateNotifier* notifier = NetworkStateNotifier::Get();
93 DCHECK(CrosLibrary::Get()->EnsureLoaded());
94 notifier->NetworkChanged(mock_network_library_); 94 notifier->NetworkChanged(mock_network_library_);
95 WaitForNotification(); 95 WaitForNotification();
96 EXPECT_EQ(chromeos::NetworkStateDetails::CONNECTING, state_); 96 EXPECT_EQ(chromeos::NetworkStateDetails::CONNECTING, state_);
97 } 97 }
98 98
99 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestDisconnected) { 99 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestDisconnected) {
100 NotificationRegistrar registrar; 100 NotificationRegistrar registrar;
101 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED, 101 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED,
102 NotificationService::AllSources()); 102 NotificationService::AllSources());
103 EXPECT_CALL(*mock_network_library_, Connected()) 103 EXPECT_CALL(*mock_network_library_, Connected())
104 .Times(1) 104 .Times(1)
105 .WillOnce((Return(false))) 105 .WillOnce((Return(false)))
106 .RetiresOnSaturation(); 106 .RetiresOnSaturation();
107 EXPECT_CALL(*mock_network_library_, Connecting()) 107 EXPECT_CALL(*mock_network_library_, Connecting())
108 .Times(1) 108 .Times(1)
109 .WillOnce((Return(false))) 109 .WillOnce((Return(false)))
110 .RetiresOnSaturation(); 110 .RetiresOnSaturation();
111 NetworkStateNotifier* notifier = NetworkStateNotifier::Get(); 111 NetworkStateNotifier* notifier = NetworkStateNotifier::Get();
112 DCHECK(CrosLibrary::Get()->EnsureLoaded());
113 notifier->NetworkChanged(mock_network_library_); 112 notifier->NetworkChanged(mock_network_library_);
114 WaitForNotification(); 113 WaitForNotification();
115 EXPECT_EQ(chromeos::NetworkStateDetails::DISCONNECTED, state_); 114 EXPECT_EQ(chromeos::NetworkStateDetails::DISCONNECTED, state_);
116 } 115 }
117 116
118 } // namespace chromeos 117 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/network_state_notifier.cc ('k') | chrome/browser/chromeos/offline/offline_load_page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698