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

Unified Diff: mojo/public/cpp/bindings/tests/handle_passing_unittest.cc

Issue 376383002: Mojo: Add support for InterfacePtr as a struct member (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: retry Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mojo/public/interfaces/bindings/tests/sample_factory.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/tests/handle_passing_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/handle_passing_unittest.cc b/mojo/public/cpp/bindings/tests/handle_passing_unittest.cc
index 99eddf83410615547d2b3be19a7f8437fb4cf792..ab2e47506cc4d7192398be09df6da1bca38022e7 100644
--- a/mojo/public/cpp/bindings/tests/handle_passing_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/handle_passing_unittest.cc
@@ -26,6 +26,24 @@ class StringRecorder {
std::string* buf_;
};
+class ImportedInterfaceImpl
+ : public InterfaceImpl<imported::ImportedInterface> {
+ public:
+ virtual void OnConnectionError() MOJO_OVERRIDE {
+ delete this;
+ }
+
+ virtual void DoSomething() MOJO_OVERRIDE {
+ do_something_count_++;
+ }
+
+ static int do_something_count() { return do_something_count_; }
+
+ private:
+ static int do_something_count_;
+};
+int ImportedInterfaceImpl::do_something_count_ = 0;
+
class SampleNamedObjectImpl : public InterfaceImpl<sample::NamedObject> {
public:
virtual void OnConnectionError() MOJO_OVERRIDE {
@@ -75,6 +93,9 @@ class SampleFactoryImpl : public InterfaceImpl<sample::Factory> {
response->x = 2;
response->pipe = pipe0.Pass();
client()->DidStuff(response.Pass(), text1);
+
+ if (request->obj.get())
+ request->obj->DoSomething();
}
virtual void DoStuff2(ScopedDataPipeConsumerHandle pipe) MOJO_OVERRIDE {
@@ -194,16 +215,22 @@ TEST_F(HandlePassingTest, Basic) {
MessagePipe pipe1;
EXPECT_TRUE(WriteTextMessage(pipe1.handle1.get(), kText2));
+ imported::ImportedInterfacePtr imported;
+ BindToProxy(new ImportedInterfaceImpl(), &imported);
+
sample::RequestPtr request(sample::Request::New());
request->x = 1;
request->pipe = pipe1.handle0.Pass();
+ request->obj = imported.Pass();
factory->DoStuff(request.Pass(), pipe0.handle0.Pass());
EXPECT_FALSE(factory_client.got_response());
+ int count_before = ImportedInterfaceImpl::do_something_count();
PumpMessages();
EXPECT_TRUE(factory_client.got_response());
+ EXPECT_EQ(1, ImportedInterfaceImpl::do_something_count() - count_before);
}
TEST_F(HandlePassingTest, PassInvalid) {
« no previous file with comments | « no previous file | mojo/public/interfaces/bindings/tests/sample_factory.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698