Index: mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc |
diff --git a/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc b/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc |
index aff625116863453f96ab36e88f1ed968336703bb..b64719e179b01693c3c5c1787618819f07f17704 100644 |
--- a/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc |
+++ b/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc |
@@ -78,6 +78,8 @@ class MathCalculatorUI { |
double GetOutput() const { return output_; } |
+ math::CalculatorPtr& GetInterfacePtr() { return calculator_; } |
+ |
private: |
void Output(const base::Closure& closure, double output) { |
output_ = output; |
@@ -735,6 +737,42 @@ TEST_F(InterfacePtrTest, Fusion) { |
EXPECT_TRUE(called); |
} |
+void Fail() { |
+ FAIL() << "Unexpected connection error"; |
+} |
+ |
+TEST_F(InterfacePtrTest, FlushForTesting) { |
+ math::CalculatorPtr calc; |
+ MathCalculatorImpl calc_impl(GetProxy(&calc)); |
+ calc.set_connection_error_handler(base::Bind(&Fail)); |
+ |
+ // Suppose this is instantiated in a process that has pipe1_. |
yzshen1
2016/08/31 17:06:47
I guess this is an outdated comment (here and else
Sam McNally
2016/09/01 00:44:37
Done.
|
+ MathCalculatorUI calculator_ui(std::move(calc)); |
+ |
+ calculator_ui.Add(2.0, base::Bind(&base::DoNothing)); |
+ calculator_ui.GetInterfacePtr().FlushForTesting(); |
+ EXPECT_EQ(2.0, calculator_ui.GetOutput()); |
+ |
+ calculator_ui.Multiply(5.0, base::Bind(&base::DoNothing)); |
+ calculator_ui.GetInterfacePtr().FlushForTesting(); |
+ |
+ EXPECT_EQ(10.0, calculator_ui.GetOutput()); |
+} |
+ |
+void SetBool(bool* value) { |
+ *value = true; |
+} |
+ |
+TEST_F(InterfacePtrTest, FlushForTestingWithClosedPeer) { |
+ math::CalculatorPtr calc; |
+ GetProxy(&calc); |
+ bool called = false; |
+ calc.set_connection_error_handler(base::Bind(&SetBool, &called)); |
+ calc.FlushForTesting(); |
+ EXPECT_TRUE(called); |
+ calc.FlushForTesting(); |
+} |
+ |
} // namespace |
} // namespace test |
} // namespace mojo |