1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// Copyright 2015 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 "blimp/common/create_blimp_message.h"
#include "blimp/common/proto/blimp_message.pb.h"
#include "blimp/common/proto/compositor.pb.h"
#include "blimp/common/proto/input.pb.h"
#include "blimp/common/proto/navigation.pb.h"
#include "blimp/common/proto/render_widget.pb.h"
#include "blimp/common/proto/size.pb.h"
#include "blimp/common/proto/tab_control.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace blimp {
namespace {
const int kTabId = 1234;
TEST(CreateBlimpMessageTest, CompositorMessage) {
CompositorMessage* details = nullptr;
scoped_ptr<BlimpMessage> message = CreateBlimpMessage(&details, kTabId);
EXPECT_NE(nullptr, details);
EXPECT_NE(nullptr, message);
EXPECT_EQ(details, message->mutable_compositor());
EXPECT_EQ(kTabId, message->target_tab_id());
}
TEST(CreateBlimpMessageTest, TabControlMessage) {
TabControlMessage* details = nullptr;
scoped_ptr<BlimpMessage> message = CreateBlimpMessage(&details);
EXPECT_NE(nullptr, details);
EXPECT_NE(nullptr, message);
EXPECT_EQ(details, message->mutable_tab_control());
}
TEST(CreateBlimpMessageTest, InputMessage) {
InputMessage* details = nullptr;
scoped_ptr<BlimpMessage> message = CreateBlimpMessage(&details);
EXPECT_NE(nullptr, details);
EXPECT_NE(nullptr, message);
EXPECT_EQ(details, message->mutable_input());
}
TEST(CreateBlimpMessageTest, NavigationMessage) {
NavigationMessage* details = nullptr;
scoped_ptr<BlimpMessage> message = CreateBlimpMessage(&details, kTabId);
EXPECT_NE(nullptr, details);
EXPECT_NE(nullptr, message);
EXPECT_EQ(details, message->mutable_navigation());
EXPECT_EQ(kTabId, message->target_tab_id());
}
TEST(CreateBlimpMessageTest, RenderWidgetMessage) {
RenderWidgetMessage* details = nullptr;
scoped_ptr<BlimpMessage> message = CreateBlimpMessage(&details, kTabId);
EXPECT_NE(nullptr, details);
EXPECT_NE(nullptr, message);
EXPECT_EQ(details, message->mutable_render_widget());
EXPECT_EQ(kTabId, message->target_tab_id());
}
TEST(CreateBlimpMessageTest, SizeMessage) {
SizeMessage* details = nullptr;
scoped_ptr<BlimpMessage> message = CreateBlimpMessage(&details);
EXPECT_NE(nullptr, details);
EXPECT_NE(nullptr, message);
EXPECT_EQ(TabControlMessage::SIZE, message->mutable_tab_control()->type());
EXPECT_EQ(details, message->mutable_tab_control()->mutable_size());
}
TEST(CreateBlimpMessageTest, StartConnectionMessage) {
const char* client_token = "token";
const int protocol_version = 1;
scoped_ptr<BlimpMessage> message =
CreateStartConnectionMessage(client_token, protocol_version);
EXPECT_NE(nullptr, message);
EXPECT_EQ(BlimpMessage::PROTOCOL_CONTROL, message->type());
EXPECT_EQ(ProtocolControlMessage::START_CONNECTION,
message->protocol_control().type());
EXPECT_EQ(client_token,
message->protocol_control().start_connection().client_token());
EXPECT_EQ(protocol_version,
message->protocol_control().start_connection().protocol_version());
}
} // namespace
} // namespace blimp
|