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

Side by Side Diff: chrome/browser/chromeos/net/tether_notification_presenter_unittest.cc

Issue 2805393002: TetherNotificationPresenter: Connect to a network when the 'Connect' button is pressed. (Closed)
Patch Set: Remove extra constructor. Created 3 years, 8 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
« no previous file with comments | « chrome/browser/chromeos/net/tether_notification_presenter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/net/tether_notification_presenter.h" 5 #include "chrome/browser/chromeos/net/tether_notification_presenter.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 cryptauth::RemoteDevice CreateTestRemoteDevice() { 96 cryptauth::RemoteDevice CreateTestRemoteDevice() {
97 cryptauth::RemoteDevice device = cryptauth::GenerateTestRemoteDevices(1)[0]; 97 cryptauth::RemoteDevice device = cryptauth::GenerateTestRemoteDevices(1)[0];
98 device.name = "testDevice"; 98 device.name = "testDevice";
99 return device; 99 return device;
100 } 100 }
101 101
102 } // namespace 102 } // namespace
103 103
104 class TetherNotificationPresenterTest : public testing::Test { 104 class TetherNotificationPresenterTest : public testing::Test {
105 public:
106 class TestNetworkConnect : public NetworkConnect {
107 public:
108 TestNetworkConnect() {}
109 ~TestNetworkConnect() override {}
110
111 std::string network_id_to_connect() { return network_id_to_connect_; }
112
113 // NetworkConnect:
114 void DisconnectFromNetworkId(const std::string& network_id) override {}
115 bool MaybeShowConfigureUI(const std::string& network_id,
116 const std::string& connect_error) override {
117 return false;
118 }
119 void SetTechnologyEnabled(const chromeos::NetworkTypePattern& technology,
120 bool enabled_state) override {}
121 void ShowMobileSetup(const std::string& network_id) override {}
122 void ConfigureNetworkIdAndConnect(
123 const std::string& network_id,
124 const base::DictionaryValue& shill_properties,
125 bool shared) override {}
126 void CreateConfigurationAndConnect(base::DictionaryValue* shill_properties,
127 bool shared) override {}
128 void SetTetherDelegate(TetherDelegate* tether_delegate) override {}
129
130 void CreateConfiguration(base::DictionaryValue* shill_properties,
131 bool shared) override {}
132
133 void ConnectToNetworkId(const std::string& network_id) override {
134 network_id_to_connect_ = network_id;
135 }
136
137 private:
138 std::string network_id_to_connect_;
139 };
140
105 protected: 141 protected:
106 TetherNotificationPresenterTest() : test_device_(CreateTestRemoteDevice()) {} 142 TetherNotificationPresenterTest() : test_device_(CreateTestRemoteDevice()) {}
107 143
108 void SetUp() override { 144 void SetUp() override {
109 test_message_center_ = base::WrapUnique(new TestMessageCenter()); 145 test_message_center_ = base::WrapUnique(new TestMessageCenter());
110 notification_presenter_ = base::WrapUnique( 146 test_network_connect_ = base::WrapUnique(new TestNetworkConnect());
111 new TetherNotificationPresenter(test_message_center_.get())); 147 notification_presenter_ = base::WrapUnique(new TetherNotificationPresenter(
148 test_message_center_.get(), test_network_connect_.get()));
112 } 149 }
113 150
114 std::string GetActiveHostNotificationId() { 151 std::string GetActiveHostNotificationId() {
115 return std::string(TetherNotificationPresenter::kActiveHostNotificationId); 152 return std::string(TetherNotificationPresenter::kActiveHostNotificationId);
116 } 153 }
117 154
118 std::string GetPotentialHotspotNotificationId() { 155 std::string GetPotentialHotspotNotificationId() {
119 return std::string( 156 return std::string(
120 TetherNotificationPresenter::kPotentialHotspotNotificationId); 157 TetherNotificationPresenter::kPotentialHotspotNotificationId);
121 } 158 }
122 159
123 const cryptauth::RemoteDevice test_device_; 160 const cryptauth::RemoteDevice test_device_;
124 161
125 std::unique_ptr<TestMessageCenter> test_message_center_; 162 std::unique_ptr<TestMessageCenter> test_message_center_;
163 std::unique_ptr<TestNetworkConnect> test_network_connect_;
126 164
127 std::unique_ptr<TetherNotificationPresenter> notification_presenter_; 165 std::unique_ptr<TetherNotificationPresenter> notification_presenter_;
128 166
129 private: 167 private:
130 DISALLOW_COPY_AND_ASSIGN(TetherNotificationPresenterTest); 168 DISALLOW_COPY_AND_ASSIGN(TetherNotificationPresenterTest);
131 }; 169 };
132 170
133 TEST_F(TetherNotificationPresenterTest, 171 TEST_F(TetherNotificationPresenterTest,
134 TestHostConnectionFailedNotification_RemoveProgrammatically) { 172 TestHostConnectionFailedNotification_RemoveProgrammatically) {
135 EXPECT_FALSE(test_message_center_->FindVisibleNotificationById( 173 EXPECT_FALSE(test_message_center_->FindVisibleNotificationById(
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 247
210 message_center::Notification* notification = 248 message_center::Notification* notification =
211 test_message_center_->FindVisibleNotificationById( 249 test_message_center_->FindVisibleNotificationById(
212 GetPotentialHotspotNotificationId()); 250 GetPotentialHotspotNotificationId());
213 EXPECT_TRUE(notification); 251 EXPECT_TRUE(notification);
214 EXPECT_EQ(GetPotentialHotspotNotificationId(), notification->id()); 252 EXPECT_EQ(GetPotentialHotspotNotificationId(), notification->id());
215 253
216 // Tap the notification's button. 254 // Tap the notification's button.
217 test_message_center_->NotifyNotificationButtonTapped( 255 test_message_center_->NotifyNotificationButtonTapped(
218 GetPotentialHotspotNotificationId(), 0 /* button_index */); 256 GetPotentialHotspotNotificationId(), 0 /* button_index */);
219 // TODO(khorimoto): Test that the connection dialog is shown. 257
258 EXPECT_EQ(test_device_.GetDeviceId(),
259 test_network_connect_->network_id_to_connect());
260
261 // TODO(hansberry): Test for the case of the user not yet going through
262 // the connection dialog.
220 } 263 }
221 264
222 TEST_F(TetherNotificationPresenterTest, 265 TEST_F(TetherNotificationPresenterTest,
223 TestMultiplePotentialHotspotNotification_RemoveProgrammatically) { 266 TestMultiplePotentialHotspotNotification_RemoveProgrammatically) {
224 EXPECT_FALSE(test_message_center_->FindVisibleNotificationById( 267 EXPECT_FALSE(test_message_center_->FindVisibleNotificationById(
225 GetPotentialHotspotNotificationId())); 268 GetPotentialHotspotNotificationId()));
226 notification_presenter_->NotifyMultiplePotentialHotspotsNearby(); 269 notification_presenter_->NotifyMultiplePotentialHotspotsNearby();
227 270
228 message_center::Notification* notification = 271 message_center::Notification* notification =
229 test_message_center_->FindVisibleNotificationById( 272 test_message_center_->FindVisibleNotificationById(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 EXPECT_EQ(1u, test_message_center_->GetNumNotifications()); 323 EXPECT_EQ(1u, test_message_center_->GetNumNotifications());
281 324
282 notification_presenter_->RemovePotentialHotspotNotification(); 325 notification_presenter_->RemovePotentialHotspotNotification();
283 EXPECT_FALSE(test_message_center_->FindVisibleNotificationById( 326 EXPECT_FALSE(test_message_center_->FindVisibleNotificationById(
284 GetPotentialHotspotNotificationId())); 327 GetPotentialHotspotNotificationId()));
285 } 328 }
286 329
287 } // namespace tether 330 } // namespace tether
288 331
289 } // namespace chromeos 332 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/net/tether_notification_presenter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698