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/stl_converters.h" | 5 #include "mojo/public/cpp/bindings/stl_converters.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 ASSERT_FALSE(mojo_obj2[0].is_null()); | 66 ASSERT_FALSE(mojo_obj2[0].is_null()); |
67 ASSERT_EQ(1u, mojo_obj2[1].size()); | 67 ASSERT_EQ(1u, mojo_obj2[1].size()); |
68 ASSERT_EQ(2u, mojo_obj2[1]["hello"].size()); | 68 ASSERT_EQ(2u, mojo_obj2[1]["hello"].size()); |
69 ASSERT_EQ(123, mojo_obj2[1]["hello"][0]); | 69 ASSERT_EQ(123, mojo_obj2[1]["hello"][0]); |
70 ASSERT_EQ(456, mojo_obj2[1]["hello"][1]); | 70 ASSERT_EQ(456, mojo_obj2[1]["hello"][1]); |
71 } | 71 } |
72 | 72 |
73 TEST_F(STLConvertersTest, StopsAtMojoStruct) { | 73 TEST_F(STLConvertersTest, StopsAtMojoStruct) { |
74 Array<NamedRegionPtr> mojo_obj(1); | 74 Array<NamedRegionPtr> mojo_obj(1); |
75 mojo_obj[0] = NamedRegion::New(); | 75 mojo_obj[0] = NamedRegion::New(); |
76 mojo_obj[0]->name = "hello"; | 76 mojo_obj[0]->name.emplace("hello"); |
77 mojo_obj[0]->rects.resize(3); | 77 mojo_obj[0]->rects.emplace(3); |
78 | 78 |
79 std::vector<NamedRegionPtr> stl_obj = UnwrapToSTLType(std::move(mojo_obj)); | 79 std::vector<NamedRegionPtr> stl_obj = UnwrapToSTLType(std::move(mojo_obj)); |
80 | 80 |
81 ASSERT_EQ(1u, stl_obj.size()); | 81 ASSERT_EQ(1u, stl_obj.size()); |
82 ASSERT_EQ("hello", stl_obj[0]->name); | 82 ASSERT_EQ("hello", stl_obj[0]->name.value()); |
83 ASSERT_EQ(3u, stl_obj[0]->rects.size()); | 83 ASSERT_EQ(3u, stl_obj[0]->rects->size()); |
84 | 84 |
85 Array<NamedRegionPtr> mojo_obj2 = WrapSTLType(std::move(stl_obj)); | 85 Array<NamedRegionPtr> mojo_obj2 = WrapSTLType(std::move(stl_obj)); |
86 | 86 |
87 ASSERT_EQ(1u, mojo_obj2.size()); | 87 ASSERT_EQ(1u, mojo_obj2.size()); |
88 ASSERT_EQ("hello", mojo_obj2[0]->name); | 88 ASSERT_EQ("hello", mojo_obj2[0]->name.value()); |
89 ASSERT_EQ(3u, mojo_obj2[0]->rects.size()); | 89 ASSERT_EQ(3u, mojo_obj2[0]->rects->size()); |
90 } | 90 } |
91 | 91 |
92 } // namespace test | 92 } // namespace test |
93 } // namespace mojo | 93 } // namespace mojo |
OLD | NEW |