nearby: snapshot of cl/313536507

Signed-off-by: Alexey Polyudov <apolyudov@google.com>
Change-Id: I8936b527079074d5c3af5531b9245063767cc4a7
This commit is contained in:
Alexey Polyudov
2020-05-28 00:03:22 -07:00
parent 667bf4ee3b
commit ae1c427b99
334 changed files with 20315 additions and 1487 deletions
+44
View File
@@ -0,0 +1,44 @@
#include "core_v2/core.h"
#include "core_v2/internal/client_proxy.h"
#include "core_v2/internal/mock_service_controller.h"
#include "core_v2/internal/service_controller.h"
#include "platform_v2/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