mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Roll forward to cl/338482889
Signed-off-by: Alexey Polyudov <apolyudov@google.com> Change-Id: I9850950db8bd84f0904ea1a413151887f52098cf
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#include "core/core.h"
|
||||
|
||||
#include "core/internal/client_proxy.h"
|
||||
#include "core/internal/mock_service_controller.h"
|
||||
#include "core/internal/service_controller.h"
|
||||
#include "platform/public/logging.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/time/clock.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
namespace connections {
|
||||
namespace {
|
||||
|
||||
TEST(CoreTest, ConstructorDestructorWorks) {
|
||||
MockServiceController mock;
|
||||
Core core{[&mock]() { return &mock; }};
|
||||
}
|
||||
|
||||
TEST(CoreTest, DestructorReportsFatalFailure) {
|
||||
MockServiceController mock;
|
||||
ON_CALL(mock, StopDiscovery).WillByDefault([](ClientProxy* client) {
|
||||
NEARBY_LOG(INFO, "Blocking Endpoint disconnect for 10 sec");
|
||||
absl::SleepFor(absl::Milliseconds(10000));
|
||||
});
|
||||
ASSERT_DEATH(
|
||||
[&mock]() {
|
||||
Core core{[&mock]() { return &mock; }};
|
||||
EXPECT_CALL(mock, StartDiscovery).Times(1);
|
||||
EXPECT_CALL(mock, StopAdvertising).Times(1);
|
||||
core.StartDiscovery("service_id", {.strategy = Strategy::kP2pCluster},
|
||||
{}, {.result_cb = [](Status status) {
|
||||
NEARBY_LOG(INFO, "Discovery status: %d",
|
||||
static_cast<int>(status.value));
|
||||
}});
|
||||
}(),
|
||||
"Unable to shutdown");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
Reference in New Issue
Block a user