summaryrefslogtreecommitdiff
path: root/chromium/net/third_party/quiche/src/quic/qbone/bonnet/qbone_tunnel_silo_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/net/third_party/quiche/src/quic/qbone/bonnet/qbone_tunnel_silo_test.cc')
-rw-r--r--chromium/net/third_party/quiche/src/quic/qbone/bonnet/qbone_tunnel_silo_test.cc78
1 files changed, 78 insertions, 0 deletions
diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/qbone_tunnel_silo_test.cc b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/qbone_tunnel_silo_test.cc
new file mode 100644
index 00000000000..8327a53eacc
--- /dev/null
+++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/qbone_tunnel_silo_test.cc
@@ -0,0 +1,78 @@
+// Copyright (c) 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "quic/qbone/bonnet/qbone_tunnel_silo.h"
+
+#include "absl/synchronization/notification.h"
+#include "quic/platform/api/quic_test.h"
+#include "quic/qbone/bonnet/mock_qbone_tunnel.h"
+
+namespace quic {
+namespace {
+
+using ::testing::Eq;
+using ::testing::Invoke;
+using ::testing::Return;
+
+TEST(QboneTunnelSiloTest, SiloRunsEventLoop) {
+ MockQboneTunnel mock_tunnel;
+
+ absl::Notification event_loop_run;
+ EXPECT_CALL(mock_tunnel, WaitForEvents)
+ .WillRepeatedly(Invoke([&event_loop_run]() {
+ if (!event_loop_run.HasBeenNotified()) {
+ event_loop_run.Notify();
+ }
+ return false;
+ }));
+
+ QboneTunnelSilo silo(&mock_tunnel, false);
+ silo.Start();
+
+ event_loop_run.WaitForNotification();
+
+ absl::Notification client_disconnected;
+ EXPECT_CALL(mock_tunnel, Disconnect)
+ .WillOnce(Invoke([&client_disconnected]() {
+ client_disconnected.Notify();
+ return QboneTunnelInterface::ENDED;
+ }));
+
+ silo.Quit();
+ client_disconnected.WaitForNotification();
+
+ silo.Join();
+}
+
+TEST(QboneTunnelSiloTest, SiloCanShutDownAfterInit) {
+ MockQboneTunnel mock_tunnel;
+
+ int iteration_count = 0;
+ EXPECT_CALL(mock_tunnel, WaitForEvents)
+ .WillRepeatedly(Invoke([&iteration_count]() {
+ iteration_count++;
+ return false;
+ }));
+
+ EXPECT_CALL(mock_tunnel, state)
+ .WillOnce(Return(QboneTunnelInterface::START_REQUESTED))
+ .WillOnce(Return(QboneTunnelInterface::STARTED));
+
+ absl::Notification client_disconnected;
+ EXPECT_CALL(mock_tunnel, Disconnect)
+ .WillOnce(Invoke([&client_disconnected]() {
+ client_disconnected.Notify();
+ return QboneTunnelInterface::ENDED;
+ }));
+
+ QboneTunnelSilo silo(&mock_tunnel, true);
+ silo.Start();
+
+ client_disconnected.WaitForNotification();
+ silo.Join();
+ EXPECT_THAT(iteration_count, Eq(1));
+}
+
+} // namespace
+} // namespace quic