mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Cleanup EventLogger interface.
PiperOrigin-RevId: 625797877
This commit is contained in:
committed by
Copybara-Service
parent
42f7afb940
commit
012b9b0569
@@ -242,7 +242,7 @@ cc_test(
|
||||
"//connections/implementation/mediums",
|
||||
"//connections/implementation/proto:offline_wire_formats_cc_proto",
|
||||
"//connections/v3:v3_types",
|
||||
"//internal/analytics:event_logger",
|
||||
"//internal/analytics:mock_event_logger",
|
||||
"//internal/flags:nearby_flags",
|
||||
"//internal/interop:authentication_status",
|
||||
"//internal/interop:authentication_transport_interface",
|
||||
@@ -257,10 +257,8 @@ cc_test(
|
||||
"//proto:connections_enums_cc_proto",
|
||||
"@com_github_protobuf_matchers//protobuf-matchers",
|
||||
"@com_google_absl//absl/base:core_headers",
|
||||
"@com_google_absl//absl/container:flat_hash_set",
|
||||
"@com_google_absl//absl/status",
|
||||
"@com_google_absl//absl/strings",
|
||||
"@com_google_absl//absl/strings:str_format",
|
||||
"@com_google_absl//absl/synchronization",
|
||||
"@com_google_absl//absl/time",
|
||||
"@com_google_absl//absl/types:span",
|
||||
|
||||
@@ -56,9 +56,8 @@ cc_test(
|
||||
shard_count = 16,
|
||||
deps = [
|
||||
":analytics",
|
||||
"//internal/analytics:event_logger",
|
||||
"//internal/analytics:mock_event_logger",
|
||||
"//internal/platform:base",
|
||||
"//internal/platform:comm",
|
||||
"//internal/platform:error_code_recorder",
|
||||
"//internal/platform:types",
|
||||
"//internal/platform/implementation/g3", # build_cleaner: keep
|
||||
@@ -68,6 +67,5 @@ cc_test(
|
||||
"@com_github_protobuf_matchers//protobuf-matchers",
|
||||
"@com_google_absl//absl/time",
|
||||
"@com_google_googletest//:gtest_main",
|
||||
"@com_google_protobuf//:protobuf_lite",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <stddef.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -25,16 +24,14 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include "protobuf-matchers/protocol-buffer-matchers.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/time/clock.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "internal/analytics/event_logger.h"
|
||||
#include "internal/analytics/mock_event_logger.h"
|
||||
#include "internal/platform/count_down_latch.h"
|
||||
#include "internal/platform/error_code_params.h"
|
||||
#include "internal/platform/error_code_recorder.h"
|
||||
#include "internal/platform/exception.h"
|
||||
#include "internal/proto/analytics/connections_log.proto.h"
|
||||
#include "proto/connections_enums.proto.h"
|
||||
#include "google/protobuf/message_lite.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace analytics {
|
||||
@@ -70,7 +67,7 @@ using ::location::nearby::proto::connections::WEB_RTC;
|
||||
using ::location::nearby::proto::connections::WIFI_LAN;
|
||||
using ::location::nearby::proto::connections::WIFI_LAN_MEDIUM_ERROR;
|
||||
using ::location::nearby::proto::connections::WIFI_LAN_SOCKET_CREATION;
|
||||
using ::nearby::analytics::EventLogger;
|
||||
using ::nearby::analytics::MockEventLogger;
|
||||
using ::proto2::contrib::parse_proto::ParseTextProtoOrDie;
|
||||
using ::testing::Contains;
|
||||
using ::protobuf_matchers::EqualsProto;
|
||||
@@ -79,7 +76,7 @@ using ::testing::proto::Partially;
|
||||
|
||||
constexpr absl::Duration kDefaultTimeout = absl::Milliseconds(1000);
|
||||
|
||||
class FakeEventLogger : public EventLogger {
|
||||
class FakeEventLogger : public MockEventLogger {
|
||||
public:
|
||||
explicit FakeEventLogger(CountDownLatch& client_session_done_latch)
|
||||
: client_session_done_latch_(client_session_done_latch) {}
|
||||
@@ -90,20 +87,15 @@ class FakeEventLogger : public EventLogger {
|
||||
start_client_session_done_latch_ptr_(
|
||||
start_client_session_done_latch_ptr) {}
|
||||
|
||||
void Log(const ::google::protobuf::MessageLite& message) override {
|
||||
auto connections_log = dynamic_cast<const ConnectionsLog*>(&message);
|
||||
if (connections_log == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
EventType event_type = connections_log->event_type();
|
||||
void Log(const ConnectionsLog& message) override {
|
||||
EventType event_type = message.event_type();
|
||||
logged_event_types_.push_back(event_type);
|
||||
if (event_type == CLIENT_SESSION) {
|
||||
logged_client_session_count_++;
|
||||
logged_client_session_ = connections_log->client_session();
|
||||
logged_client_session_ = message.client_session();
|
||||
}
|
||||
if (event_type == ERROR_CODE) {
|
||||
error_code_ = connections_log->error_code();
|
||||
error_code_ = message.error_code();
|
||||
}
|
||||
if (event_type == STOP_CLIENT_SESSION) {
|
||||
client_session_done_latch_.CountDown();
|
||||
|
||||
@@ -25,17 +25,13 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include "protobuf-matchers/protocol-buffer-matchers.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/container/flat_hash_set.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "absl/time/clock.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "absl/types/span.h"
|
||||
#include "connections/listeners.h"
|
||||
#include "connections/strategy.h"
|
||||
#include "connections/v3/bandwidth_info.h"
|
||||
#include "connections/v3/connection_listening_options.h"
|
||||
#include "connections/v3/connections_device_provider.h"
|
||||
#include "internal/analytics/event_logger.h"
|
||||
#include "internal/analytics/mock_event_logger.h"
|
||||
#include "internal/interop/device_provider.h"
|
||||
#include "internal/platform/byte_array.h"
|
||||
#include "internal/platform/count_down_latch.h"
|
||||
@@ -64,15 +60,13 @@ constexpr FeatureFlags::Flags kTestCases[] = {
|
||||
},
|
||||
};
|
||||
|
||||
class FakeEventLogger : public ::nearby::analytics::EventLogger {
|
||||
class FakeEventLogger : public ::nearby::analytics::MockEventLogger {
|
||||
public:
|
||||
explicit FakeEventLogger() = default;
|
||||
|
||||
void Log(const ::google::protobuf::MessageLite& message) override {
|
||||
ConnectionsLog log;
|
||||
log.CheckTypeAndMergeFrom(message);
|
||||
void Log(const ConnectionsLog& message) override {
|
||||
MutexLock lock(&mutex_);
|
||||
logs_.push_back(std::move(log));
|
||||
logs_.push_back(message);
|
||||
}
|
||||
|
||||
int GetCompleteClientSessionCount() {
|
||||
|
||||
Reference in New Issue
Block a user