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

Unified Diff: mojo/edk/system/awakable_list_unittest.cc

Issue 799113004: Update mojo sdk to rev 59145288bae55b0fce4276b017df6a1117bcf00f (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add mojo's ply to checklicenses whitelist Created 6 years 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/edk/system/awakable_list.cc ('k') | mojo/edk/system/channel.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/awakable_list_unittest.cc
diff --git a/mojo/edk/system/awakable_list_unittest.cc b/mojo/edk/system/awakable_list_unittest.cc
index 201b7519246d603e62c35927eec2e593470fb53f..0ef6a7a0a09f3e423b4177ec201260bbbded7dac 100644
--- a/mojo/edk/system/awakable_list_unittest.cc
+++ b/mojo/edk/system/awakable_list_unittest.cc
@@ -284,6 +284,75 @@ TEST(AwakableListTest, MultipleAwakables) {
EXPECT_EQ(10u, context4);
}
+class KeepAwakable : public Awakable {
+ public:
+ KeepAwakable() : awake_count(0) {}
+
+ bool Awake(MojoResult result, uintptr_t context) override {
+ awake_count++;
+ return true;
+ }
+
+ int awake_count;
+
+ DISALLOW_COPY_AND_ASSIGN(KeepAwakable);
+};
+
+class RemoveAwakable : public Awakable {
+ public:
+ RemoveAwakable() : awake_count(0) {}
+
+ bool Awake(MojoResult result, uintptr_t context) override {
+ awake_count++;
+ return false;
+ }
+
+ int awake_count;
+
+ DISALLOW_COPY_AND_ASSIGN(RemoveAwakable);
+};
+
+TEST(AwakableListTest, KeepAwakablesReturningTrue) {
+ KeepAwakable keep0;
+ KeepAwakable keep1;
+ RemoveAwakable remove0;
+ RemoveAwakable remove1;
+ RemoveAwakable remove2;
+
+ HandleSignalsState hss(MOJO_HANDLE_SIGNAL_WRITABLE,
+ MOJO_HANDLE_SIGNAL_WRITABLE);
+
+ AwakableList remove_all;
+ remove_all.Add(&remove0, MOJO_HANDLE_SIGNAL_WRITABLE, 0);
+ remove_all.Add(&remove1, MOJO_HANDLE_SIGNAL_WRITABLE, 0);
+
+ remove_all.AwakeForStateChange(hss);
+ EXPECT_EQ(remove0.awake_count, 1);
+ EXPECT_EQ(remove1.awake_count, 1);
+
+ remove_all.AwakeForStateChange(hss);
+ EXPECT_EQ(remove0.awake_count, 1);
+ EXPECT_EQ(remove1.awake_count, 1);
+
+ AwakableList remove_first;
+ remove_first.Add(&remove2, MOJO_HANDLE_SIGNAL_WRITABLE, 0);
+ remove_first.Add(&keep0, MOJO_HANDLE_SIGNAL_WRITABLE, 0);
+ remove_first.Add(&keep1, MOJO_HANDLE_SIGNAL_WRITABLE, 0);
+
+ remove_first.AwakeForStateChange(hss);
+ EXPECT_EQ(keep0.awake_count, 1);
+ EXPECT_EQ(keep1.awake_count, 1);
+ EXPECT_EQ(remove2.awake_count, 1);
+
+ remove_first.AwakeForStateChange(hss);
+ EXPECT_EQ(keep0.awake_count, 2);
+ EXPECT_EQ(keep1.awake_count, 2);
+ EXPECT_EQ(remove2.awake_count, 1);
+
+ remove_first.Remove(&keep0);
+ remove_first.Remove(&keep1);
+}
+
} // namespace
} // namespace system
} // namespace mojo
« no previous file with comments | « mojo/edk/system/awakable_list.cc ('k') | mojo/edk/system/channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698