• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "mojo/public/cpp/bindings/lib/wtf_hash_util.h"
6 
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"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/blink/renderer/platform/wtf/hash_functions.h"
11 
12 namespace mojo {
13 namespace test {
14 namespace {
15 
16 using WTFHashTest = testing::Test;
17 
TEST_F(WTFHashTest,NestedStruct)18 TEST_F(WTFHashTest, NestedStruct) {
19   // Just check that this template instantiation compiles.
20   ASSERT_EQ(::mojo::internal::Hash(
21                 ::mojo::internal::kHashSeed,
22                 blink::SimpleNestedStruct::New(blink::ContainsOther::New(1))),
23             ::mojo::internal::Hash(
24                 ::mojo::internal::kHashSeed,
25                 blink::SimpleNestedStruct::New(blink::ContainsOther::New(1))));
26 }
27 
TEST_F(WTFHashTest,Enum)28 TEST_F(WTFHashTest, Enum) {
29   // Just check that this template instantiation compiles.
30 
31   // Top-level.
32   ASSERT_EQ(WTF::DefaultHash<blink::TopLevelEnum>::Hash().GetHash(
33                 blink::TopLevelEnum::E0),
34             WTF::DefaultHash<blink::TopLevelEnum>::Hash().GetHash(
35                 blink::TopLevelEnum::E0));
36 
37   // Nested in struct.
38   ASSERT_EQ(WTF::DefaultHash<blink::TestWTFStruct::NestedEnum>::Hash().GetHash(
39                 blink::TestWTFStruct::NestedEnum::E0),
40             WTF::DefaultHash<blink::TestWTFStruct::NestedEnum>::Hash().GetHash(
41                 blink::TestWTFStruct::NestedEnum::E0));
42 
43   // Nested in interface.
44   ASSERT_EQ(WTF::DefaultHash<blink::TestWTF::NestedEnum>::Hash().GetHash(
45                 blink::TestWTF::NestedEnum::E0),
46             WTF::DefaultHash<blink::TestWTF::NestedEnum>::Hash().GetHash(
47                 blink::TestWTF::NestedEnum::E0));
48 }
49 
50 }  // namespace
51 }  // namespace test
52 }  // namespace mojo
53