Skip to content

Commit

Permalink
CryptAuth Component: Fix inconsistencies with test names and #define …
Browse files Browse the repository at this point in the history
…names.

Several files were moved from the ProximityAuth component without their test names and #define names being changed. This CL also ensures that the #define value has a trailing underscore, as is convention in Chromium.

Review-Url: https://codereview.chromium.org/2646513003
Cr-Commit-Position: refs/heads/master@{#444869}
  • Loading branch information
khorimoto authored and Commit bot committed Jan 19, 2017
1 parent f45d9fc commit f7a6aff
Show file tree
Hide file tree
Showing 51 changed files with 478 additions and 469 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ const char kOtherCharUUID[] = "09731422-048A-11E5-8418-1697F925EC7B";
const char kOtherCharID[] = "other id";
} // namespace

class ProximityAuthBluetoothLowEnergyCharacteristicFinderTest
class CryptAuthBluetoothLowEnergyCharacteristicFinderTest
: public testing::Test {
protected:
ProximityAuthBluetoothLowEnergyCharacteristicFinderTest()
CryptAuthBluetoothLowEnergyCharacteristicFinderTest()
: adapter_(new NiceMock<device::MockBluetoothAdapter>),
success_callback_(base::Bind(
&ProximityAuthBluetoothLowEnergyCharacteristicFinderTest::
&CryptAuthBluetoothLowEnergyCharacteristicFinderTest::
OnCharacteristicsFound,
base::Unretained(this))),
error_callback_(base::Bind(
&ProximityAuthBluetoothLowEnergyCharacteristicFinderTest::
&CryptAuthBluetoothLowEnergyCharacteristicFinderTest::
OnCharacteristicsFinderError,
base::Unretained(this))),
device_(new NiceMock<device::MockBluetoothDevice>(adapter_.get(),
Expand Down Expand Up @@ -127,14 +127,14 @@ class ProximityAuthBluetoothLowEnergyCharacteristicFinderTest
RemoteAttribute from_peripheral_char_;
};

TEST_F(ProximityAuthBluetoothLowEnergyCharacteristicFinderTest,
TEST_F(CryptAuthBluetoothLowEnergyCharacteristicFinderTest,
ConstructAndDestroyDontCrash) {
BluetoothLowEnergyCharacteristicsFinder characteristic_finder(
adapter_, device_.get(), remote_service_, to_peripheral_char_,
from_peripheral_char_, success_callback_, error_callback_);
}

TEST_F(ProximityAuthBluetoothLowEnergyCharacteristicFinderTest,
TEST_F(CryptAuthBluetoothLowEnergyCharacteristicFinderTest,
FindRightCharacteristics) {
BluetoothLowEnergyCharacteristicsFinder characteristic_finder(
adapter_, device_.get(), remote_service_, to_peripheral_char_,
Expand Down Expand Up @@ -169,7 +169,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyCharacteristicFinderTest,
observer->GattDiscoveryCompleteForService(adapter_.get(), service_.get());
}

TEST_F(ProximityAuthBluetoothLowEnergyCharacteristicFinderTest,
TEST_F(CryptAuthBluetoothLowEnergyCharacteristicFinderTest,
DidntFindRightCharacteristics) {
BluetoothLowEnergyCharacteristicsFinder characteristic_finder(
adapter_, device_.get(), remote_service_, to_peripheral_char_,
Expand All @@ -190,7 +190,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyCharacteristicFinderTest,
observer->GattDiscoveryCompleteForService(adapter_.get(), service_.get());
}

TEST_F(ProximityAuthBluetoothLowEnergyCharacteristicFinderTest,
TEST_F(CryptAuthBluetoothLowEnergyCharacteristicFinderTest,
FindOnlyOneRightCharacteristic) {
BluetoothLowEnergyCharacteristicsFinder characteristic_finder(
adapter_, device_.get(), remote_service_, to_peripheral_char_,
Expand All @@ -215,7 +215,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyCharacteristicFinderTest,
EXPECT_EQ(kFromPeripheralCharID, found_from_char.id);
}

TEST_F(ProximityAuthBluetoothLowEnergyCharacteristicFinderTest,
TEST_F(CryptAuthBluetoothLowEnergyCharacteristicFinderTest,
FindWrongCharacteristic_FindRightCharacteristics) {
BluetoothLowEnergyCharacteristicsFinder characteristic_finder(
adapter_, device_.get(), remote_service_, to_peripheral_char_,
Expand Down Expand Up @@ -252,7 +252,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyCharacteristicFinderTest,
observer->GattDiscoveryCompleteForService(adapter_.get(), service_.get());
}

TEST_F(ProximityAuthBluetoothLowEnergyCharacteristicFinderTest,
TEST_F(CryptAuthBluetoothLowEnergyCharacteristicFinderTest,
RightCharacteristicsAlreadyPresent) {
RemoteAttribute found_to_char, found_from_char;
EXPECT_CALL(*this, OnCharacteristicsFound(_, _, _))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ const char kRXCharacteristicUUID[] = "00000100-0004-1000-8000-001A11000102";

BluetoothLowEnergyWeaveClientConnection::
BluetoothLowEnergyWeaveClientConnection(
const cryptauth::RemoteDevice& device,
const RemoteDevice& device,
scoped_refptr<device::BluetoothAdapter> adapter,
const BluetoothUUID remote_service_uuid,
cryptauth::BluetoothThrottler* bluetooth_throttler,
BluetoothThrottler* bluetooth_throttler,
int max_number_of_write_attempts)
: Connection(device),
adapter_(adapter),
Expand Down Expand Up @@ -162,7 +162,7 @@ void BluetoothLowEnergyWeaveClientConnection::SetSubStatus(
SubStatus new_sub_status) {
sub_status_ = new_sub_status;

// Sets the status of parent class cryptauth::Connection accordingly.
// Sets the status of parent class Connection accordingly.
if (new_sub_status == SubStatus::CONNECTED) {
SetStatus(Status::CONNECTED);
} else if (new_sub_status == SubStatus::DISCONNECTED) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class BluetoothLowEnergyWeaveClientConnection
static Factory* factory_instance_;
};

// The sub-state of a cryptauth::BluetoothLowEnergyWeaveClientConnection
// extends the IN_PROGRESS state of cryptauth::Connection::Status.
// The sub-state of a BluetoothLowEnergyWeaveClientConnection
// extends the IN_PROGRESS state of Connection::Status.
enum SubStatus {
DISCONNECTED,
WAITING_GATT_CONNECTION,
Expand All @@ -88,15 +88,15 @@ class BluetoothLowEnergyWeaveClientConnection
// pass through |gatt_connection|. A subsequent call to Connect() must be
// made.
BluetoothLowEnergyWeaveClientConnection(
const cryptauth::RemoteDevice& remote_device,
const RemoteDevice& remote_device,
scoped_refptr<device::BluetoothAdapter> adapter,
const device::BluetoothUUID remote_service_uuid,
BluetoothThrottler* bluetooth_throttler,
int max_number_of_write_attempts);

~BluetoothLowEnergyWeaveClientConnection() override;

// namespace cryptauth::Connection:
// namespace Connection:
void Connect() override;
void Disconnect() override;
std::string GetDeviceAddress() override;
Expand All @@ -118,7 +118,7 @@ class BluetoothLowEnergyWeaveClientConnection
const BluetoothLowEnergyCharacteristicsFinder::ErrorCallback&
error_callback);

// namespace cryptauth::Connection:
// namespace Connection:
void SendMessageImpl(std::unique_ptr<WireMessage> message) override;

// device::BluetoothAdapter::Observer:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class TestBluetoothLowEnergyWeaveClientConnection
: public BluetoothLowEnergyWeaveClientConnection {
public:
TestBluetoothLowEnergyWeaveClientConnection(
const cryptauth::RemoteDevice& remote_device,
const RemoteDevice& remote_device,
scoped_refptr<device::BluetoothAdapter> adapter,
const device::BluetoothUUID remote_service_uuid,
BluetoothThrottler* bluetooth_throttler,
Expand Down Expand Up @@ -341,10 +341,10 @@ class TestBluetoothLowEnergyWeaveClientConnection

} // namespace

class ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest
class CryptAuthBluetoothLowEnergyWeaveClientConnectionTest
: public testing::Test {
public:
ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest()
CryptAuthBluetoothLowEnergyWeaveClientConnectionTest()
: adapter_(new NiceMock<device::MockBluetoothAdapter>),
remote_device_(CreateLERemoteDeviceForTest()),
service_uuid_(device::BluetoothUUID(kServiceUUID)),
Expand All @@ -363,7 +363,7 @@ class ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest
receiver_factory_);
}

~ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest() override {
~CryptAuthBluetoothLowEnergyWeaveClientConnectionTest() override {
BluetoothLowEnergyWeavePacketGenerator::Factory::SetInstanceForTesting(
nullptr);
BluetoothLowEnergyWeavePacketReceiver::Factory::SetInstanceForTesting(
Expand Down Expand Up @@ -588,7 +588,7 @@ class ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest

protected:
scoped_refptr<device::MockBluetoothAdapter> adapter_;
cryptauth::RemoteDevice remote_device_;
RemoteDevice remote_device_;
device::BluetoothUUID service_uuid_;
device::BluetoothUUID tx_characteristic_uuid_;
device::BluetoothUUID rx_characteristic_uuid_;
Expand Down Expand Up @@ -629,21 +629,21 @@ class ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest
write_remote_characteristic_error_callback_;
};

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
CreateAndDestroyWithoutConnectCallDoesntCrash) {
BluetoothLowEnergyWeaveClientConnection connection(
remote_device_, adapter_, service_uuid_, bluetooth_throttler_.get(),
kMaxNumberOfTries);
}

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
DisconnectWithoutConnectDoesntCrash) {
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection());
Disconnect(connection.get());
}

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
ConnectSuccess) {
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection());
Expand All @@ -653,7 +653,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
ConnectionResponseReceived(connection.get(), kDefaultMaxPacketSize);
}

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
ConnectSuccessDisconnect) {
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection());
Expand All @@ -662,15 +662,15 @@ TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
Disconnect(connection.get());
}

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
ConnectIncompleteDisconnectFromWaitingCharacteristicsState) {
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection());
ConnectGatt(connection.get());
Disconnect(connection.get());
}

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
ConnectIncompleteDisconnectFromWaitingNotifySessionState) {
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection());
Expand All @@ -679,7 +679,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
Disconnect(connection.get());
}

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
ConnectIncompleteDisconnectFromWaitingConnectionResponseState) {
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection());
Expand All @@ -689,7 +689,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
Disconnect(connection.get());
}

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
ConnectFailsCharacteristicsNotFound) {
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection());
Expand All @@ -707,7 +707,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
EXPECT_EQ(connection->status(), Connection::DISCONNECTED);
}

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
ConnectFailsNotifySessionError) {
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection());
Expand All @@ -725,7 +725,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
EXPECT_EQ(connection->status(), Connection::DISCONNECTED);
}

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
ConnectFailsErrorSendingConnectionRequest) {
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection());
Expand Down Expand Up @@ -757,7 +757,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
EXPECT_EQ(connection->status(), Connection::DISCONNECTED);
}

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
ReceiveMessageSmallerThanCharacteristicSize) {
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection());
Expand All @@ -773,7 +773,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
EXPECT_EQ(received_bytes, kSmallMessage);
}

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
ReceiveMessageLargerThanCharacteristicSize) {
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection());
Expand All @@ -793,7 +793,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
EXPECT_EQ(received_bytes, kLargeMessage);
}

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
SendMessageSmallerThanCharacteristicSize) {
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection());
Expand All @@ -819,7 +819,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
EXPECT_TRUE(connection_observer_.GetLastSendSuccess());
}

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
SendMessageLargerThanCharacteristicSize) {
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection());
Expand Down Expand Up @@ -863,7 +863,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
EXPECT_TRUE(connection_observer_.GetLastSendSuccess());
}

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
SendMessageKeepsFailing) {
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection());
Expand Down Expand Up @@ -899,7 +899,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
EXPECT_EQ(connection->status(), Connection::DISCONNECTED);
}

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
ReceiveCloseConnectionTest) {
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection());
Expand All @@ -914,7 +914,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
EXPECT_EQ(connection->status(), Connection::DISCONNECTED);
}

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
ReceiverErrorTest) {
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection());
Expand All @@ -940,7 +940,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
EXPECT_EQ(connection->status(), Connection::DISCONNECTED);
}

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
ReceiverErrorWithPendingWritesTest) {
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection());
Expand Down Expand Up @@ -979,7 +979,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
EXPECT_EQ(connection->status(), Connection::DISCONNECTED);
}

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
WriteConnectionCloseMaxNumberOfTimes) {
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection());
Expand Down Expand Up @@ -1017,7 +1017,7 @@ TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
EXPECT_EQ(connection->status(), Connection::DISCONNECTED);
}

TEST_F(ProximityAuthBluetoothLowEnergyWeaveClientConnectionTest,
TEST_F(CryptAuthBluetoothLowEnergyWeaveClientConnectionTest,
ConnectAfterADelayWhenThrottled) {
std::unique_ptr<TestBluetoothLowEnergyWeaveClientConnection> connection(
CreateConnection());
Expand Down
Loading

0 comments on commit f7a6aff

Please sign in to comment.