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

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 EXPECT_EQ(message.ToXml()->Str(),
Sergey Ulanov 2016/06/02 09:26:04 You don't want to compare generate XML as string.
Hzj_jie 2016/06/02 22:00:18 Done.
577 "<iq xmlns=\"jabber:client\" to=\"to_jid\" type=\"set\">"
578 "<jingle xmlns=\"urn:xmpp:jingle:1\" sid=\"sid\" "
579 "action=\"session-terminate\">"
580 "<reason><decline/></reason>"
581 "<rem:error-code xmlns:rem=\"google:remoting\">"
582 "<rem:INVALID_ACCOUNT/>"
583 "</rem:error-code>"
584 "</jingle>"
585 "</iq>");
586 JingleMessage parsed;
587 ParseFormatAndCompare(message.ToXml()->Str().c_str(), &parsed);
588 EXPECT_EQ(message.action, parsed.action);
589 EXPECT_EQ(message.reason, parsed.reason);
590 EXPECT_EQ(message.error_code, parsed.error_code);
591
592 message.error_code = parsed.error_code = UNKNOWN_ERROR;
Sergey Ulanov 2016/06/02 09:26:04 this double assignment is not readable. Please spl
Hzj_jie 2016/06/02 22:00:19 Done.
593 EXPECT_EQ(message.ToXml()->Str(),
594 "<iq xmlns=\"jabber:client\" to=\"to_jid\" type=\"set\">"
595 "<jingle xmlns=\"urn:xmpp:jingle:1\" sid=\"sid\" "
596 "action=\"session-terminate\">"
597 "<reason><decline/></reason>"
598 "</jingle>"
599 "</iq>");
600 ParseFormatAndCompare(message.ToXml()->Str().c_str(), &parsed);
601 EXPECT_EQ(message.action, parsed.action);
602 EXPECT_EQ(message.reason, parsed.reason);
603 }
604
605 TEST(JingleMessageTest, InvalidAccount) {
606 const char* kTestSessionTerminateMessage =
607 "<cli:iq from='user@gmail.com/chromoting016DBB07' "
608 "to='user@gmail.com/chromiumsy5C6A652D' type='set' "
609 "xmlns:cli='jabber:client'><jingle action='session-terminate' "
610 "sid='2227053353' xmlns='urn:xmpp:jingle:1'><reason><decline/></reason>"
611 "<gr:error-code xmlns:gr='google:remoting'>"
612 "<gr:INVALID_ACCOUNT/>"
613 "</gr:error-code>"
614 "</jingle></cli:iq>";
615 JingleMessage message;
616 ParseFormatAndCompare(kTestSessionTerminateMessage, &message);
617 EXPECT_EQ(message.action, JingleMessage::SESSION_TERMINATE);
618 EXPECT_EQ(message.reason, JingleMessage::DECLINE);
619 EXPECT_EQ(message.error_code, INVALID_ACCOUNT);
620 }
621
622 TEST(JingleMessageTest, AuthenticationFailed) {
623 const char* kTestSessionTerminateMessage =
624 "<cli:iq from='user@gmail.com/chromoting016DBB07' "
625 "to='user@gmail.com/chromiumsy5C6A652D' type='set' "
626 "xmlns:cli='jabber:client'><jingle action='session-terminate' "
627 "sid='2227053353' xmlns='urn:xmpp:jingle:1'><reason><decline/></reason>"
628 "<gr:error-code xmlns:gr='google:remoting'>"
629 "<gr:AUTHENTICATION_FAILED />"
630 "</gr:error-code>"
631 "</jingle></cli:iq>";
632 JingleMessage message;
633 ParseFormatAndCompare(kTestSessionTerminateMessage, &message);
634 EXPECT_EQ(message.action, JingleMessage::SESSION_TERMINATE);
635 EXPECT_EQ(message.reason, JingleMessage::DECLINE);
636 EXPECT_EQ(message.error_code, AUTHENTICATION_FAILED);
637 }
638
569 } // namespace protocol 639 } // namespace protocol
570 } // namespace remoting 640 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698