tests: merge TcpChannel and UdpChannel test suites using test case templates

Change-Id: Id56bb036db53494d4d250f9ea68a3ded78b33ddb
Refs: #3514
diff --git a/tests/daemon/face/unix-stream-channel.t.cpp b/tests/daemon/face/unix-stream-channel.t.cpp
index 37eae6d..dcd0270 100644
--- a/tests/daemon/face/unix-stream-channel.t.cpp
+++ b/tests/daemon/face/unix-stream-channel.t.cpp
@@ -25,8 +25,7 @@
 
 #include "face/unix-stream-channel.hpp"
 
-#include "tests/limited-io.hpp"
-#include "factory-test-common.hpp"
+#include "channel-fixture.hpp"
 
 #include <boost/filesystem.hpp>
 #include <fstream>
@@ -34,22 +33,19 @@
 namespace nfd {
 namespace tests {
 
-BOOST_AUTO_TEST_SUITE(Face)
-
-using nfd::Face;
 namespace fs = boost::filesystem;
 namespace local = boost::asio::local;
 
-class UnixStreamChannelFixture : public BaseFixture
+class UnixStreamChannelFixture : public ChannelFixture<UnixStreamChannel, unix_stream::Endpoint>
 {
 protected:
   UnixStreamChannelFixture()
-    : listenerEp("nfd-test-unix-stream-channel.sock")
   {
+    listenerEp = unix_stream::Endpoint("nfd-test-unix-stream-channel.sock");
   }
 
-  unique_ptr<UnixStreamChannel>
-  makeChannel()
+  virtual unique_ptr<UnixStreamChannel>
+  makeChannel() final
   {
     return make_unique<UnixStreamChannel>(listenerEp);
   }
@@ -65,11 +61,11 @@
         listenerFaces.push_back(newFace);
         limitedIo.afterOp();
       },
-      &failIfError);
+      ChannelFixture::unexpectedFailure);
   }
 
   void
-  connect(local::stream_protocol::socket& client)
+  clientConnect(local::stream_protocol::socket& client)
   {
     client.async_connect(listenerEp,
       [this] (const boost::system::error_code& error) {
@@ -77,16 +73,17 @@
         limitedIo.afterOp();
       });
   }
-
-protected:
-  LimitedIo limitedIo;
-  unix_stream::Endpoint listenerEp;
-  unique_ptr<UnixStreamChannel> listenerChannel;
-  std::vector<shared_ptr<Face>> listenerFaces;
 };
 
+BOOST_AUTO_TEST_SUITE(Face)
 BOOST_FIXTURE_TEST_SUITE(TestUnixStreamChannel, UnixStreamChannelFixture)
 
+BOOST_AUTO_TEST_CASE(Uri)
+{
+  auto channel = makeChannel();
+  BOOST_CHECK_EQUAL(channel->getUri(), FaceUri(listenerEp));
+}
+
 BOOST_AUTO_TEST_CASE(Listen)
 {
   auto channel = makeChannel();
@@ -108,15 +105,15 @@
   BOOST_CHECK_EQUAL(listenerFaces.size(), 0);
 
   local::stream_protocol::socket client1(g_io);
-  this->connect(client1);
+  this->clientConnect(client1);
 
   BOOST_CHECK_EQUAL(limitedIo.run(2, time::seconds(1)), LimitedIo::EXCEED_OPS);
   BOOST_CHECK_EQUAL(listenerFaces.size(), 1);
 
   local::stream_protocol::socket client2(g_io);
   local::stream_protocol::socket client3(g_io);
-  this->connect(client2);
-  this->connect(client3);
+  this->clientConnect(client2);
+  this->clientConnect(client3);
 
   BOOST_CHECK_EQUAL(limitedIo.run(4, time::seconds(1)), LimitedIo::EXCEED_OPS);
   BOOST_CHECK_EQUAL(listenerFaces.size(), 3);