OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/edk/system/wait_set_dispatcher.h" | 5 #include "mojo/edk/system/wait_set_dispatcher.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "mojo/edk/embedder/embedder_internal.h" | 14 #include "mojo/edk/embedder/embedder_internal.h" |
15 #include "mojo/edk/system/core.h" | 15 #include "mojo/edk/system/core.h" |
16 #include "mojo/edk/system/message_pipe_dispatcher.h" | 16 #include "mojo/edk/system/message_pipe_dispatcher.h" |
| 17 #include "mojo/edk/system/request_context.h" |
17 #include "mojo/edk/system/test_utils.h" | 18 #include "mojo/edk/system/test_utils.h" |
18 #include "mojo/edk/system/waiter.h" | 19 #include "mojo/edk/system/waiter.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 | 21 |
21 namespace mojo { | 22 namespace mojo { |
22 namespace edk { | 23 namespace edk { |
23 namespace { | 24 namespace { |
24 | 25 |
25 class WaitSetDispatcherTest : public ::testing::Test { | 26 class WaitSetDispatcherTest : public ::testing::Test { |
26 public: | 27 public: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 72 |
72 void CloseOnShutdown(const scoped_refptr<Dispatcher>& dispatcher) { | 73 void CloseOnShutdown(const scoped_refptr<Dispatcher>& dispatcher) { |
73 dispatchers_to_close_.push_back(dispatcher); | 74 dispatchers_to_close_.push_back(dispatcher); |
74 } | 75 } |
75 | 76 |
76 protected: | 77 protected: |
77 scoped_refptr<MessagePipeDispatcher> dispatcher0_; | 78 scoped_refptr<MessagePipeDispatcher> dispatcher0_; |
78 scoped_refptr<MessagePipeDispatcher> dispatcher1_; | 79 scoped_refptr<MessagePipeDispatcher> dispatcher1_; |
79 | 80 |
80 private: | 81 private: |
| 82 // We keep an active RequestContext for the duration of each test. It's unused |
| 83 // since these tests don't rely on the MojoWatch API. |
| 84 const RequestContext request_context_; |
| 85 |
81 static uint64_t pipe_id_generator_; | 86 static uint64_t pipe_id_generator_; |
82 DispatcherVector dispatchers_to_close_; | 87 DispatcherVector dispatchers_to_close_; |
83 | 88 |
84 DISALLOW_COPY_AND_ASSIGN(WaitSetDispatcherTest); | 89 DISALLOW_COPY_AND_ASSIGN(WaitSetDispatcherTest); |
85 }; | 90 }; |
86 | 91 |
87 // static | 92 // static |
88 uint64_t WaitSetDispatcherTest::pipe_id_generator_ = 1; | 93 uint64_t WaitSetDispatcherTest::pipe_id_generator_ = 1; |
89 | 94 |
90 TEST_F(WaitSetDispatcherTest, Basic) { | 95 TEST_F(WaitSetDispatcherTest, Basic) { |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 EXPECT_EQ(MOJO_RESULT_OK, | 462 EXPECT_EQ(MOJO_RESULT_OK, |
458 GetOneReadyDispatcher(wait_set, &woken_dispatcher, nullptr)); | 463 GetOneReadyDispatcher(wait_set, &woken_dispatcher, nullptr)); |
459 EXPECT_EQ(nested_wait_set, woken_dispatcher); | 464 EXPECT_EQ(nested_wait_set, woken_dispatcher); |
460 | 465 |
461 wait_set->RemoveAwakable(&w, nullptr); | 466 wait_set->RemoveAwakable(&w, nullptr); |
462 } | 467 } |
463 | 468 |
464 } // namespace | 469 } // namespace |
465 } // namespace edk | 470 } // namespace edk |
466 } // namespace mojo | 471 } // namespace mojo |
OLD | NEW |