| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
| 6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/numerics/safe_math.h" | 9 #include "base/numerics/safe_math.h" |
| 10 #include "base/process/process_handle.h" | |
| 11 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/values.h" | 12 #include "base/values.h" |
| 14 #include "mojo/common/common_custom_types_struct_traits.h" | |
| 15 #include "mojo/common/process_id.mojom.h" | |
| 16 #include "mojo/common/test_common_custom_types.mojom.h" | 13 #include "mojo/common/test_common_custom_types.mojom.h" |
| 17 #include "mojo/public/cpp/bindings/binding.h" | 14 #include "mojo/public/cpp/bindings/binding.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 16 |
| 20 namespace mojo { | 17 namespace mojo { |
| 21 namespace common { | 18 namespace common { |
| 22 namespace test { | 19 namespace test { |
| 23 namespace { | 20 namespace { |
| 24 | 21 |
| 25 template <typename T> | 22 template <typename T> |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 TestUnguessableTokenPtr ptr; | 219 TestUnguessableTokenPtr ptr; |
| 223 TestUnguessableTokenImpl impl(MakeRequest(&ptr)); | 220 TestUnguessableTokenImpl impl(MakeRequest(&ptr)); |
| 224 | 221 |
| 225 base::UnguessableToken token = base::UnguessableToken::Create(); | 222 base::UnguessableToken token = base::UnguessableToken::Create(); |
| 226 | 223 |
| 227 ptr->BounceNonce(token, ExpectResponse(&token, run_loop.QuitClosure())); | 224 ptr->BounceNonce(token, ExpectResponse(&token, run_loop.QuitClosure())); |
| 228 | 225 |
| 229 run_loop.Run(); | 226 run_loop.Run(); |
| 230 } | 227 } |
| 231 | 228 |
| 232 TEST_F(CommonCustomTypesTest, ProcessId) { | |
| 233 base::ProcessId pid = base::GetCurrentProcId(); | |
| 234 base::ProcessId out_pid = base::kNullProcessId; | |
| 235 ASSERT_NE(pid, out_pid); | |
| 236 EXPECT_TRUE(mojom::ProcessId::Deserialize(mojom::ProcessId::Serialize(&pid), | |
| 237 &out_pid)); | |
| 238 EXPECT_EQ(pid, out_pid); | |
| 239 } | |
| 240 | |
| 241 TEST_F(CommonCustomTypesTest, Time) { | 229 TEST_F(CommonCustomTypesTest, Time) { |
| 242 base::RunLoop run_loop; | 230 base::RunLoop run_loop; |
| 243 | 231 |
| 244 TestTimePtr ptr; | 232 TestTimePtr ptr; |
| 245 TestTimeImpl impl(MakeRequest(&ptr)); | 233 TestTimeImpl impl(MakeRequest(&ptr)); |
| 246 | 234 |
| 247 base::Time t = base::Time::Now(); | 235 base::Time t = base::Time::Now(); |
| 248 | 236 |
| 249 ptr->BounceTime(t, ExpectResponse(&t, run_loop.QuitClosure())); | 237 ptr->BounceTime(t, ExpectResponse(&t, run_loop.QuitClosure())); |
| 250 | 238 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 for (size_t i = 0; i < arraysize(kTestDirections); i++) { | 423 for (size_t i = 0; i < arraysize(kTestDirections); i++) { |
| 436 base::i18n::TextDirection direction_out; | 424 base::i18n::TextDirection direction_out; |
| 437 ASSERT_TRUE(ptr->BounceTextDirection(kTestDirections[i], &direction_out)); | 425 ASSERT_TRUE(ptr->BounceTextDirection(kTestDirections[i], &direction_out)); |
| 438 EXPECT_EQ(kTestDirections[i], direction_out); | 426 EXPECT_EQ(kTestDirections[i], direction_out); |
| 439 } | 427 } |
| 440 } | 428 } |
| 441 | 429 |
| 442 } // namespace test | 430 } // namespace test |
| 443 } // namespace common | 431 } // namespace common |
| 444 } // namespace mojo | 432 } // namespace mojo |
| OLD | NEW |