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

Side by Side Diff: mojo/edk/system/core_unittest.cc

Issue 782693004: Update mojo sdk to rev f6c8ec07c01deebc13178d516225fd12695c3dc2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: hack mojo_system_impl gypi for android :| 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/core.h" 5 #include "mojo/edk/system/core.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 EXPECT_EQ(0u, info.GetBeginReadDataCallCount()); 88 EXPECT_EQ(0u, info.GetBeginReadDataCallCount());
89 EXPECT_EQ(MOJO_RESULT_UNIMPLEMENTED, 89 EXPECT_EQ(MOJO_RESULT_UNIMPLEMENTED,
90 core()->BeginReadData(h, NullUserPointer(), NullUserPointer(), 90 core()->BeginReadData(h, NullUserPointer(), NullUserPointer(),
91 MOJO_READ_DATA_FLAG_NONE)); 91 MOJO_READ_DATA_FLAG_NONE));
92 EXPECT_EQ(1u, info.GetBeginReadDataCallCount()); 92 EXPECT_EQ(1u, info.GetBeginReadDataCallCount());
93 93
94 EXPECT_EQ(0u, info.GetEndReadDataCallCount()); 94 EXPECT_EQ(0u, info.GetEndReadDataCallCount());
95 EXPECT_EQ(MOJO_RESULT_UNIMPLEMENTED, core()->EndReadData(h, 0)); 95 EXPECT_EQ(MOJO_RESULT_UNIMPLEMENTED, core()->EndReadData(h, 0));
96 EXPECT_EQ(1u, info.GetEndReadDataCallCount()); 96 EXPECT_EQ(1u, info.GetEndReadDataCallCount());
97 97
98 EXPECT_EQ(0u, info.GetAddWaiterCallCount()); 98 EXPECT_EQ(0u, info.GetAddAwakableCallCount());
99 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, 99 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
100 core()->Wait(h, ~MOJO_HANDLE_SIGNAL_NONE, MOJO_DEADLINE_INDEFINITE, 100 core()->Wait(h, ~MOJO_HANDLE_SIGNAL_NONE, MOJO_DEADLINE_INDEFINITE,
101 NullUserPointer())); 101 NullUserPointer()));
102 EXPECT_EQ(1u, info.GetAddWaiterCallCount()); 102 EXPECT_EQ(1u, info.GetAddAwakableCallCount());
103 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, 103 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
104 core()->Wait(h, ~MOJO_HANDLE_SIGNAL_NONE, 0, NullUserPointer())); 104 core()->Wait(h, ~MOJO_HANDLE_SIGNAL_NONE, 0, NullUserPointer()));
105 EXPECT_EQ(2u, info.GetAddWaiterCallCount()); 105 EXPECT_EQ(2u, info.GetAddAwakableCallCount());
106 MojoHandleSignalsState hss = kFullMojoHandleSignalsState; 106 MojoHandleSignalsState hss = kFullMojoHandleSignalsState;
107 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, 107 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
108 core()->Wait(h, ~MOJO_HANDLE_SIGNAL_NONE, MOJO_DEADLINE_INDEFINITE, 108 core()->Wait(h, ~MOJO_HANDLE_SIGNAL_NONE, MOJO_DEADLINE_INDEFINITE,
109 MakeUserPointer(&hss))); 109 MakeUserPointer(&hss)));
110 EXPECT_EQ(3u, info.GetAddWaiterCallCount()); 110 EXPECT_EQ(3u, info.GetAddAwakableCallCount());
111 EXPECT_EQ(0u, hss.satisfied_signals); 111 EXPECT_EQ(0u, hss.satisfied_signals);
112 EXPECT_EQ(0u, hss.satisfiable_signals); 112 EXPECT_EQ(0u, hss.satisfiable_signals);
113 EXPECT_EQ( 113 EXPECT_EQ(
114 MOJO_RESULT_FAILED_PRECONDITION, 114 MOJO_RESULT_FAILED_PRECONDITION,
115 core()->Wait(h, ~MOJO_HANDLE_SIGNAL_NONE, 10 * 1000, NullUserPointer())); 115 core()->Wait(h, ~MOJO_HANDLE_SIGNAL_NONE, 10 * 1000, NullUserPointer()));
116 EXPECT_EQ(4u, info.GetAddWaiterCallCount()); 116 EXPECT_EQ(4u, info.GetAddAwakableCallCount());
117 hss = kFullMojoHandleSignalsState; 117 hss = kFullMojoHandleSignalsState;
118 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, 118 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
119 core()->Wait(h, ~MOJO_HANDLE_SIGNAL_NONE, 10 * 1000, 119 core()->Wait(h, ~MOJO_HANDLE_SIGNAL_NONE, 10 * 1000,
120 MakeUserPointer(&hss))); 120 MakeUserPointer(&hss)));
121 EXPECT_EQ(5u, info.GetAddWaiterCallCount()); 121 EXPECT_EQ(5u, info.GetAddAwakableCallCount());
122 EXPECT_EQ(0u, hss.satisfied_signals); 122 EXPECT_EQ(0u, hss.satisfied_signals);
123 EXPECT_EQ(0u, hss.satisfiable_signals); 123 EXPECT_EQ(0u, hss.satisfiable_signals);
124 124
125 MojoHandleSignals handle_signals = ~MOJO_HANDLE_SIGNAL_NONE; 125 MojoHandleSignals handle_signals = ~MOJO_HANDLE_SIGNAL_NONE;
126 EXPECT_EQ( 126 EXPECT_EQ(
127 MOJO_RESULT_FAILED_PRECONDITION, 127 MOJO_RESULT_FAILED_PRECONDITION,
128 core()->WaitMany(MakeUserPointer(&h), MakeUserPointer(&handle_signals), 1, 128 core()->WaitMany(MakeUserPointer(&h), MakeUserPointer(&handle_signals), 1,
129 MOJO_DEADLINE_INDEFINITE, NullUserPointer(), 129 MOJO_DEADLINE_INDEFINITE, NullUserPointer(),
130 NullUserPointer())); 130 NullUserPointer()));
131 EXPECT_EQ(6u, info.GetAddWaiterCallCount()); 131 EXPECT_EQ(6u, info.GetAddAwakableCallCount());
132 uint32_t result_index = static_cast<uint32_t>(-1); 132 uint32_t result_index = static_cast<uint32_t>(-1);
133 EXPECT_EQ( 133 EXPECT_EQ(
134 MOJO_RESULT_FAILED_PRECONDITION, 134 MOJO_RESULT_FAILED_PRECONDITION,
135 core()->WaitMany(MakeUserPointer(&h), MakeUserPointer(&handle_signals), 1, 135 core()->WaitMany(MakeUserPointer(&h), MakeUserPointer(&handle_signals), 1,
136 MOJO_DEADLINE_INDEFINITE, MakeUserPointer(&result_index), 136 MOJO_DEADLINE_INDEFINITE, MakeUserPointer(&result_index),
137 NullUserPointer())); 137 NullUserPointer()));
138 EXPECT_EQ(7u, info.GetAddWaiterCallCount()); 138 EXPECT_EQ(7u, info.GetAddAwakableCallCount());
139 EXPECT_EQ(0u, result_index); 139 EXPECT_EQ(0u, result_index);
140 hss = kFullMojoHandleSignalsState; 140 hss = kFullMojoHandleSignalsState;
141 EXPECT_EQ( 141 EXPECT_EQ(
142 MOJO_RESULT_FAILED_PRECONDITION, 142 MOJO_RESULT_FAILED_PRECONDITION,
143 core()->WaitMany(MakeUserPointer(&h), MakeUserPointer(&handle_signals), 1, 143 core()->WaitMany(MakeUserPointer(&h), MakeUserPointer(&handle_signals), 1,
144 MOJO_DEADLINE_INDEFINITE, NullUserPointer(), 144 MOJO_DEADLINE_INDEFINITE, NullUserPointer(),
145 MakeUserPointer(&hss))); 145 MakeUserPointer(&hss)));
146 EXPECT_EQ(8u, info.GetAddWaiterCallCount()); 146 EXPECT_EQ(8u, info.GetAddAwakableCallCount());
147 EXPECT_EQ(0u, hss.satisfied_signals); 147 EXPECT_EQ(0u, hss.satisfied_signals);
148 EXPECT_EQ(0u, hss.satisfiable_signals); 148 EXPECT_EQ(0u, hss.satisfiable_signals);
149 result_index = static_cast<uint32_t>(-1); 149 result_index = static_cast<uint32_t>(-1);
150 hss = kFullMojoHandleSignalsState; 150 hss = kFullMojoHandleSignalsState;
151 EXPECT_EQ( 151 EXPECT_EQ(
152 MOJO_RESULT_FAILED_PRECONDITION, 152 MOJO_RESULT_FAILED_PRECONDITION,
153 core()->WaitMany(MakeUserPointer(&h), MakeUserPointer(&handle_signals), 1, 153 core()->WaitMany(MakeUserPointer(&h), MakeUserPointer(&handle_signals), 1,
154 MOJO_DEADLINE_INDEFINITE, MakeUserPointer(&result_index), 154 MOJO_DEADLINE_INDEFINITE, MakeUserPointer(&result_index),
155 MakeUserPointer(&hss))); 155 MakeUserPointer(&hss)));
156 EXPECT_EQ(9u, info.GetAddWaiterCallCount()); 156 EXPECT_EQ(9u, info.GetAddAwakableCallCount());
157 EXPECT_EQ(0u, result_index); 157 EXPECT_EQ(0u, result_index);
158 EXPECT_EQ(0u, hss.satisfied_signals); 158 EXPECT_EQ(0u, hss.satisfied_signals);
159 EXPECT_EQ(0u, hss.satisfiable_signals); 159 EXPECT_EQ(0u, hss.satisfiable_signals);
160 160
161 EXPECT_EQ(0u, info.GetDtorCallCount()); 161 EXPECT_EQ(0u, info.GetDtorCallCount());
162 EXPECT_EQ(0u, info.GetCloseCallCount()); 162 EXPECT_EQ(0u, info.GetCloseCallCount());
163 EXPECT_EQ(0u, info.GetCancelAllWaitersCallCount()); 163 EXPECT_EQ(0u, info.GetCancelAllAwakablesCallCount());
164 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h)); 164 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h));
165 EXPECT_EQ(1u, info.GetCancelAllWaitersCallCount()); 165 EXPECT_EQ(1u, info.GetCancelAllAwakablesCallCount());
166 EXPECT_EQ(1u, info.GetCloseCallCount()); 166 EXPECT_EQ(1u, info.GetCloseCallCount());
167 EXPECT_EQ(1u, info.GetDtorCallCount()); 167 EXPECT_EQ(1u, info.GetDtorCallCount());
168 168
169 // No waiters should ever have ever been added. 169 // No awakables should ever have ever been added.
170 EXPECT_EQ(0u, info.GetRemoveWaiterCallCount()); 170 EXPECT_EQ(0u, info.GetRemoveAwakableCallCount());
171 } 171 }
172 172
173 TEST_F(CoreTest, InvalidArguments) { 173 TEST_F(CoreTest, InvalidArguments) {
174 // |Close()|: 174 // |Close()|:
175 { 175 {
176 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, core()->Close(MOJO_HANDLE_INVALID)); 176 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, core()->Close(MOJO_HANDLE_INVALID));
177 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, core()->Close(10)); 177 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, core()->Close(10));
178 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, core()->Close(1000000000)); 178 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, core()->Close(1000000000));
179 179
180 // Test a double-close. 180 // Test a double-close.
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h_passing[1])); 1274 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h_passing[1]));
1275 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(ph)); 1275 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(ph));
1276 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(ch)); 1276 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(ch));
1277 } 1277 }
1278 1278
1279 // TODO(vtl): Test |DuplicateBufferHandle()| and |MapBuffer()|. 1279 // TODO(vtl): Test |DuplicateBufferHandle()| and |MapBuffer()|.
1280 1280
1281 } // namespace 1281 } // namespace
1282 } // namespace system 1282 } // namespace system
1283 } // namespace mojo 1283 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698