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

Unified Diff: mojo/common/handle_watcher_unittest.cc

Issue 282823003: Mojo: cancel pending AsyncWait calls when the callers thread exits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: env first Created 6 years, 7 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/common/handle_watcher.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/common/handle_watcher_unittest.cc
diff --git a/mojo/common/handle_watcher_unittest.cc b/mojo/common/handle_watcher_unittest.cc
index 5cc8cfa82079f94c7402b5c95bbd3071e69c7658..37fde23ef05b2c63a7a42b590535491caf083a3d 100644
--- a/mojo/common/handle_watcher_unittest.cc
+++ b/mojo/common/handle_watcher_unittest.cc
@@ -20,6 +20,13 @@ namespace mojo {
namespace common {
namespace test {
+void ObserveCallback(bool* was_signaled,
+ MojoResult* result_observed,
+ MojoResult result) {
+ *was_signaled = true;
+ *result_observed = result;
+}
+
void RunUntilIdle() {
base::RunLoop run_loop;
run_loop.RunUntilIdle();
@@ -101,14 +108,6 @@ class HandleWatcherTest : public testing::Test {
test::SetTickClockForTest(NULL);
}
- virtual void SetUp() OVERRIDE {
- environment_.reset(new Environment);
- }
-
- virtual void TearDown() OVERRIDE {
- environment_.reset();
- }
-
protected:
void InstallTickClock() {
test::SetTickClockForTest(&tick_clock_);
@@ -117,8 +116,8 @@ class HandleWatcherTest : public testing::Test {
base::SimpleTestTickClock tick_clock_;
private:
+ Environment environment_;
base::MessageLoop message_loop_;
- scoped_ptr<Environment> environment_;
DISALLOW_COPY_AND_ASSIGN(HandleWatcherTest);
};
@@ -315,6 +314,29 @@ TEST_F(HandleWatcherTest, DeleteInCallback) {
EXPECT_TRUE(callback_helper.got_callback());
}
+TEST(HandleWatcherCleanEnvironmentTest, AbortedOnMessageLoopDestruction) {
+ bool was_signaled = false;
+ MojoResult result = MOJO_RESULT_OK;
+
+ Environment env;
+
+ MessagePipe pipe;
+ HandleWatcher watcher;
+ {
+ base::MessageLoop loop;
+
+ watcher.Start(pipe.handle0.get(),
+ MOJO_WAIT_FLAG_READABLE,
+ MOJO_DEADLINE_INDEFINITE,
+ base::Bind(&ObserveCallback, &was_signaled, &result));
+
+ // Now, let the MessageLoop get torn down. We expect our callback to run.
+ }
+
+ EXPECT_TRUE(was_signaled);
+ EXPECT_EQ(MOJO_RESULT_ABORTED, result);
+}
+
} // namespace test
} // namespace common
} // namespace mojo
« no previous file with comments | « mojo/common/handle_watcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698