| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h" | 8 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 template <> | 44 template <> |
| 45 struct TypeConverter<test::RectPtr, RedmondRect> { | 45 struct TypeConverter<test::RectPtr, RedmondRect> { |
| 46 static test::RectPtr Convert(const RedmondRect& input) { | 46 static test::RectPtr Convert(const RedmondRect& input) { |
| 47 test::RectPtr rect(test::Rect::New()); | 47 test::RectPtr rect(test::Rect::New()); |
| 48 rect->x = input.left; | 48 rect->x = input.left; |
| 49 rect->y = input.top; | 49 rect->y = input.top; |
| 50 rect->width = input.right - input.left; | 50 rect->width = input.right - input.left; |
| 51 rect->height = input.bottom - input.top; | 51 rect->height = input.bottom - input.top; |
| 52 return rect.Pass(); | 52 return rect; |
| 53 } | 53 } |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 template <> | 56 template <> |
| 57 struct TypeConverter<RedmondRect, test::RectPtr> { | 57 struct TypeConverter<RedmondRect, test::RectPtr> { |
| 58 static RedmondRect Convert(const test::RectPtr& input) { | 58 static RedmondRect Convert(const test::RectPtr& input) { |
| 59 RedmondRect rect; | 59 RedmondRect rect; |
| 60 rect.left = input->x; | 60 rect.left = input->x; |
| 61 rect.top = input->y; | 61 rect.top = input->y; |
| 62 rect.right = input->x + input->width; | 62 rect.right = input->x + input->width; |
| 63 rect.bottom = input->y + input->height; | 63 rect.bottom = input->y + input->height; |
| 64 return rect; | 64 return rect; |
| 65 } | 65 } |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 template <> | 68 template <> |
| 69 struct TypeConverter<test::NamedRegionPtr, RedmondNamedRegion> { | 69 struct TypeConverter<test::NamedRegionPtr, RedmondNamedRegion> { |
| 70 static test::NamedRegionPtr Convert(const RedmondNamedRegion& input) { | 70 static test::NamedRegionPtr Convert(const RedmondNamedRegion& input) { |
| 71 test::NamedRegionPtr region(test::NamedRegion::New()); | 71 test::NamedRegionPtr region(test::NamedRegion::New()); |
| 72 region->name = input.name; | 72 region->name = input.name; |
| 73 region->rects = Array<test::RectPtr>::From(input.rects); | 73 region->rects = Array<test::RectPtr>::From(input.rects); |
| 74 return region.Pass(); | 74 return region; |
| 75 } | 75 } |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 template <> | 78 template <> |
| 79 struct TypeConverter<RedmondNamedRegion, test::NamedRegionPtr> { | 79 struct TypeConverter<RedmondNamedRegion, test::NamedRegionPtr> { |
| 80 static RedmondNamedRegion Convert(const test::NamedRegionPtr& input) { | 80 static RedmondNamedRegion Convert(const test::NamedRegionPtr& input) { |
| 81 RedmondNamedRegion region; | 81 RedmondNamedRegion region; |
| 82 region.name = input->name; | 82 region.name = input->name; |
| 83 region.rects = input->rects.To<std::vector<RedmondRect>>(); | 83 region.rects = input->rects.To<std::vector<RedmondRect>>(); |
| 84 return region; | 84 return region; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 EXPECT_EQ(redmond_region.rects[i].left, redmond_region2.rects[i].left); | 198 EXPECT_EQ(redmond_region.rects[i].left, redmond_region2.rects[i].left); |
| 199 EXPECT_EQ(redmond_region.rects[i].top, redmond_region2.rects[i].top); | 199 EXPECT_EQ(redmond_region.rects[i].top, redmond_region2.rects[i].top); |
| 200 EXPECT_EQ(redmond_region.rects[i].right, redmond_region2.rects[i].right); | 200 EXPECT_EQ(redmond_region.rects[i].right, redmond_region2.rects[i].right); |
| 201 EXPECT_EQ(redmond_region.rects[i].bottom, redmond_region2.rects[i].bottom); | 201 EXPECT_EQ(redmond_region.rects[i].bottom, redmond_region2.rects[i].bottom); |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 | 204 |
| 205 } // namespace | 205 } // namespace |
| 206 } // namespace test | 206 } // namespace test |
| 207 } // namespace mojo | 207 } // namespace mojo |
| OLD | NEW |