Skip to content

Commit

Permalink
Fix connections_test
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 549247026
  • Loading branch information
jgsobczak authored and copybara-github committed Aug 9, 2023
1 parent 347d10b commit 9779fba
Show file tree
Hide file tree
Showing 61 changed files with 423 additions and 1,019 deletions.
2 changes: 0 additions & 2 deletions connections/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ cc_library(
"//internal/analytics:event_logger",
"//internal/interop:device",
"//internal/platform:base",
"//internal/platform:logging",
"//internal/platform:types",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/time",
Expand Down Expand Up @@ -102,7 +101,6 @@ cc_test(
"//connections/implementation:internal_test",
"//connections/v3:v3_types",
"//internal/platform:base",
"//internal/platform:logging",
"//internal/platform:types",
"//internal/platform/implementation/g3", # build_cleaner: keep
"@com_github_protobuf_matchers//protobuf-matchers",
Expand Down
2 changes: 1 addition & 1 deletion connections/c/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ cc_test(
],
deps = [
"//connections:core",
"//internal/platform:logging",
"//internal/platform:types",
"//internal/platform/implementation/windows",
"@com_github_protobuf_matchers//protobuf-matchers",
"@com_google_googletest//:gtest_main",
Expand Down
48 changes: 24 additions & 24 deletions connections/c/bluetooth_classic_server_socket_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ TEST(BluetoothClassicServerSocketTest,
PerformanceTimer::start();

core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info,
{.result_cb = [&](Status status) {
[&](Status status) {
request_result = status;
notification.Notify();
}});
});

if (notification.WaitForNotificationWithTimeout(
absl::Seconds(TimeoutSeconds))) {
Expand Down Expand Up @@ -163,10 +163,10 @@ TEST(BluetoothClassicServerSocketTest,
PerformanceTimer::start();

core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info,
{.result_cb = [&](Status status) {
[&](Status status) {
request_result = status;
notification2.Notify();
}});
});

if (notification2.WaitForNotificationWithTimeout(
absl::Seconds(TimeoutSeconds))) {
Expand Down Expand Up @@ -209,10 +209,10 @@ TEST(BluetoothClassicServerSocketTest,

PerformanceTimer::start();

core.StopAdvertising({.result_cb = [&](Status status) {
core.StopAdvertising([&](Status status) {
request_result = status;
notification3.Notify();
}});
});

if (notification3.WaitForNotificationWithTimeout(
absl::Seconds(TimeoutSeconds))) {
Expand Down Expand Up @@ -273,10 +273,10 @@ TEST(BluetoothClassicServerSocketTest, DISABLED_MultiRunWithTimeoutReproStuck) {
PerformanceTimer::start();

core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info,
{.result_cb = [&](Status status) {
[&](Status status) {
request_result = status;
notification.Notify();
}});
});

if (notification.WaitForNotificationWithTimeout(
absl::Seconds(TimeoutSeconds))) {
Expand Down Expand Up @@ -319,10 +319,10 @@ TEST(BluetoothClassicServerSocketTest, DISABLED_MultiRunWithTimeoutReproStuck) {
PerformanceTimer::start();

core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info,
{.result_cb = [&](Status status) {
[&](Status status) {
request_result = status;
notification2.Notify();
}});
});

if (notification2.WaitForNotificationWithTimeout(
absl::Seconds(TimeoutSeconds))) {
Expand Down Expand Up @@ -361,10 +361,10 @@ TEST(BluetoothClassicServerSocketTest, DISABLED_MultiRunWithTimeoutReproStuck) {

PerformanceTimer::start();

core.StopAdvertising({.result_cb = [&](Status status) {
core.StopAdvertising([&](Status status) {
request_result = status;
notification3.Notify();
}});
});

if (notification3.WaitForNotificationWithTimeout(
absl::Seconds(TimeoutSeconds))) {
Expand Down Expand Up @@ -424,10 +424,10 @@ TEST(BluetoothClassicServerSocketTest, DISABLED_SingleRunNoTimeoutReproStuck) {
PerformanceTimer::start();

core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info,
{.result_cb = [&](Status status) {
[&](Status status) {
request_result = status;
notification.Notify();
}});
});

notification.WaitForNotification();
PerformanceTimer::stop();
Expand All @@ -451,10 +451,10 @@ TEST(BluetoothClassicServerSocketTest, DISABLED_SingleRunNoTimeoutReproStuck) {
PerformanceTimer::start();

core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info,
{.result_cb = [&](Status status) {
[&](Status status) {
request_result = status;
notification2.Notify();
}});
});

notification2.WaitForNotification();
PerformanceTimer::stop();
Expand All @@ -477,10 +477,10 @@ TEST(BluetoothClassicServerSocketTest, DISABLED_SingleRunNoTimeoutReproStuck) {

PerformanceTimer::start();

core.StopAdvertising({.result_cb = [&](Status status) {
core.StopAdvertising([&](Status status) {
request_result = status;
notification3.Notify();
}});
});

notification3.WaitForNotification();
PerformanceTimer::stop();
Expand Down Expand Up @@ -521,10 +521,10 @@ TEST(BluetoothClassicServerSocketTest, DISABLED_MultiRunNoTimeoutReproStuck) {
PerformanceTimer::start();

core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info,
{.result_cb = [&](Status status) {
[&](Status status) {
request_result = status;
notification.Notify();
}});
});

notification.WaitForNotification();

Expand All @@ -551,10 +551,10 @@ TEST(BluetoothClassicServerSocketTest, DISABLED_MultiRunNoTimeoutReproStuck) {
PerformanceTimer::start();

core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info,
{.result_cb = [&](Status status) {
[&](Status status) {
request_result = status;
notification2.Notify();
}});
});

notification2.WaitForNotification();
PerformanceTimer::stop();
Expand All @@ -580,10 +580,10 @@ TEST(BluetoothClassicServerSocketTest, DISABLED_MultiRunNoTimeoutReproStuck) {

PerformanceTimer::start();

core.StopAdvertising({.result_cb = [&](Status status) {
core.StopAdvertising([&](Status status) {
request_result = status;
notification3.Notify();
}});
});

notification3.WaitForNotification();
PerformanceTimer::stop();
Expand Down
2 changes: 0 additions & 2 deletions connections/implementation/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ cc_library(
"//internal/platform:comm",
"//internal/platform:connection_info",
"//internal/platform:error_code_recorder",
"//internal/platform:logging",
"//internal/platform:types",
"//internal/platform:util",
"//internal/platform/implementation:comm",
Expand Down Expand Up @@ -236,7 +235,6 @@ cc_test(
"//internal/interop:device",
"//internal/platform:base",
"//internal/platform:comm",
"//internal/platform:logging",
"//internal/platform:test_util",
"//internal/platform:types",
"//internal/platform/implementation/g3", # build_cleaner: keep
Expand Down
2 changes: 0 additions & 2 deletions connections/implementation/analytics/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ cc_library(
"//connections:core_types",
"//internal/analytics:event_logger",
"//internal/platform:error_code_recorder",
"//internal/platform:logging",
"//internal/platform:types",
"//internal/platform/implementation:types",
"//internal/proto/analytics:connections_log_cc_proto",
Expand Down Expand Up @@ -61,7 +60,6 @@ cc_test(
"//internal/platform:base",
"//internal/platform:comm",
"//internal/platform:error_code_recorder",
"//internal/platform:logging",
"//internal/platform:types",
"//internal/platform/implementation/g3", # build_cleaner: keep
"//internal/proto/analytics:connections_log_cc_proto",
Expand Down
7 changes: 5 additions & 2 deletions connections/implementation/client_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,11 @@ void ClientProxy::OnEndpointFound(
MutexLock lock(&mutex_);

NEARBY_LOGS(INFO) << "ClientProxy [Endpoint Found]: [enter] id="
<< endpoint_id << "; service=" << service_id << "; info="
<< absl::BytesToHexString(endpoint_info.data());
<< endpoint_id << "; service=" << service_id
<< "; info=" << absl::BytesToHexString(endpoint_info.data())
<< "; medium="
<< location::nearby::proto::connections::Medium_Name(
medium);
if (!IsDiscoveringServiceId(service_id)) {
NEARBY_LOGS(INFO) << "ClientProxy [Endpoint Found]: Ignoring event for id="
<< endpoint_id
Expand Down
1 change: 0 additions & 1 deletion connections/implementation/mediums/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ cc_library(
"//internal/platform:base",
"//internal/platform:cancellation_flag",
"//internal/platform:comm",
"//internal/platform:logging",
"//internal/platform:types",
"//internal/platform:uuid",
"//proto/mediums:web_rtc_signaling_frames_cc_proto",
Expand Down
1 change: 0 additions & 1 deletion connections/implementation/mediums/ble_v2/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ cc_library(
"//internal/flags:nearby_flags",
"//internal/platform:base",
"//internal/platform:comm",
"//internal/platform:logging",
"//internal/platform:types",
"//internal/platform:util",
"//internal/platform:uuid",
Expand Down
1 change: 0 additions & 1 deletion connections/implementation/mediums/webrtc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ cc_library(
"//connections/implementation/mediums:utils",
"//internal/platform:base",
"//internal/platform:comm",
"//internal/platform:logging",
"//internal/platform:types",
"//proto/mediums:web_rtc_signaling_frames_cc_proto",
# TODO: Support WebRTC
Expand Down
6 changes: 6 additions & 0 deletions connections/status.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ std::string Status::ToString() const {
return "kWifiLanError";
case Status::kPayloadUnknown:
return "kPayloadUnknown";
case Status::kReset:
return "kReset";
case Status::kTimeout:
return "kTimeout";
case Status::kUnknown:
// fall through
default:
return "Unknown";
}
Expand Down
11 changes: 7 additions & 4 deletions connections/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace connections {

// Protocol operation result: kSuccess, if operation was successful;
// descriptive error code otherwise.
// LINT.IfChange
// LINT.IfChange(status_enum)
struct Status {
// Status is a struct, so it is possible to pass some context about failure,
// by adding extra fields to it when necessary, and not change any of the
Expand All @@ -44,6 +44,9 @@ struct Status {
kBleError,
kWifiLanError,
kPayloadUnknown,
kReset,
kTimeout,
kUnknown,
kNextValue,
};
Value value{kError};
Expand All @@ -53,9 +56,9 @@ struct Status {
std::string ToString() const;
};
// LINT.ThenChange(
// //depot/google3/location/nearby/cpp/sharing/implementation/nearby_connections_manager.cc:24
// //depot/google3/location/nearby/cpp/sharing/implementation/nearby_connections_types.h:46
// //depot/google3/location/nearby/cpp/sharing/implementation/nearby_connections_types_test.cc
// ../sharing/nearby_connections_manager.cc:status_enum,
// ../sharing/nearby_connections_types.h:status_enum,
// ../sharing/nearby_connections_types_test.cc:status_enum
// )

inline bool operator==(const Status& a, const Status& b) {
Expand Down
6 changes: 6 additions & 0 deletions connections/swift/NearbyCoreAdapter/Sources/GNCCoreAdapter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ GNCStatus GNCStatusFromCppStatus(Status status) {
return GNCStatusWifiLanError;
case Status::kPayloadUnknown:
return GNCStatusPayloadUnknown;
case Status::kReset:
return GNCStatusReset;
case Status::kTimeout:
return GNCStatusTimeout;
case Status::kUnknown:
return GNCStatusUnknown;
case Status::kNextValue:
return GNCStatusUnknown;
}
Expand Down
6 changes: 6 additions & 0 deletions connections/swift/NearbyCoreAdapter/Sources/GNCError.mm
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
return [NSError errorWithDomain:GNCErrorDomain code:GNCErrorWifiLanError userInfo:nil];
case Status::kPayloadUnknown:
return [NSError errorWithDomain:GNCErrorDomain code:GNCErrorPayloadUnknown userInfo:nil];
case Status::kReset:
return [NSError errorWithDomain:GNCErrorDomain code:GNCErrorReset userInfo:nil];
case Status::kTimeout:
return [NSError errorWithDomain:GNCErrorDomain code:GNCErrorTimeout userInfo:nil];
case Status::kUnknown:
return [NSError errorWithDomain:GNCErrorDomain code:GNCErrorUnknown userInfo:nil];
case Status::kNextValue:
return [NSError errorWithDomain:GNCErrorDomain code:GNCErrorUnknown userInfo:nil];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ typedef NS_CLOSED_ENUM(NSInteger, GNCStatus) {
GNCStatusWifiLanError,
GNCStatusPayloadUnknown,
GNCStatusUnknown,
GNCStatusReset,
GNCStatusTimeout,
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ typedef NS_ERROR_ENUM(GNCErrorDomain, GNCErrorCode){
GNCErrorBleError,
GNCErrorWifiLanError,
GNCErrorPayloadUnknown,
GNCErrorReset,
GNCErrorTimeout,
} NS_SWIFT_NAME(NearbyError);
1 change: 0 additions & 1 deletion fastpair/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ cc_test(
"//fastpair/plugins:fake_fast_pair_plugin",
"//internal/account:test_support",
"//internal/network:types",
"//internal/platform:logging",
"//internal/platform:test_util",
"//internal/platform:types",
"//internal/platform/implementation/g3", # build_cleaner: keep
Expand Down
2 changes: 1 addition & 1 deletion fastpair/common/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ cc_library(
deps = [
"//fastpair/proto:fastpair_cc_proto",
"//internal/crypto_cros",
"//internal/platform:logging",
"//internal/platform:types",
"//internal/preferences",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/container:flat_hash_map",
Expand Down
2 changes: 1 addition & 1 deletion fastpair/crypto/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cc_library(
"//fastpair/common",
"//internal/base:bluetooth_address",
"//internal/platform:base",
"//internal/platform:logging",
"//internal/platform:types",
"@boringssl//:crypto",
"@com_google_absl//absl/log:check",
],
Expand Down
2 changes: 1 addition & 1 deletion fastpair/dataparser/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cc_library(
"//fastpair/crypto",
"//internal/base:bluetooth_address",
"//internal/platform:base",
"//internal/platform:logging",
"//internal/platform:types",
"@com_google_absl//absl/functional:any_invocable",
"@com_google_absl//absl/strings",
],
Expand Down
3 changes: 0 additions & 3 deletions fastpair/handshake/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ cc_library(
"//fastpair/repository",
"//internal/base:bluetooth_address",
"//internal/platform:comm",
"//internal/platform:logging",
"//internal/platform:types",
"//internal/platform:uuid",
"@boringssl//:crypto",
Expand Down Expand Up @@ -89,7 +88,6 @@ cc_test(
"//fastpair/internal/mediums",
"//fastpair/repository:test_support",
"//fastpair/testing",
"//internal/platform:logging",
"//internal/platform:types",
"//internal/platform/implementation/g3", # build_cleaner: keep
"@com_github_protobuf_matchers//protobuf-matchers",
Expand Down Expand Up @@ -164,7 +162,6 @@ cc_test(
":handshake",
"//fastpair/common",
"//fastpair/internal/mediums",
"//internal/platform:logging",
"//internal/platform:test_util",
"//internal/platform:types",
"//internal/platform/implementation/g3", # build_cleaner: keep
Expand Down
Loading

0 comments on commit 9779fba

Please sign in to comment.