1 // Copyright 2017 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/tests/rect_blink.h"
6 #include "mojo/public/interfaces/bindings/tests/rect.mojom-blink.h"
7 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom-blink.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace mojo {
11 namespace test {
12 namespace {
13
TEST(WTFMapTest,StructKey)14 TEST(WTFMapTest, StructKey) {
15 WTF::HashMap<blink::RectPtr, int32_t> map;
16 map.insert(blink::Rect::New(1, 2, 3, 4), 123);
17
18 blink::RectPtr key = blink::Rect::New(1, 2, 3, 4);
19 ASSERT_NE(map.end(), map.find(key));
20 ASSERT_EQ(123, map.find(key)->value);
21
22 map.erase(key);
23 ASSERT_EQ(0u, map.size());
24 }
25
TEST(WTFMapTest,TypemappedStructKey)26 TEST(WTFMapTest, TypemappedStructKey) {
27 WTF::HashMap<blink::ContainsHashablePtr, int32_t> map;
28 map.insert(blink::ContainsHashable::New(RectBlink(1, 2, 3, 4)), 123);
29
30 blink::ContainsHashablePtr key =
31 blink::ContainsHashable::New(RectBlink(1, 2, 3, 4));
32 ASSERT_NE(map.end(), map.find(key));
33 ASSERT_EQ(123, map.find(key)->value);
34
35 map.erase(key);
36 ASSERT_EQ(0u, map.size());
37 }
38
39 } // namespace
40 } // namespace test
41 } // namespace mojo
42