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 "mojo/public/cpp/bindings/lib/wtf_hash_util.h" | 5 #include "mojo/public/cpp/bindings/lib/wtf_hash_util.h" |
6 | 6 |
7 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom-blink.h" | 7 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom-blink.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace mojo { | 10 namespace mojo { |
11 namespace test { | 11 namespace test { |
12 namespace { | 12 namespace { |
13 | 13 |
14 using WTFHashTest = testing::Test; | 14 using WTFHashTest = testing::Test; |
15 | 15 |
16 static blink::ContainsOtherPtr MakeContainsOther(uint64_t other) { | |
17 blink::ContainsOtherPtr ptr = blink::ContainsOther::New(); | |
18 ptr->other = other; | |
19 return ptr; | |
20 } | |
21 | |
22 static blink::SimpleNestedStructPtr MakeSimpleNestedStruct( | |
23 blink::ContainsOtherPtr nested) { | |
24 blink::SimpleNestedStructPtr ptr = blink::SimpleNestedStruct::New(); | |
25 ptr->nested = std::move(nested); | |
26 return ptr; | |
27 } | |
28 | |
29 TEST_F(WTFHashTest, NestedStruct) { | 16 TEST_F(WTFHashTest, NestedStruct) { |
30 // Just check that this template instantiation compiles. | 17 // Just check that this template instantiation compiles. |
31 ASSERT_EQ( | 18 ASSERT_EQ(::mojo::internal::Hash( |
32 ::mojo::internal::Hash(::mojo::internal::kHashSeed, | 19 ::mojo::internal::kHashSeed, |
33 MakeSimpleNestedStruct(MakeContainsOther(1))), | 20 blink::SimpleNestedStruct::New(blink::ContainsOther::New(1))), |
34 ::mojo::internal::Hash(::mojo::internal::kHashSeed, | 21 ::mojo::internal::Hash( |
35 MakeSimpleNestedStruct(MakeContainsOther(1)))); | 22 ::mojo::internal::kHashSeed, |
| 23 blink::SimpleNestedStruct::New(blink::ContainsOther::New(1)))); |
36 } | 24 } |
37 | 25 |
38 TEST_F(WTFHashTest, UnmappedNativeStruct) { | 26 TEST_F(WTFHashTest, UnmappedNativeStruct) { |
39 // Just check that this template instantiation compiles. | 27 // Just check that this template instantiation compiles. |
40 ASSERT_EQ(::mojo::internal::Hash(::mojo::internal::kHashSeed, | 28 ASSERT_EQ(::mojo::internal::Hash(::mojo::internal::kHashSeed, |
41 blink::UnmappedNativeStruct::New()), | 29 blink::UnmappedNativeStruct::New()), |
42 ::mojo::internal::Hash(::mojo::internal::kHashSeed, | 30 ::mojo::internal::Hash(::mojo::internal::kHashSeed, |
43 blink::UnmappedNativeStruct::New())); | 31 blink::UnmappedNativeStruct::New())); |
44 } | 32 } |
45 | 33 |
46 } // namespace | 34 } // namespace |
47 } // namespace test | 35 } // namespace test |
48 } // namespace mojo | 36 } // namespace mojo |
OLD | NEW |