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

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

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 4 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 | « mojo/public/cpp/bindings/tests/message_queue.cc ('k') | mojo/public/cpp/bindings/tests/router_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/tests/request_response_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/request_response_unittest.cc b/mojo/public/cpp/bindings/tests/request_response_unittest.cc
deleted file mode 100644
index 9034a65e79d236320b00c0f76bc066f959ae4401..0000000000000000000000000000000000000000
--- a/mojo/public/cpp/bindings/tests/request_response_unittest.cc
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "gtest/gtest.h"
-#include "mojo/public/cpp/bindings/binding.h"
-#include "mojo/public/cpp/test_support/test_utils.h"
-#include "mojo/public/cpp/utility/run_loop.h"
-#include "mojo/public/interfaces/bindings/tests/sample_import.mojom.h"
-#include "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.h"
-
-namespace mojo {
-namespace test {
-namespace {
-
-class ProviderImpl : public sample::Provider {
- public:
- explicit ProviderImpl(InterfaceRequest<sample::Provider> request)
- : binding_(this, request.Pass()) {}
-
- void EchoString(const String& a,
- const Callback<void(String)>& callback) override {
- Callback<void(String)> callback_copy;
- // Make sure operator= is used.
- callback_copy = callback;
- callback_copy.Run(a);
- }
-
- void EchoStrings(const String& a,
- const String& b,
- const Callback<void(String, String)>& callback) override {
- callback.Run(a, b);
- }
-
- void EchoMessagePipeHandle(
- ScopedMessagePipeHandle a,
- const Callback<void(ScopedMessagePipeHandle)>& callback) override {
- callback.Run(a.Pass());
- }
-
- void EchoEnum(sample::Enum a,
- const Callback<void(sample::Enum)>& callback) override {
- callback.Run(a);
- }
-
- void EchoInt(int32_t a, const EchoIntCallback& callback) override {
- callback.Run(a);
- }
-
- Binding<sample::Provider> binding_;
-};
-
-class StringRecorder {
- public:
- explicit StringRecorder(std::string* buf) : buf_(buf) {}
- void Run(const String& a) const { *buf_ = a; }
- void Run(const String& a, const String& b) const {
- *buf_ = a.get() + b.get();
- }
-
- private:
- std::string* buf_;
-};
-
-class EnumRecorder {
- public:
- explicit EnumRecorder(sample::Enum* value) : value_(value) {}
- void Run(sample::Enum a) const { *value_ = a; }
-
- private:
- sample::Enum* value_;
-};
-
-class MessagePipeWriter {
- public:
- explicit MessagePipeWriter(const char* text) : text_(text) {}
- void Run(ScopedMessagePipeHandle handle) const {
- WriteTextMessage(handle.get(), text_);
- }
-
- private:
- std::string text_;
-};
-
-class RequestResponseTest : public testing::Test {
- public:
- ~RequestResponseTest() override { loop_.RunUntilIdle(); }
-
- void PumpMessages() { loop_.RunUntilIdle(); }
-
- private:
- RunLoop loop_;
-};
-
-TEST_F(RequestResponseTest, EchoString) {
- sample::ProviderPtr provider;
- ProviderImpl provider_impl(GetProxy(&provider));
-
- std::string buf;
- provider->EchoString(String::From("hello"), StringRecorder(&buf));
-
- PumpMessages();
-
- EXPECT_EQ(std::string("hello"), buf);
-}
-
-TEST_F(RequestResponseTest, EchoStrings) {
- sample::ProviderPtr provider;
- ProviderImpl provider_impl(GetProxy(&provider));
-
- std::string buf;
- provider->EchoStrings(
- String::From("hello"), String::From(" world"), StringRecorder(&buf));
-
- PumpMessages();
-
- EXPECT_EQ(std::string("hello world"), buf);
-}
-
-TEST_F(RequestResponseTest, EchoMessagePipeHandle) {
- sample::ProviderPtr provider;
- ProviderImpl provider_impl(GetProxy(&provider));
-
- MessagePipe pipe2;
- provider->EchoMessagePipeHandle(pipe2.handle1.Pass(),
- MessagePipeWriter("hello"));
-
- PumpMessages();
-
- std::string value;
- ReadTextMessage(pipe2.handle0.get(), &value);
-
- EXPECT_EQ(std::string("hello"), value);
-}
-
-TEST_F(RequestResponseTest, EchoEnum) {
- sample::ProviderPtr provider;
- ProviderImpl provider_impl(GetProxy(&provider));
-
- sample::Enum value;
- provider->EchoEnum(sample::Enum::VALUE, EnumRecorder(&value));
-
- PumpMessages();
-
- EXPECT_EQ(sample::Enum::VALUE, value);
-}
-
-} // namespace
-} // namespace test
-} // namespace mojo
« no previous file with comments | « mojo/public/cpp/bindings/tests/message_queue.cc ('k') | mojo/public/cpp/bindings/tests/router_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698