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

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

Issue 1150563003: Rename InterfacePtr's WaitForIncomingMethodCall() -> WaitForIncomingResponse(). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 7 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 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 "mojo/public/cpp/bindings/binding.h" 5 #include "mojo/public/cpp/bindings/binding.h"
6 #include "mojo/public/cpp/bindings/error_handler.h" 6 #include "mojo/public/cpp/bindings/error_handler.h"
7 #include "mojo/public/cpp/bindings/strong_binding.h" 7 #include "mojo/public/cpp/bindings/strong_binding.h"
8 #include "mojo/public/cpp/environment/environment.h" 8 #include "mojo/public/cpp/environment/environment.h"
9 #include "mojo/public/cpp/utility/run_loop.h" 9 #include "mojo/public/cpp/utility/run_loop.h"
10 #include "mojo/public/interfaces/bindings/tests/math_calculator.mojom.h" 10 #include "mojo/public/interfaces/bindings/tests/math_calculator.mojom.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 Binding<math::Calculator> binding_; 80 Binding<math::Calculator> binding_;
81 }; 81 };
82 82
83 class MathCalculatorUI { 83 class MathCalculatorUI {
84 public: 84 public:
85 explicit MathCalculatorUI(math::CalculatorPtr calculator) 85 explicit MathCalculatorUI(math::CalculatorPtr calculator)
86 : calculator_(calculator.Pass()), 86 : calculator_(calculator.Pass()),
87 output_(0.0), 87 output_(0.0),
88 callback_(MakeRunnable(&MathCalculatorUI::Output, this)) {} 88 callback_(MakeRunnable(&MathCalculatorUI::Output, this)) {}
89 89
90 bool WaitForIncomingMethodCall() { 90 bool WaitForIncomingResponse() {
91 return calculator_.WaitForIncomingMethodCall(); 91 return calculator_.WaitForIncomingResponse();
92 } 92 }
93 93
94 bool encountered_error() const { return calculator_.encountered_error(); } 94 bool encountered_error() const { return calculator_.encountered_error(); }
95 95
96 void Add(double value) { calculator_->Add(value, callback_); } 96 void Add(double value) { calculator_->Add(value, callback_); }
97 97
98 void Subtract(double value) { calculator_->Add(-value, callback_); } 98 void Subtract(double value) { calculator_->Add(-value, callback_); }
99 99
100 void Multiply(double value) { calculator_->Multiply(value, callback_); } 100 void Multiply(double value) { calculator_->Multiply(value, callback_); }
101 101
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 MathCalculatorImpl calc_impl(GetProxy(&calc)); 225 MathCalculatorImpl calc_impl(GetProxy(&calc));
226 226
227 // Suppose this is instantiated in a process that has pipe1_. 227 // Suppose this is instantiated in a process that has pipe1_.
228 MathCalculatorUI calculator_ui(calc.Pass()); 228 MathCalculatorUI calculator_ui(calc.Pass());
229 229
230 EXPECT_EQ(0.0, calculator_ui.GetOutput()); 230 EXPECT_EQ(0.0, calculator_ui.GetOutput());
231 231
232 calculator_ui.Add(2.0); 232 calculator_ui.Add(2.0);
233 EXPECT_EQ(0.0, calculator_ui.GetOutput()); 233 EXPECT_EQ(0.0, calculator_ui.GetOutput());
234 calc_impl.WaitForIncomingMethodCall(); 234 calc_impl.WaitForIncomingMethodCall();
235 calculator_ui.WaitForIncomingMethodCall(); 235 calculator_ui.WaitForIncomingResponse();
236 EXPECT_EQ(2.0, calculator_ui.GetOutput()); 236 EXPECT_EQ(2.0, calculator_ui.GetOutput());
237 237
238 calculator_ui.Multiply(5.0); 238 calculator_ui.Multiply(5.0);
239 EXPECT_EQ(2.0, calculator_ui.GetOutput()); 239 EXPECT_EQ(2.0, calculator_ui.GetOutput());
240 calc_impl.WaitForIncomingMethodCall(); 240 calc_impl.WaitForIncomingMethodCall();
241 calculator_ui.WaitForIncomingMethodCall(); 241 calculator_ui.WaitForIncomingResponse();
242 EXPECT_EQ(10.0, calculator_ui.GetOutput()); 242 EXPECT_EQ(10.0, calculator_ui.GetOutput());
243 } 243 }
244 244
245 TEST_F(InterfacePtrTest, Movable) { 245 TEST_F(InterfacePtrTest, Movable) {
246 math::CalculatorPtr a; 246 math::CalculatorPtr a;
247 math::CalculatorPtr b; 247 math::CalculatorPtr b;
248 MathCalculatorImpl calc_impl(GetProxy(&b)); 248 MathCalculatorImpl calc_impl(GetProxy(&b));
249 249
250 EXPECT_TRUE(!a); 250 EXPECT_TRUE(!a);
251 EXPECT_FALSE(!b); 251 EXPECT_FALSE(!b);
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 } 577 }
578 578
579 loop.RunUntilIdle(); 579 loop.RunUntilIdle();
580 EXPECT_TRUE(error_received); 580 EXPECT_TRUE(error_received);
581 EXPECT_FALSE(destroyed); 581 EXPECT_FALSE(destroyed);
582 } 582 }
583 583
584 } // namespace 584 } // namespace
585 } // namespace test 585 } // namespace test
586 } // namespace mojo 586 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/interface_ptr_internal.h ('k') | mojo/public/cpp/bindings/tests/versioning_apptest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698