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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chromeos/cros/cros_in_process_browser_test.h" 7 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h"
8 #include "chrome/browser/chromeos/cros/mock_network_library.h" 8 #include "chrome/browser/chromeos/cros/mock_network_library.h"
9 #include "chrome/common/chrome_notification_types.h"
9 #include "chrome/test/ui_test_utils.h" 10 #include "chrome/test/ui_test_utils.h"
10 #include "content/browser/browser_thread.h" 11 #include "content/browser/browser_thread.h"
11 #include "content/common/notification_registrar.h" 12 #include "content/common/notification_registrar.h"
12 #include "content/common/notification_service.h" 13 #include "content/common/notification_service.h"
13 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 namespace chromeos { 17 namespace chromeos {
17 18
18 using ::testing::Return; 19 using ::testing::Return;
(...skipping 14 matching lines...) Expand all
33 mock_network_library_ = cros_mock_->mock_network_library(); 34 mock_network_library_ = cros_mock_->mock_network_library();
34 ASSERT_TRUE(mock_network_library_); 35 ASSERT_TRUE(mock_network_library_);
35 EXPECT_CALL(*mock_network_library_, Connected()) 36 EXPECT_CALL(*mock_network_library_, Connected())
36 .Times(1) 37 .Times(1)
37 .WillRepeatedly((Return(true))) 38 .WillRepeatedly((Return(true)))
38 .RetiresOnSaturation(); 39 .RetiresOnSaturation();
39 NetworkStateNotifier::GetInstance(); 40 NetworkStateNotifier::GetInstance();
40 } 41 }
41 42
42 // NotificationObserver overrides. 43 // NotificationObserver overrides.
43 virtual void Observe(NotificationType type, 44 virtual void Observe(int type,
44 const NotificationSource& source, 45 const NotificationSource& source,
45 const NotificationDetails& details) { 46 const NotificationDetails& details) {
46 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); 47 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
47 EXPECT_TRUE(NotificationType::NETWORK_STATE_CHANGED == type); 48 EXPECT_TRUE(chrome::NOTIFICATION_NETWORK_STATE_CHANGED == type);
48 chromeos::NetworkStateDetails* state_details = 49 chromeos::NetworkStateDetails* state_details =
49 Details<chromeos::NetworkStateDetails>(details).ptr(); 50 Details<chromeos::NetworkStateDetails>(details).ptr();
50 state_ = state_details->state(); 51 state_ = state_details->state();
51 } 52 }
52 53
53 void WaitForNotification() { 54 void WaitForNotification() {
54 ui_test_utils::WaitForNotification( 55 ui_test_utils::WaitForNotification(
55 NotificationType::NETWORK_STATE_CHANGED); 56 chrome::NOTIFICATION_NETWORK_STATE_CHANGED);
56 } 57 }
57 58
58 protected: 59 protected:
59 MockNetworkLibrary *mock_network_library_; 60 MockNetworkLibrary *mock_network_library_;
60 NetworkStateDetails::State state_; 61 NetworkStateDetails::State state_;
61 }; 62 };
62 63
63 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestConnected) { 64 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestConnected) {
64 // NETWORK_STATE_CHAGNED has to be registered in UI thread. 65 // NETWORK_STATE_CHAGNED has to be registered in UI thread.
65 NotificationRegistrar registrar; 66 NotificationRegistrar registrar;
66 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED, 67 registrar.Add(this, chrome::NOTIFICATION_NETWORK_STATE_CHANGED,
67 NotificationService::AllSources()); 68 NotificationService::AllSources());
68 EXPECT_CALL(*mock_network_library_, Connected()) 69 EXPECT_CALL(*mock_network_library_, Connected())
69 .Times(1) 70 .Times(1)
70 .WillRepeatedly((Return(true))) 71 .WillRepeatedly((Return(true)))
71 .RetiresOnSaturation(); 72 .RetiresOnSaturation();
72 NetworkStateNotifier* notifier = NetworkStateNotifier::GetInstance(); 73 NetworkStateNotifier* notifier = NetworkStateNotifier::GetInstance();
73 notifier->OnNetworkManagerChanged(mock_network_library_); 74 notifier->OnNetworkManagerChanged(mock_network_library_);
74 WaitForNotification(); 75 WaitForNotification();
75 EXPECT_EQ(chromeos::NetworkStateDetails::CONNECTED, state_); 76 EXPECT_EQ(chromeos::NetworkStateDetails::CONNECTED, state_);
76 } 77 }
77 78
78 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestConnecting) { 79 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestConnecting) {
79 NotificationRegistrar registrar; 80 NotificationRegistrar registrar;
80 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED, 81 registrar.Add(this, chrome::NOTIFICATION_NETWORK_STATE_CHANGED,
81 NotificationService::AllSources()); 82 NotificationService::AllSources());
82 EXPECT_CALL(*mock_network_library_, Connected()) 83 EXPECT_CALL(*mock_network_library_, Connected())
83 .Times(1) 84 .Times(1)
84 .WillOnce((Return(false))) 85 .WillOnce((Return(false)))
85 .RetiresOnSaturation(); 86 .RetiresOnSaturation();
86 EXPECT_CALL(*mock_network_library_, Connecting()) 87 EXPECT_CALL(*mock_network_library_, Connecting())
87 .Times(1) 88 .Times(1)
88 .WillOnce((Return(true))) 89 .WillOnce((Return(true)))
89 .RetiresOnSaturation(); 90 .RetiresOnSaturation();
90 NetworkStateNotifier* notifier = NetworkStateNotifier::GetInstance(); 91 NetworkStateNotifier* notifier = NetworkStateNotifier::GetInstance();
91 notifier->OnNetworkManagerChanged(mock_network_library_); 92 notifier->OnNetworkManagerChanged(mock_network_library_);
92 WaitForNotification(); 93 WaitForNotification();
93 EXPECT_EQ(chromeos::NetworkStateDetails::CONNECTING, state_); 94 EXPECT_EQ(chromeos::NetworkStateDetails::CONNECTING, state_);
94 } 95 }
95 96
96 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestDisconnected) { 97 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestDisconnected) {
97 NotificationRegistrar registrar; 98 NotificationRegistrar registrar;
98 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED, 99 registrar.Add(this, chrome::NOTIFICATION_NETWORK_STATE_CHANGED,
99 NotificationService::AllSources()); 100 NotificationService::AllSources());
100 EXPECT_CALL(*mock_network_library_, Connected()) 101 EXPECT_CALL(*mock_network_library_, Connected())
101 .Times(1) 102 .Times(1)
102 .WillOnce((Return(false))) 103 .WillOnce((Return(false)))
103 .RetiresOnSaturation(); 104 .RetiresOnSaturation();
104 EXPECT_CALL(*mock_network_library_, Connecting()) 105 EXPECT_CALL(*mock_network_library_, Connecting())
105 .Times(1) 106 .Times(1)
106 .WillOnce((Return(false))) 107 .WillOnce((Return(false)))
107 .RetiresOnSaturation(); 108 .RetiresOnSaturation();
108 NetworkStateNotifier* notifier = NetworkStateNotifier::GetInstance(); 109 NetworkStateNotifier* notifier = NetworkStateNotifier::GetInstance();
109 notifier->OnNetworkManagerChanged(mock_network_library_); 110 notifier->OnNetworkManagerChanged(mock_network_library_);
110 WaitForNotification(); 111 WaitForNotification();
111 EXPECT_EQ(chromeos::NetworkStateDetails::DISCONNECTED, state_); 112 EXPECT_EQ(chromeos::NetworkStateDetails::DISCONNECTED, state_);
112 } 113 }
113 114
114 } // namespace chromeos 115 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/network_state_notifier.cc ('k') | chrome/browser/chromeos/notifications/balloon_collection_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698