Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(811)

Side by Side Diff: blimp/net/blimp_message_demultiplexer_unittest.cc

Issue 2632803002: Remove all blimp network code. (Closed)
Patch Set: merge from origin/master for good measure Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « blimp/net/blimp_message_demultiplexer.cc ('k') | blimp/net/blimp_message_multiplexer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "blimp/net/blimp_message_demultiplexer.h"
6
7 #include "base/logging.h"
8 #include "blimp/common/create_blimp_message.h"
9 #include "blimp/net/test_common.h"
10 #include "net/base/net_errors.h"
11 #include "net/base/test_completion_callback.h"
12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 using testing::_;
16 using testing::InvokeArgument;
17 using testing::Ref;
18 using testing::Return;
19 using testing::SaveArg;
20
21 namespace blimp {
22
23 class BlimpMessageDemultiplexerTest : public testing::Test {
24 public:
25 BlimpMessageDemultiplexerTest()
26 : input_msg_(new BlimpMessage), compositor_msg_(new BlimpMessage) {}
27
28 void SetUp() override {
29 demux_.AddProcessor(BlimpMessage::kInput, &receiver1_);
30 demux_.AddProcessor(BlimpMessage::kCompositor, &receiver2_);
31 InputMessage* input = nullptr;
32 input_msg_ = CreateBlimpMessage(&input);
33 CompositorMessage* compositor = nullptr;
34 compositor_msg_ = CreateBlimpMessage(&compositor, 1);
35 }
36
37 protected:
38 std::unique_ptr<BlimpMessage> input_msg_;
39 std::unique_ptr<BlimpMessage> compositor_msg_;
40 MockBlimpMessageProcessor receiver1_;
41 MockBlimpMessageProcessor receiver2_;
42 net::CompletionCallback captured_cb_;
43 BlimpMessageDemultiplexer demux_;
44 };
45
46 TEST_F(BlimpMessageDemultiplexerTest, ProcessMessageOK) {
47 EXPECT_CALL(receiver1_, MockableProcessMessage(Ref(*input_msg_), _))
48 .WillOnce(SaveArg<1>(&captured_cb_));
49 net::TestCompletionCallback cb;
50 demux_.ProcessMessage(std::move(input_msg_), cb.callback());
51 captured_cb_.Run(net::OK);
52 EXPECT_EQ(net::OK, cb.WaitForResult());
53 }
54
55 TEST_F(BlimpMessageDemultiplexerTest, ProcessMessageFailed) {
56 EXPECT_CALL(receiver2_, MockableProcessMessage(Ref(*compositor_msg_), _))
57 .WillOnce(SaveArg<1>(&captured_cb_));
58 net::TestCompletionCallback cb2;
59 demux_.ProcessMessage(std::move(compositor_msg_), cb2.callback());
60 captured_cb_.Run(net::ERR_FAILED);
61 EXPECT_EQ(net::ERR_FAILED, cb2.WaitForResult());
62 }
63
64 TEST_F(BlimpMessageDemultiplexerTest, ProcessMessageNoRegisteredHandler) {
65 net::TestCompletionCallback cb;
66 std::unique_ptr<BlimpMessage> unknown_message(new BlimpMessage);
67 demux_.ProcessMessage(std::move(unknown_message), cb.callback());
68 EXPECT_EQ(net::ERR_NOT_IMPLEMENTED, cb.WaitForResult());
69 }
70
71 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/net/blimp_message_demultiplexer.cc ('k') | blimp/net/blimp_message_multiplexer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698