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

Side by Side Diff: google_apis/gcm/engine/connection_handler_impl_unittest.cc

Issue 149073006: Explicit destruction order in gcm_unit_tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "google_apis/gcm/engine/connection_handler_impl.h" 5 #include "google_apis/gcm/engine/connection_handler_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 const char kDataMsgCategoryLong2[] = 42 const char kDataMsgCategoryLong2[] =
43 "this is a second long category that will result in a message > 128 bytes"; 43 "this is a second long category that will result in a message > 128 bytes";
44 44
45 // ---- Helpers for building messages. ---- 45 // ---- Helpers for building messages. ----
46 46
47 // Encode a protobuf packet with protobuf type |tag| and serialized protobuf 47 // Encode a protobuf packet with protobuf type |tag| and serialized protobuf
48 // bytes |proto| into the MCS message form (tag + varint size + bytes). 48 // bytes |proto| into the MCS message form (tag + varint size + bytes).
49 std::string EncodePacket(uint8 tag, const std::string& proto) { 49 std::string EncodePacket(uint8 tag, const std::string& proto) {
50 std::string result; 50 std::string result;
51 google::protobuf::io::StringOutputStream string_output_stream(&result); 51 google::protobuf::io::StringOutputStream string_output_stream(&result);
52 google::protobuf::io::CodedOutputStream coded_output_stream( 52 {
53 google::protobuf::io::CodedOutputStream coded_output_stream(
53 &string_output_stream); 54 &string_output_stream);
54 const unsigned char tag_byte[1] = {tag}; 55 const unsigned char tag_byte[1] = { tag };
55 coded_output_stream.WriteRaw(tag_byte, 1); 56 coded_output_stream.WriteRaw(tag_byte, 1);
56 coded_output_stream.WriteVarint32(proto.size()); 57 coded_output_stream.WriteVarint32(proto.size());
57 coded_output_stream.WriteRaw(proto.c_str(), proto.size()); 58 coded_output_stream.WriteRaw(proto.c_str(), proto.size());
59 // ~CodedOutputStream must run before the move constructor at the
60 // return statement. http://crbug.com/338962
61 }
58 return result; 62 return result;
59 } 63 }
60 64
61 // Encode a handshake request into the MCS message form. 65 // Encode a handshake request into the MCS message form.
62 std::string EncodeHandshakeRequest() { 66 std::string EncodeHandshakeRequest() {
63 std::string result; 67 std::string result;
64 const char version_byte[1] = {kMCSVersion}; 68 const char version_byte[1] = {kMCSVersion};
65 result.append(version_byte, 1); 69 result.append(version_byte, 1);
66 ScopedMessage login_request(BuildLoginRequest(kAuthId, kAuthToken)); 70 ScopedMessage login_request(BuildLoginRequest(kAuthId, kAuthToken));
67 result.append(EncodePacket(kLoginRequestTag, 71 result.append(EncodePacket(kLoginRequestTag,
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 data_message.set_category(kDataMsgCategory); 623 data_message.set_category(kDataMsgCategory);
620 connection_handler()->SendMessage(data_message); 624 connection_handler()->SendMessage(data_message);
621 EXPECT_FALSE(connection_handler()->CanSendMessage()); 625 EXPECT_FALSE(connection_handler()->CanSendMessage());
622 WaitForMessage(); // The message send. Should result in an error 626 WaitForMessage(); // The message send. Should result in an error
623 EXPECT_FALSE(connection_handler()->CanSendMessage()); 627 EXPECT_FALSE(connection_handler()->CanSendMessage());
624 EXPECT_EQ(net::ERR_CONNECTION_CLOSED, last_error()); 628 EXPECT_EQ(net::ERR_CONNECTION_CLOSED, last_error());
625 } 629 }
626 630
627 } // namespace 631 } // namespace
628 } // namespace gcm 632 } // namespace gcm
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698