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

Side by Side Diff: chromeos/components/tether/disconnect_tethering_operation_unittest.cc

Issue 2915713002: Tether MessageTransferOperation: Only wait for a response from a host for a certain amount of time … (Closed)
Patch Set: khorimoto@ comments. Created 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chromeos/components/tether/disconnect_tethering_operation.h" 5 #include "chromeos/components/tether/disconnect_tethering_operation.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "chromeos/components/tether/fake_ble_connection_manager.h" 10 #include "chromeos/components/tether/fake_ble_connection_manager.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 fake_ble_connection_manager_->sent_messages(); 77 fake_ble_connection_manager_->sent_messages();
78 ASSERT_EQ(1u, sent_messages.size()); 78 ASSERT_EQ(1u, sent_messages.size());
79 EXPECT_EQ(test_device_, sent_messages[0].remote_device); 79 EXPECT_EQ(test_device_, sent_messages[0].remote_device);
80 EXPECT_EQ(disconnect_tethering_request_string_, sent_messages[0].message); 80 EXPECT_EQ(disconnect_tethering_request_string_, sent_messages[0].message);
81 } 81 }
82 82
83 void SimulateConnectionTimeout() { 83 void SimulateConnectionTimeout() {
84 operation_->UnregisterDevice(test_device_); 84 operation_->UnregisterDevice(test_device_);
85 } 85 }
86 86
87 bool ShouldWaitForResponse() { return operation_->ShouldWaitForResponse(); }
88
87 const std::string disconnect_tethering_request_string_; 89 const std::string disconnect_tethering_request_string_;
88 const cryptauth::RemoteDevice test_device_; 90 const cryptauth::RemoteDevice test_device_;
89 91
90 std::unique_ptr<FakeBleConnectionManager> fake_ble_connection_manager_; 92 std::unique_ptr<FakeBleConnectionManager> fake_ble_connection_manager_;
91 std::unique_ptr<TestObserver> test_observer_; 93 std::unique_ptr<TestObserver> test_observer_;
92 94
93 std::unique_ptr<DisconnectTetheringOperation> operation_; 95 std::unique_ptr<DisconnectTetheringOperation> operation_;
94 96
95 private: 97 private:
96 DISALLOW_COPY_AND_ASSIGN(DisconnectTetheringOperationTest); 98 DISALLOW_COPY_AND_ASSIGN(DisconnectTetheringOperationTest);
97 }; 99 };
98 100
99 TEST_F(DisconnectTetheringOperationTest, TestSuccess) { 101 TEST_F(DisconnectTetheringOperationTest, TestSuccess) {
100 SimulateDeviceAuthenticationAndVerifyMessageSent(); 102 SimulateDeviceAuthenticationAndVerifyMessageSent();
101 EXPECT_EQ(test_device_.GetDeviceId(), test_observer_->last_device_id()); 103 EXPECT_EQ(test_device_.GetDeviceId(), test_observer_->last_device_id());
102 EXPECT_TRUE(test_observer_->WasLastOperationSuccessful()); 104 EXPECT_TRUE(test_observer_->WasLastOperationSuccessful());
103 } 105 }
104 106
105 TEST_F(DisconnectTetheringOperationTest, TestFailure) { 107 TEST_F(DisconnectTetheringOperationTest, TestFailure) {
106 SimulateConnectionTimeout(); 108 SimulateConnectionTimeout();
107 EXPECT_EQ(test_device_.GetDeviceId(), test_observer_->last_device_id()); 109 EXPECT_EQ(test_device_.GetDeviceId(), test_observer_->last_device_id());
108 EXPECT_FALSE(test_observer_->WasLastOperationSuccessful()); 110 EXPECT_FALSE(test_observer_->WasLastOperationSuccessful());
109 } 111 }
110 112
113 TEST_F(DisconnectTetheringOperationTest, TestShouldNotWaitForResponse) {
Kyle Horimoto 2017/06/01 18:18:58 nit: I don't think this test is really necessary.
Ryan Hansberry 2017/06/01 18:44:09 Fair enough, removed.
114 EXPECT_FALSE(ShouldWaitForResponse());
115 }
116
111 } // namespace tether 117 } // namespace tether
112 118
113 } // namespace cryptauth 119 } // namespace cryptauth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698