Clean up extension confirmation prompts and make them consistent between Views and...
[chromium-blink-merge.git] / remoting / host / server_log_entry_host_unittest.cc
blobd249c0376df79f446194fedebeff32182f5a4971
1 // Copyright 2014 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.
5 #include "base/memory/scoped_ptr.h"
6 #include "base/strings/stringize_macros.h"
7 #include "remoting/host/server_log_entry_host.h"
8 #include "remoting/signaling/server_log_entry.h"
9 #include "remoting/signaling/server_log_entry_unittest.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
13 using buzz::XmlAttr;
14 using buzz::XmlElement;
16 namespace remoting {
18 TEST(ServerLogEntryHostTest, MakeForSessionStateChange) {
19 scoped_ptr<ServerLogEntry> entry(MakeLogEntryForSessionStateChange(true));
20 scoped_ptr<XmlElement> stanza = entry->ToStanza();
21 std::string error;
22 std::map<std::string, std::string> key_value_pairs;
23 key_value_pairs["role"] = "host";
24 key_value_pairs["event-name"] = "session-state";
25 key_value_pairs["session-state"] = "connected";
26 std::set<std::string> keys;
27 ASSERT_TRUE(VerifyStanza(key_value_pairs, keys, stanza.get(), &error))
28 << error;
31 TEST(ServerLogEntryHostTest, MakeForHeartbeat) {
32 scoped_ptr<ServerLogEntry> entry(MakeLogEntryForHeartbeat());
33 scoped_ptr<XmlElement> stanza = entry->ToStanza();
34 std::string error;
35 std::map<std::string, std::string> key_value_pairs;
36 key_value_pairs["role"] = "host";
37 key_value_pairs["event-name"] = "heartbeat";
38 std::set<std::string> keys;
39 ASSERT_TRUE(VerifyStanza(key_value_pairs, keys, stanza.get(), &error))
40 << error;
43 TEST(ServerLogEntryHostTest, AddHostFields) {
44 scoped_ptr<ServerLogEntry> entry(MakeLogEntryForSessionStateChange(true));
45 AddHostFieldsToLogEntry(entry.get());
46 scoped_ptr<XmlElement> stanza = entry->ToStanza();
47 std::string error;
48 std::map<std::string, std::string> key_value_pairs;
49 key_value_pairs["role"] = "host";
50 key_value_pairs["event-name"] = "session-state";
51 key_value_pairs["session-state"] = "connected";
52 std::set<std::string> keys;
53 keys.insert("cpu");
54 #if defined(OS_WIN)
55 key_value_pairs["os-name"] = "Windows";
56 keys.insert("os-version");
57 #elif defined(OS_MACOSX)
58 key_value_pairs["os-name"] = "Mac";
59 keys.insert("os-version");
60 #elif defined(OS_CHROMEOS)
61 key_value_pairs["os-name"] = "ChromeOS";
62 keys.insert("os-version");
63 #elif defined(OS_LINUX)
64 key_value_pairs["os-name"] = "Linux";
65 #endif
67 // The check below will compile but fail if VERSION isn't defined (STRINGIZE
68 // silently converts undefined values).
69 #ifndef VERSION
70 #error VERSION must be defined
71 #endif
72 key_value_pairs["host-version"] = STRINGIZE(VERSION);
73 ASSERT_TRUE(VerifyStanza(key_value_pairs, keys, stanza.get(), &error)) <<
74 error;
77 TEST(ServerLogEntryHostTest, AddModeField1) {
78 scoped_ptr<ServerLogEntry> entry(MakeLogEntryForSessionStateChange(true));
79 entry->AddModeField(ServerLogEntry::IT2ME);
80 scoped_ptr<XmlElement> stanza = entry->ToStanza();
81 std::string error;
82 std::map<std::string, std::string> key_value_pairs;
83 key_value_pairs["role"] = "host";
84 key_value_pairs["event-name"] = "session-state";
85 key_value_pairs["session-state"] = "connected";
86 key_value_pairs["mode"] = "it2me";
87 std::set<std::string> keys;
88 ASSERT_TRUE(VerifyStanza(key_value_pairs, keys, stanza.get(), &error)) <<
89 error;
92 TEST(ServerLogEntryHostTest, AddModeField2) {
93 scoped_ptr<ServerLogEntry> entry(MakeLogEntryForSessionStateChange(true));
94 entry->AddModeField(ServerLogEntry::ME2ME);
95 scoped_ptr<XmlElement> stanza = entry->ToStanza();
96 std::string error;
97 std::map<std::string, std::string> key_value_pairs;
98 key_value_pairs["role"] = "host";
99 key_value_pairs["event-name"] = "session-state";
100 key_value_pairs["session-state"] = "connected";
101 key_value_pairs["mode"] = "me2me";
102 std::set<std::string> keys;
103 ASSERT_TRUE(VerifyStanza(key_value_pairs, keys, stanza.get(), &error)) <<
104 error;
107 } // namespace remoting