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

Unified Diff: mojo/message_pump/message_pump_mojo_unittest.cc

Issue 1280463003: Revert of Straightens outs DEPS in mojo/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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/message_pump/message_pump_mojo_handler.h ('k') | mojo/message_pump/time_helper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/message_pump/message_pump_mojo_unittest.cc
diff --git a/mojo/message_pump/message_pump_mojo_unittest.cc b/mojo/message_pump/message_pump_mojo_unittest.cc
deleted file mode 100644
index 51f3670c513d94730309de832cb1feb0e9a4f88b..0000000000000000000000000000000000000000
--- a/mojo/message_pump/message_pump_mojo_unittest.cc
+++ /dev/null
@@ -1,124 +0,0 @@
-// Copyright 2013 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/message_pump/message_pump_mojo.h"
-
-#include "base/message_loop/message_loop_test.h"
-#include "base/run_loop.h"
-#include "mojo/message_pump/message_pump_mojo_handler.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/mojo/src/mojo/public/cpp/system/core.h"
-
-namespace mojo {
-namespace common {
-namespace test {
-
-scoped_ptr<base::MessagePump> CreateMojoMessagePump() {
- return scoped_ptr<base::MessagePump>(new MessagePumpMojo());
-}
-
-RUN_MESSAGE_LOOP_TESTS(Mojo, &CreateMojoMessagePump);
-
-class CountingMojoHandler : public MessagePumpMojoHandler {
- public:
- CountingMojoHandler() : success_count_(0), error_count_(0) {}
-
- void OnHandleReady(const Handle& handle) override {
- ReadMessageRaw(static_cast<const MessagePipeHandle&>(handle),
- NULL,
- NULL,
- NULL,
- NULL,
- MOJO_READ_MESSAGE_FLAG_NONE);
- ++success_count_;
- }
- void OnHandleError(const Handle& handle, MojoResult result) override {
- ++error_count_;
- }
-
- int success_count() { return success_count_; }
- int error_count() { return error_count_; }
-
- private:
- int success_count_;
- int error_count_;
-
- DISALLOW_COPY_AND_ASSIGN(CountingMojoHandler);
-};
-
-class CountingObserver : public MessagePumpMojo::Observer {
- public:
- void WillSignalHandler() override { will_signal_handler_count++; }
- void DidSignalHandler() override { did_signal_handler_count++; }
-
- int will_signal_handler_count = 0;
- int did_signal_handler_count = 0;
-};
-
-TEST(MessagePumpMojo, RunUntilIdle) {
- base::MessageLoop message_loop(MessagePumpMojo::Create());
- CountingMojoHandler handler;
- MessagePipe handles;
- MessagePumpMojo::current()->AddHandler(&handler,
- handles.handle0.get(),
- MOJO_HANDLE_SIGNAL_READABLE,
- base::TimeTicks());
- WriteMessageRaw(
- handles.handle1.get(), NULL, 0, NULL, 0, MOJO_WRITE_MESSAGE_FLAG_NONE);
- WriteMessageRaw(
- handles.handle1.get(), NULL, 0, NULL, 0, MOJO_WRITE_MESSAGE_FLAG_NONE);
- base::RunLoop run_loop;
- run_loop.RunUntilIdle();
- EXPECT_EQ(2, handler.success_count());
-}
-
-TEST(MessagePumpMojo, Observer) {
- base::MessageLoop message_loop(MessagePumpMojo::Create());
-
- CountingObserver observer;
- MessagePumpMojo::current()->AddObserver(&observer);
-
- CountingMojoHandler handler;
- MessagePipe handles;
- MessagePumpMojo::current()->AddHandler(&handler,
- handles.handle0.get(),
- MOJO_HANDLE_SIGNAL_READABLE,
- base::TimeTicks());
- WriteMessageRaw(
- handles.handle1.get(), NULL, 0, NULL, 0, MOJO_WRITE_MESSAGE_FLAG_NONE);
- base::RunLoop run_loop;
- run_loop.RunUntilIdle();
- EXPECT_EQ(1, handler.success_count());
- EXPECT_EQ(1, observer.will_signal_handler_count);
- EXPECT_EQ(1, observer.did_signal_handler_count);
- MessagePumpMojo::current()->RemoveObserver(&observer);
-
- WriteMessageRaw(
- handles.handle1.get(), NULL, 0, NULL, 0, MOJO_WRITE_MESSAGE_FLAG_NONE);
- base::RunLoop run_loop2;
- run_loop2.RunUntilIdle();
- EXPECT_EQ(2, handler.success_count());
- EXPECT_EQ(1, observer.will_signal_handler_count);
- EXPECT_EQ(1, observer.did_signal_handler_count);
-}
-
-TEST(MessagePumpMojo, UnregisterAfterDeadline) {
- base::MessageLoop message_loop(MessagePumpMojo::Create());
- CountingMojoHandler handler;
- MessagePipe handles;
- MessagePumpMojo::current()->AddHandler(
- &handler,
- handles.handle0.get(),
- MOJO_HANDLE_SIGNAL_READABLE,
- base::TimeTicks::Now() - base::TimeDelta::FromSeconds(1));
- for (int i = 0; i < 2; ++i) {
- base::RunLoop run_loop;
- run_loop.RunUntilIdle();
- }
- EXPECT_EQ(1, handler.error_count());
-}
-
-} // namespace test
-} // namespace common
-} // namespace mojo
« no previous file with comments | « mojo/message_pump/message_pump_mojo_handler.h ('k') | mojo/message_pump/time_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698