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 static blink::ContainsOtherPtr MakeContainsOther(uint64_t other) { | 18 static blink::ContainsOtherPtr MakeContainsOther(uint64_t other) { |
17 blink::ContainsOtherPtr ptr = blink::ContainsOther::New(); | 19 blink::ContainsOtherPtr ptr = blink::ContainsOther::New(); |
18 ptr->other = other; | 20 ptr->other = other; |
(...skipping 17 matching lines...) Expand all Loading... |
36 } | 38 } |
37 | 39 |
38 TEST_F(WTFHashTest, UnmappedNativeStruct) { | 40 TEST_F(WTFHashTest, UnmappedNativeStruct) { |
39 // Just check that this template instantiation compiles. | 41 // Just check that this template instantiation compiles. |
40 ASSERT_EQ(::mojo::internal::Hash(::mojo::internal::kHashSeed, | 42 ASSERT_EQ(::mojo::internal::Hash(::mojo::internal::kHashSeed, |
41 blink::UnmappedNativeStruct::New()), | 43 blink::UnmappedNativeStruct::New()), |
42 ::mojo::internal::Hash(::mojo::internal::kHashSeed, | 44 ::mojo::internal::Hash(::mojo::internal::kHashSeed, |
43 blink::UnmappedNativeStruct::New())); | 45 blink::UnmappedNativeStruct::New())); |
44 } | 46 } |
45 | 47 |
| 48 TEST_F(WTFHashTest, Enum) { |
| 49 // Just check that this template instantiation compiles. |
| 50 |
| 51 // Top-level. |
| 52 ASSERT_EQ(WTF::DefaultHash<blink::TopLevelEnum>::Hash().hash( |
| 53 blink::TopLevelEnum::E0), |
| 54 WTF::DefaultHash<blink::TopLevelEnum>::Hash().hash( |
| 55 blink::TopLevelEnum::E0)); |
| 56 |
| 57 // Nested in struct. |
| 58 ASSERT_EQ(WTF::DefaultHash<blink::TestWTFStruct::NestedEnum>::Hash().hash( |
| 59 blink::TestWTFStruct::NestedEnum::E0), |
| 60 WTF::DefaultHash<blink::TestWTFStruct::NestedEnum>::Hash().hash( |
| 61 blink::TestWTFStruct::NestedEnum::E0)); |
| 62 |
| 63 // Nested in interface. |
| 64 ASSERT_EQ(WTF::DefaultHash<blink::TestWTF::NestedEnum>::Hash().hash( |
| 65 blink::TestWTF::NestedEnum::E0), |
| 66 WTF::DefaultHash<blink::TestWTF::NestedEnum>::Hash().hash( |
| 67 blink::TestWTF::NestedEnum::E0)); |
| 68 } |
| 69 |
46 } // namespace | 70 } // namespace |
47 } // namespace test | 71 } // namespace test |
48 } // namespace mojo | 72 } // namespace mojo |
OLD | NEW |