blob: 6897a2a621a1c42d5bccf73df7154ab697f5c077 [file] [log] [blame]
Steve DiBenedettoef04f272014-06-04 14:28:31 -06001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014, Regents of the University of California,
4 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis
10 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26#include "face/websocket-factory.hpp"
27#include "tests/test-common.hpp"
28
29namespace nfd {
30namespace tests {
31
32BOOST_FIXTURE_TEST_SUITE(FaceWebSocket, BaseFixture)
33
34BOOST_AUTO_TEST_CASE(GetChannels)
35{
36 WebSocketFactory factory("19596");
37 BOOST_REQUIRE_EQUAL(factory.getChannels().empty(), true);
38
39 std::vector<shared_ptr<const Channel> > expectedChannels;
40
41 expectedChannels.push_back(factory.createChannel("127.0.0.1", "20070"));
42 expectedChannels.push_back(factory.createChannel("127.0.0.1", "20071"));
43 expectedChannels.push_back(factory.createChannel("::1", "20071"));
44
45 std::list<shared_ptr<const Channel> > channels = factory.getChannels();
46 for (std::list<shared_ptr<const Channel> >::const_iterator i = channels.begin();
47 i != channels.end(); ++i)
48 {
49 std::vector<shared_ptr<const Channel> >::iterator pos =
50 std::find(expectedChannels.begin(), expectedChannels.end(), *i);
51
52 BOOST_REQUIRE(pos != expectedChannels.end());
53 expectedChannels.erase(pos);
54 }
55
56 BOOST_CHECK_EQUAL(expectedChannels.size(), 0);
57}
58
59BOOST_AUTO_TEST_SUITE_END()
60
61} // namespace tests
62} // namespace nfd