OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "tools/battor_agent/battor_connection_impl.h" | 5 #include "tools/battor_agent/battor_connection_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/test/test_simple_task_runner.h" | 10 #include "base/test/test_simple_task_runner.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 ASSERT_EQ(BATTOR_MESSAGE_TYPE_CONTROL, GetReadType()); | 191 ASSERT_EQ(BATTOR_MESSAGE_TYPE_CONTROL, GetReadType()); |
192 ASSERT_EQ(0, std::memcmp(GetReadMessage()->data(), expected, 5)); | 192 ASSERT_EQ(0, std::memcmp(GetReadMessage()->data(), expected, 5)); |
193 } | 193 } |
194 | 194 |
195 TEST_F(BattOrConnectionImplTest, ReadMessageInvalidType) { | 195 TEST_F(BattOrConnectionImplTest, ReadMessageInvalidType) { |
196 OpenConnection(); | 196 OpenConnection(); |
197 ASSERT_TRUE(GetOpenSuccess()); | 197 ASSERT_TRUE(GetOpenSuccess()); |
198 | 198 |
199 const char data[] = { | 199 const char data[] = { |
200 BATTOR_CONTROL_BYTE_START, | 200 BATTOR_CONTROL_BYTE_START, |
201 UINT8_MAX, | 201 static_cast<char>(UINT8_MAX), |
202 BATTOR_CONTROL_BYTE_ESCAPE, | 202 BATTOR_CONTROL_BYTE_ESCAPE, |
203 BATTOR_CONTROL_MESSAGE_TYPE_RESET, | 203 BATTOR_CONTROL_MESSAGE_TYPE_RESET, |
204 0x04, | 204 0x04, |
205 0x04, | 205 0x04, |
206 0x04, | 206 0x04, |
207 0x04, | 207 0x04, |
208 BATTOR_CONTROL_BYTE_END, | 208 BATTOR_CONTROL_BYTE_END, |
209 }; | 209 }; |
210 SendBytesRaw(data, 7); | 210 SendBytesRaw(data, 7); |
211 ReadMessage(BATTOR_MESSAGE_TYPE_CONTROL); | 211 ReadMessage(BATTOR_MESSAGE_TYPE_CONTROL); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 BATTOR_CONTROL_BYTE_END, | 387 BATTOR_CONTROL_BYTE_END, |
388 }; | 388 }; |
389 SendBytesRaw(data, 3); | 389 SendBytesRaw(data, 3); |
390 ReadMessage(BATTOR_MESSAGE_TYPE_PRINT); | 390 ReadMessage(BATTOR_MESSAGE_TYPE_PRINT); |
391 | 391 |
392 ASSERT_TRUE(IsReadComplete()); | 392 ASSERT_TRUE(IsReadComplete()); |
393 ASSERT_FALSE(GetReadSuccess()); | 393 ASSERT_FALSE(GetReadSuccess()); |
394 } | 394 } |
395 | 395 |
396 } // namespace battor | 396 } // namespace battor |
OLD | NEW |