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

Side by Side Diff: remoting/protocol/jingle_messages_unittest.cc

Issue 2026123002: [Chromoting] Use google:remoting namespace to export remoting specific error codes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve review comments Created 4 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/protocol/jingle_messages.h" 5 #include "remoting/protocol/jingle_messages.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 ASSERT_TRUE(source_message.get()); 559 ASSERT_TRUE(source_message.get());
560 560
561 EXPECT_FALSE(JingleMessage::IsJingleMessage(source_message.get())); 561 EXPECT_FALSE(JingleMessage::IsJingleMessage(source_message.get()));
562 562
563 JingleMessage message; 563 JingleMessage message;
564 std::string error; 564 std::string error;
565 EXPECT_FALSE(message.ParseXml(source_message.get(), &error)); 565 EXPECT_FALSE(message.ParseXml(source_message.get(), &error));
566 EXPECT_FALSE(error.empty()); 566 EXPECT_FALSE(error.empty());
567 } 567 }
568 568
569 TEST(JingleMessageTest, ErrorCodeShouldBeIncludedInXml) {
570 JingleMessage message(std::string("to_jid"),
571 JingleMessage::SESSION_TERMINATE,
572 std::string("sid"));
573 message.action = JingleMessage::SESSION_TERMINATE;
574 message.reason = JingleMessage::DECLINE;
575 message.error_code = INVALID_ACCOUNT;
576 JingleMessage parsed;
577 ParseFormatAndCompare(message.ToXml()->Str().c_str(), &parsed);
Sergey Ulanov 2016/06/03 08:53:49 This tests formats message, parses it and then for
Hzj_jie 2016/06/03 21:46:34 This test was for debugging purpose, I should remo
578 EXPECT_EQ(message.action, parsed.action);
579 EXPECT_EQ(message.reason, parsed.reason);
580 EXPECT_EQ(message.error_code, parsed.error_code);
581
582 message.error_code = UNKNOWN_ERROR;
583 parsed.error_code = UNKNOWN_ERROR;
584 ParseFormatAndCompare(message.ToXml()->Str().c_str(), &parsed);
585 EXPECT_EQ(message.action, parsed.action);
586 EXPECT_EQ(message.reason, parsed.reason);
587 EXPECT_EQ(UNKNOWN_ERROR, parsed.error_code);
Sergey Ulanov 2016/06/03 08:53:49 Add this condition in the SessionTerminate test ab
Hzj_jie 2016/06/03 21:46:33 Acknowledged.
588 }
589
590 TEST(JingleMessageTest, InvalidAccount) {
591 const char* kTestSessionTerminateMessage =
592 "<cli:iq from='user@gmail.com/chromoting016DBB07' "
593 "to='user@gmail.com/chromiumsy5C6A652D' type='set' "
594 "xmlns:cli='jabber:client'><jingle action='session-terminate' "
595 "sid='2227053353' xmlns='urn:xmpp:jingle:1'><reason><decline/></reason>"
596 "<gr:error-code xmlns:gr='google:remoting'>"
597 "<gr:INVALID_ACCOUNT/>"
598 "</gr:error-code>"
599 "</jingle></cli:iq>";
600 JingleMessage message;
601 ParseFormatAndCompare(kTestSessionTerminateMessage, &message);
602 EXPECT_EQ(message.action, JingleMessage::SESSION_TERMINATE);
603 EXPECT_EQ(message.reason, JingleMessage::DECLINE);
604 EXPECT_EQ(message.error_code, INVALID_ACCOUNT);
605 }
606
607 TEST(JingleMessageTest, AuthenticationFailed) {
Sergey Ulanov 2016/06/03 08:53:49 Maybe instead of testing these two errors in two s
Hzj_jie 2016/06/03 21:46:34 Done.
608 const char* kTestSessionTerminateMessage =
609 "<cli:iq from='user@gmail.com/chromoting016DBB07' "
610 "to='user@gmail.com/chromiumsy5C6A652D' type='set' "
611 "xmlns:cli='jabber:client'><jingle action='session-terminate' "
612 "sid='2227053353' xmlns='urn:xmpp:jingle:1'><reason><decline/></reason>"
613 "<gr:error-code xmlns:gr='google:remoting'>"
614 "<gr:AUTHENTICATION_FAILED />"
615 "</gr:error-code>"
616 "</jingle></cli:iq>";
617 JingleMessage message;
618 ParseFormatAndCompare(kTestSessionTerminateMessage, &message);
619 EXPECT_EQ(message.action, JingleMessage::SESSION_TERMINATE);
620 EXPECT_EQ(message.reason, JingleMessage::DECLINE);
621 EXPECT_EQ(message.error_code, AUTHENTICATION_FAILED);
622 }
623
569 } // namespace protocol 624 } // namespace protocol
570 } // namespace remoting 625 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698