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

Side by Side Diff: mojo/public/cpp/bindings/tests/router_unittest.cc

Issue 617503003: Mojo: MOJO_OVERRIDE -> override in mojo/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 6 years, 2 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 2014 The Chromium Authors. All rights reserved. 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 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 <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include "mojo/public/cpp/bindings/lib/message_builder.h" 8 #include "mojo/public/cpp/bindings/lib/message_builder.h"
9 #include "mojo/public/cpp/bindings/lib/message_queue.h" 9 #include "mojo/public/cpp/bindings/lib/message_queue.h"
10 #include "mojo/public/cpp/bindings/lib/router.h" 10 #include "mojo/public/cpp/bindings/lib/router.h"
(...skipping 19 matching lines...) Expand all
30 internal::ResponseMessageBuilder builder(name, payload_size, request_id); 30 internal::ResponseMessageBuilder builder(name, payload_size, request_id);
31 memcpy(builder.buffer()->Allocate(payload_size), text, payload_size); 31 memcpy(builder.buffer()->Allocate(payload_size), text, payload_size);
32 builder.Finish(message); 32 builder.Finish(message);
33 } 33 }
34 34
35 class MessageAccumulator : public MessageReceiver { 35 class MessageAccumulator : public MessageReceiver {
36 public: 36 public:
37 explicit MessageAccumulator(internal::MessageQueue* queue) : queue_(queue) { 37 explicit MessageAccumulator(internal::MessageQueue* queue) : queue_(queue) {
38 } 38 }
39 39
40 virtual bool Accept(Message* message) MOJO_OVERRIDE { 40 virtual bool Accept(Message* message) override {
41 queue_->Push(message); 41 queue_->Push(message);
42 return true; 42 return true;
43 } 43 }
44 44
45 private: 45 private:
46 internal::MessageQueue* queue_; 46 internal::MessageQueue* queue_;
47 }; 47 };
48 48
49 class ResponseGenerator : public MessageReceiverWithResponder { 49 class ResponseGenerator : public MessageReceiverWithResponder {
50 public: 50 public:
51 ResponseGenerator() { 51 ResponseGenerator() {
52 } 52 }
53 53
54 virtual bool Accept(Message* message) MOJO_OVERRIDE { 54 virtual bool Accept(Message* message) override { return false; }
55 return false;
56 }
57 55
58 virtual bool AcceptWithResponder(Message* message, MessageReceiver* responder) 56 virtual bool AcceptWithResponder(Message* message,
59 MOJO_OVERRIDE { 57 MessageReceiver* responder) override {
60 EXPECT_TRUE(message->has_flag(internal::kMessageExpectsResponse)); 58 EXPECT_TRUE(message->has_flag(internal::kMessageExpectsResponse));
61 59
62 return SendResponse(message->name(), message->request_id(), responder); 60 return SendResponse(message->name(), message->request_id(), responder);
63 } 61 }
64 62
65 bool SendResponse(uint32_t name, uint64_t request_id, 63 bool SendResponse(uint32_t name, uint64_t request_id,
66 MessageReceiver* responder) { 64 MessageReceiver* responder) {
67 Message response; 65 Message response;
68 AllocResponseMessage(name, "world", request_id, &response); 66 AllocResponseMessage(name, "world", request_id, &response);
69 67
70 bool result = responder->Accept(&response); 68 bool result = responder->Accept(&response);
71 delete responder; 69 delete responder;
72 return result; 70 return result;
73 } 71 }
74 }; 72 };
75 73
76 class LazyResponseGenerator : public ResponseGenerator { 74 class LazyResponseGenerator : public ResponseGenerator {
77 public: 75 public:
78 LazyResponseGenerator() : responder_(NULL), name_(0), request_id_(0) { 76 LazyResponseGenerator() : responder_(NULL), name_(0), request_id_(0) {
79 } 77 }
80 78
81 virtual ~LazyResponseGenerator() { 79 virtual ~LazyResponseGenerator() {
82 delete responder_; 80 delete responder_;
83 } 81 }
84 82
85 virtual bool AcceptWithResponder(Message* message, MessageReceiver* responder) 83 virtual bool AcceptWithResponder(Message* message,
86 MOJO_OVERRIDE { 84 MessageReceiver* responder) override {
87 name_ = message->name(); 85 name_ = message->name();
88 request_id_ = message->request_id(); 86 request_id_ = message->request_id();
89 responder_ = responder; 87 responder_ = responder;
90 return true; 88 return true;
91 } 89 }
92 90
93 bool has_responder() const { return !!responder_; } 91 bool has_responder() const { return !!responder_; }
94 92
95 void Complete() { 93 void Complete() {
96 SendResponse(name_, request_id_, responder_); 94 SendResponse(name_, request_id_, responder_);
97 responder_ = NULL; 95 responder_ = NULL;
98 } 96 }
99 97
100 private: 98 private:
101 MessageReceiver* responder_; 99 MessageReceiver* responder_;
102 uint32_t name_; 100 uint32_t name_;
103 uint32_t request_id_; 101 uint32_t request_id_;
104 }; 102 };
105 103
106 class RouterTest : public testing::Test { 104 class RouterTest : public testing::Test {
107 public: 105 public:
108 RouterTest() { 106 RouterTest() {
109 } 107 }
110 108
111 virtual void SetUp() MOJO_OVERRIDE { 109 virtual void SetUp() override {
112 CreateMessagePipe(NULL, &handle0_, &handle1_); 110 CreateMessagePipe(NULL, &handle0_, &handle1_);
113 } 111 }
114 112
115 virtual void TearDown() MOJO_OVERRIDE { 113 virtual void TearDown() override {}
116 }
117 114
118 void PumpMessages() { 115 void PumpMessages() {
119 loop_.RunUntilIdle(); 116 loop_.RunUntilIdle();
120 } 117 }
121 118
122 protected: 119 protected:
123 ScopedMessagePipeHandle handle0_; 120 ScopedMessagePipeHandle handle0_;
124 ScopedMessagePipeHandle handle1_; 121 ScopedMessagePipeHandle handle1_;
125 122
126 private: 123 private:
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 EXPECT_TRUE(generator.has_responder()); 218 EXPECT_TRUE(generator.has_responder());
222 219
223 } 220 }
224 221
225 generator.Complete(); // This should end up doing nothing. 222 generator.Complete(); // This should end up doing nothing.
226 } 223 }
227 224
228 } // namespace 225 } // namespace
229 } // namespace test 226 } // namespace test
230 } // namespace mojo 227 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/request_response_unittest.cc ('k') | mojo/public/cpp/bindings/tests/sample_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698