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

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

Issue 1933053003: Used oneof in blimp_message.proto (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 4 years, 7 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "blimp/net/blimp_message_demultiplexer.h" 5 #include "blimp/net/blimp_message_demultiplexer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "blimp/common/create_blimp_message.h"
8 #include "blimp/net/test_common.h" 9 #include "blimp/net/test_common.h"
9 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
10 #include "net/base/test_completion_callback.h" 11 #include "net/base/test_completion_callback.h"
11 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 using testing::_; 15 using testing::_;
15 using testing::InvokeArgument; 16 using testing::InvokeArgument;
16 using testing::Ref; 17 using testing::Ref;
17 using testing::Return; 18 using testing::Return;
18 using testing::SaveArg; 19 using testing::SaveArg;
19 20
20 namespace blimp { 21 namespace blimp {
21 22
22 class BlimpMessageDemultiplexerTest : public testing::Test { 23 class BlimpMessageDemultiplexerTest : public testing::Test {
23 public: 24 public:
24 BlimpMessageDemultiplexerTest() 25 BlimpMessageDemultiplexerTest()
25 : input_msg_(new BlimpMessage), compositor_msg_(new BlimpMessage) {} 26 : input_msg_(new BlimpMessage), compositor_msg_(new BlimpMessage) {}
26 27
27 void SetUp() override { 28 void SetUp() override {
28 demux_.AddProcessor(BlimpMessage::INPUT, &receiver1_); 29 demux_.AddProcessor(BlimpMessage::kInput, &receiver1_);
29 demux_.AddProcessor(BlimpMessage::COMPOSITOR, &receiver2_); 30 demux_.AddProcessor(BlimpMessage::kCompositor, &receiver2_);
30 input_msg_->set_type(BlimpMessage::INPUT); 31 InputMessage* input = nullptr;
31 compositor_msg_->set_type(BlimpMessage::COMPOSITOR); 32 input_msg_ = CreateBlimpMessage(&input);
33 CompositorMessage* compositor = nullptr;
34 compositor_msg_ = CreateBlimpMessage(&compositor, 1);
32 } 35 }
33 36
34 protected: 37 protected:
35 std::unique_ptr<BlimpMessage> input_msg_; 38 std::unique_ptr<BlimpMessage> input_msg_;
36 std::unique_ptr<BlimpMessage> compositor_msg_; 39 std::unique_ptr<BlimpMessage> compositor_msg_;
37 MockBlimpMessageProcessor receiver1_; 40 MockBlimpMessageProcessor receiver1_;
38 MockBlimpMessageProcessor receiver2_; 41 MockBlimpMessageProcessor receiver2_;
39 net::CompletionCallback captured_cb_; 42 net::CompletionCallback captured_cb_;
40 BlimpMessageDemultiplexer demux_; 43 BlimpMessageDemultiplexer demux_;
41 }; 44 };
(...skipping 12 matching lines...) Expand all
54 .WillOnce(SaveArg<1>(&captured_cb_)); 57 .WillOnce(SaveArg<1>(&captured_cb_));
55 net::TestCompletionCallback cb2; 58 net::TestCompletionCallback cb2;
56 demux_.ProcessMessage(std::move(compositor_msg_), cb2.callback()); 59 demux_.ProcessMessage(std::move(compositor_msg_), cb2.callback());
57 captured_cb_.Run(net::ERR_FAILED); 60 captured_cb_.Run(net::ERR_FAILED);
58 EXPECT_EQ(net::ERR_FAILED, cb2.WaitForResult()); 61 EXPECT_EQ(net::ERR_FAILED, cb2.WaitForResult());
59 } 62 }
60 63
61 TEST_F(BlimpMessageDemultiplexerTest, ProcessMessageNoRegisteredHandler) { 64 TEST_F(BlimpMessageDemultiplexerTest, ProcessMessageNoRegisteredHandler) {
62 net::TestCompletionCallback cb; 65 net::TestCompletionCallback cb;
63 std::unique_ptr<BlimpMessage> unknown_message(new BlimpMessage); 66 std::unique_ptr<BlimpMessage> unknown_message(new BlimpMessage);
64 unknown_message->set_type(BlimpMessage::UNKNOWN);
65 demux_.ProcessMessage(std::move(unknown_message), cb.callback()); 67 demux_.ProcessMessage(std::move(unknown_message), cb.callback());
66 EXPECT_EQ(net::ERR_NOT_IMPLEMENTED, cb.WaitForResult()); 68 EXPECT_EQ(net::ERR_NOT_IMPLEMENTED, cb.WaitForResult());
67 } 69 }
68 70
69 } // namespace blimp 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