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

Side by Side Diff: device/bluetooth/test/bluetooth_test_mac.mm

Issue 2695573002: Adding BluetoothTestBase::CheckNotifySessionValue() method (Closed)
Patch Set: Fixing tests Created 3 years, 10 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 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 "device/bluetooth/test/bluetooth_test_mac.h" 5 #include "device/bluetooth/test/bluetooth_test_mac.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 if (BluetoothAdapterMac::IsLowEnergyAvailable()) { 127 if (BluetoothAdapterMac::IsLowEnergyAvailable()) {
128 mock_central_manager_.reset( 128 mock_central_manager_.reset(
129 new ScopedMockCentralManager([[MockCentralManager alloc] init])); 129 new ScopedMockCentralManager([[MockCentralManager alloc] init]));
130 mock_central_manager_->get().bluetoothTestMac = this; 130 mock_central_manager_->get().bluetoothTestMac = this;
131 [mock_central_manager_->get() setState:CBCentralManagerStatePoweredOn]; 131 [mock_central_manager_->get() setState:CBCentralManagerStatePoweredOn];
132 adapter_mac_->SetCentralManagerForTesting((id)mock_central_manager_->get()); 132 adapter_mac_->SetCentralManagerForTesting((id)mock_central_manager_->get());
133 } 133 }
134 } 134 }
135 135
136 void BluetoothTestMac::ResetEventCounts() {
137 BluetoothTestBase::ResetEventCounts();
138 last_notify_value = false;
ortuno 2017/02/23 05:56:00 nit: member variables should end with "_" so last_
jlebel 2017/02/23 18:40:32 Yes!
139 }
140
136 BluetoothDevice* BluetoothTestMac::SimulateLowEnergyDevice(int device_ordinal) { 141 BluetoothDevice* BluetoothTestMac::SimulateLowEnergyDevice(int device_ordinal) {
137 TestBluetoothAdapterObserver observer(adapter_); 142 TestBluetoothAdapterObserver observer(adapter_);
138 CBCentralManager* central_manager = adapter_mac_->low_energy_central_manager_; 143 CBCentralManager* central_manager = adapter_mac_->low_energy_central_manager_;
139 BluetoothLowEnergyCentralManagerDelegate* central_manager_delegate = 144 BluetoothLowEnergyCentralManagerDelegate* central_manager_delegate =
140 adapter_mac_->low_energy_central_manager_delegate_; 145 adapter_mac_->low_energy_central_manager_delegate_;
141 146
142 const char* identifier; 147 const char* identifier;
143 NSString* name; 148 NSString* name;
144 NSArray* uuids; 149 NSArray* uuids;
145 NSNumber* rssi; 150 NSNumber* rssi;
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 BluetoothRemoteGattCharacteristicMac* characteristic_mac = 463 BluetoothRemoteGattCharacteristicMac* characteristic_mac =
459 static_cast<BluetoothRemoteGattCharacteristicMac*>(characteristic); 464 static_cast<BluetoothRemoteGattCharacteristicMac*>(characteristic);
460 CBCharacteristic* cb_characteristic = 465 CBCharacteristic* cb_characteristic =
461 characteristic_mac->GetCBCharacteristic(); 466 characteristic_mac->GetCBCharacteristic();
462 MockCBCharacteristic* characteristic_mock = 467 MockCBCharacteristic* characteristic_mock =
463 ObjCCast<MockCBCharacteristic>(cb_characteristic); 468 ObjCCast<MockCBCharacteristic>(cb_characteristic);
464 [service_mock removeCharacteristicMock:characteristic_mock]; 469 [service_mock removeCharacteristicMock:characteristic_mock];
465 [peripheral_mock mockDidDiscoverEvents]; 470 [peripheral_mock mockDidDiscoverEvents];
466 } 471 }
467 472
473 void BluetoothTestMac::ExpectedChangeNotifyValueAttempts(int attempts) {
474 EXPECT_EQ(attempts, gatt_notify_characteristic_attempts_);
475 }
476
477 void BluetoothTestMac::ExpectedNotifyValue(
478 NotifyValueState expected_value_state) {
479 switch (expected_value_state) {
480 case NotifyValueState::NONE:
481 EXPECT_FALSE(last_notify_value);
482 break;
483 case NotifyValueState::NOTIFY:
484 case NotifyValueState::INDICATE:
485 EXPECT_TRUE(last_notify_value);
486 break;
487 }
488 }
489
468 void BluetoothTestMac::OnFakeBluetoothDeviceConnectGattCalled() { 490 void BluetoothTestMac::OnFakeBluetoothDeviceConnectGattCalled() {
469 gatt_connection_attempts_++; 491 gatt_connection_attempts_++;
470 } 492 }
471 493
472 void BluetoothTestMac::OnFakeBluetoothGattDisconnect() { 494 void BluetoothTestMac::OnFakeBluetoothGattDisconnect() {
473 gatt_disconnection_attempts_++; 495 gatt_disconnection_attempts_++;
474 } 496 }
475 497
476 void BluetoothTestMac::OnFakeBluetoothServiceDiscovery() { 498 void BluetoothTestMac::OnFakeBluetoothServiceDiscovery() {
477 gatt_discovery_attempts_++; 499 gatt_discovery_attempts_++;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 // crypto::SHA256HashString(input_str, raw, sizeof(raw)); 582 // crypto::SHA256HashString(input_str, raw, sizeof(raw));
561 // if (base::HexEncode(raw, sizeof(raw)) == target) { 583 // if (base::HexEncode(raw, sizeof(raw)) == target) {
562 // return input_str; 584 // return input_str;
563 // } 585 // }
564 // ++input[0]; 586 // ++input[0];
565 // } 587 // }
566 // return ""; 588 // return "";
567 // } 589 // }
568 590
569 } // namespace device 591 } // namespace device
OLDNEW
« device/bluetooth/test/bluetooth_test.h ('K') | « device/bluetooth/test/bluetooth_test_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698