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

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

Issue 218883013: Mojo: Move public/bindings/tests/*.cc to public/cpp/bindings/tests/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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/bindings/tests/remote_ptr_unittest.cc ('k') | mojo/public/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/bindings/tests/request_response_unittest.cc
diff --git a/mojo/public/bindings/tests/request_response_unittest.cc b/mojo/public/bindings/tests/request_response_unittest.cc
deleted file mode 100644
index 2e3edf1c8186e1da33bedc0e53ee16fe014a08d7..0000000000000000000000000000000000000000
--- a/mojo/public/bindings/tests/request_response_unittest.cc
+++ /dev/null
@@ -1,140 +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 "mojo/public/bindings/tests/sample_import.mojom.h"
-#include "mojo/public/bindings/tests/sample_interfaces.mojom.h"
-#include "mojo/public/cpp/bindings/allocation_scope.h"
-#include "mojo/public/cpp/bindings/remote_ptr.h"
-#include "mojo/public/cpp/environment/environment.h"
-#include "mojo/public/cpp/test_support/test_utils.h"
-#include "mojo/public/cpp/utility/run_loop.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace mojo {
-namespace test {
-namespace {
-
-class ProviderImpl : public sample::Provider {
- public:
- explicit ProviderImpl(sample::ScopedProviderClientHandle handle)
- : client_(handle.Pass(), this) {
- }
-
- virtual void EchoString(
- const String& a,
- const Callback<void(String)>& callback) MOJO_OVERRIDE {
- AllocationScope scope;
- callback.Run(a);
- }
-
- virtual void EchoStrings(
- const String& a,
- const String& b,
- const Callback<void(String, String)>& callback) MOJO_OVERRIDE {
- AllocationScope scope;
- callback.Run(a, b);
- }
-
- virtual void EchoMessagePipeHandle(
- ScopedMessagePipeHandle a,
- const Callback<void(ScopedMessagePipeHandle)>& callback) MOJO_OVERRIDE {
- AllocationScope scope;
- callback.Run(a.Pass());
- }
-
- private:
- RemotePtr<sample::ProviderClient> client_;
-};
-
-class StringRecorder {
- public:
- StringRecorder(std::string* buf) : buf_(buf) {
- }
- void Run(const String& a) const {
- *buf_ = a.To<std::string>();
- }
- void Run(const String& a, const String& b) const {
- *buf_ = a.To<std::string>() + b.To<std::string>();
- }
- private:
- std::string* buf_;
-};
-
-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:
- void PumpMessages() {
- loop_.RunUntilIdle();
- }
-
- private:
- Environment env_;
- RunLoop loop_;
-};
-
-TEST_F(RequestResponseTest, EchoString) {
- InterfacePipe<sample::Provider> pipe;
- ProviderImpl provider_impl(pipe.handle_to_peer.Pass());
- RemotePtr<sample::Provider> provider(pipe.handle_to_self.Pass(), NULL);
-
- std::string buf;
- {
- AllocationScope scope;
- provider->EchoString("hello", StringRecorder(&buf));
- }
-
- PumpMessages();
-
- EXPECT_EQ(std::string("hello"), buf);
-}
-
-TEST_F(RequestResponseTest, EchoStrings) {
- InterfacePipe<sample::Provider> pipe;
- ProviderImpl provider_impl(pipe.handle_to_peer.Pass());
- RemotePtr<sample::Provider> provider(pipe.handle_to_self.Pass(), NULL);
-
- std::string buf;
- {
- AllocationScope scope;
- provider->EchoStrings("hello", " world", StringRecorder(&buf));
- }
-
- PumpMessages();
-
- EXPECT_EQ(std::string("hello world"), buf);
-}
-
-TEST_F(RequestResponseTest, EchoMessagePipeHandle) {
- InterfacePipe<sample::Provider> pipe;
- ProviderImpl provider_impl(pipe.handle_to_peer.Pass());
- RemotePtr<sample::Provider> provider(pipe.handle_to_self.Pass(), NULL);
-
- MessagePipe pipe2;
- {
- AllocationScope scope;
- provider->EchoMessagePipeHandle(pipe2.handle1.Pass(),
- MessagePipeWriter("hello"));
- }
-
- PumpMessages();
-
- std::string value;
- ReadTextMessage(pipe2.handle0.get(), &value);
-
- EXPECT_EQ(std::string("hello"), value);
-}
-
-} // namespace
-} // namespace test
-} // namespace mojo
« no previous file with comments | « mojo/public/bindings/tests/remote_ptr_unittest.cc ('k') | mojo/public/bindings/tests/router_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698