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 "mojo/public/interfaces/bindings/tests/test_wtf_types.mojom-blink.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "third_party/WebKit/Source/wtf/HashFunctions.h" |
9 | 11 |
10 namespace mojo { | 12 namespace mojo { |
11 namespace test { | 13 namespace test { |
12 namespace { | 14 namespace { |
13 | 15 |
14 using WTFHashTest = testing::Test; | 16 using WTFHashTest = testing::Test; |
15 | 17 |
16 TEST_F(WTFHashTest, NestedStruct) { | 18 TEST_F(WTFHashTest, NestedStruct) { |
17 // Just check that this template instantiation compiles. | 19 // Just check that this template instantiation compiles. |
18 ASSERT_EQ(::mojo::internal::Hash( | 20 ASSERT_EQ(::mojo::internal::Hash( |
19 ::mojo::internal::kHashSeed, | 21 ::mojo::internal::kHashSeed, |
20 blink::SimpleNestedStruct::New(blink::ContainsOther::New(1))), | 22 blink::SimpleNestedStruct::New(blink::ContainsOther::New(1))), |
21 ::mojo::internal::Hash( | 23 ::mojo::internal::Hash( |
22 ::mojo::internal::kHashSeed, | 24 ::mojo::internal::kHashSeed, |
23 blink::SimpleNestedStruct::New(blink::ContainsOther::New(1)))); | 25 blink::SimpleNestedStruct::New(blink::ContainsOther::New(1)))); |
24 } | 26 } |
25 | 27 |
26 TEST_F(WTFHashTest, UnmappedNativeStruct) { | 28 TEST_F(WTFHashTest, UnmappedNativeStruct) { |
27 // Just check that this template instantiation compiles. | 29 // Just check that this template instantiation compiles. |
28 ASSERT_EQ(::mojo::internal::Hash(::mojo::internal::kHashSeed, | 30 ASSERT_EQ(::mojo::internal::Hash(::mojo::internal::kHashSeed, |
29 blink::UnmappedNativeStruct::New()), | 31 blink::UnmappedNativeStruct::New()), |
30 ::mojo::internal::Hash(::mojo::internal::kHashSeed, | 32 ::mojo::internal::Hash(::mojo::internal::kHashSeed, |
31 blink::UnmappedNativeStruct::New())); | 33 blink::UnmappedNativeStruct::New())); |
32 } | 34 } |
33 | 35 |
| 36 TEST_F(WTFHashTest, Enum) { |
| 37 // Just check that this template instantiation compiles. |
| 38 |
| 39 // Top-level. |
| 40 ASSERT_EQ(WTF::DefaultHash<blink::TopLevelEnum>::Hash().hash( |
| 41 blink::TopLevelEnum::E0), |
| 42 WTF::DefaultHash<blink::TopLevelEnum>::Hash().hash( |
| 43 blink::TopLevelEnum::E0)); |
| 44 |
| 45 // Nested in struct. |
| 46 ASSERT_EQ(WTF::DefaultHash<blink::TestWTFStruct::NestedEnum>::Hash().hash( |
| 47 blink::TestWTFStruct::NestedEnum::E0), |
| 48 WTF::DefaultHash<blink::TestWTFStruct::NestedEnum>::Hash().hash( |
| 49 blink::TestWTFStruct::NestedEnum::E0)); |
| 50 |
| 51 // Nested in interface. |
| 52 ASSERT_EQ(WTF::DefaultHash<blink::TestWTF::NestedEnum>::Hash().hash( |
| 53 blink::TestWTF::NestedEnum::E0), |
| 54 WTF::DefaultHash<blink::TestWTF::NestedEnum>::Hash().hash( |
| 55 blink::TestWTF::NestedEnum::E0)); |
| 56 } |
| 57 |
34 } // namespace | 58 } // namespace |
35 } // namespace test | 59 } // namespace test |
36 } // namespace mojo | 60 } // namespace mojo |
OLD | NEW |