Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: mojo/public/cpp/bindings/tests/sample_service_unittest.cc

Issue 209453003: Add support for mojo::TypeConverter to control how convenient conversion should be. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <algorithm> 5 #include <algorithm>
6 #include <ostream> 6 #include <ostream>
7 #include <string> 7 #include <string>
8 8
9 #include "mojo/public/cpp/bindings/allocation_scope.h" 9 #include "mojo/public/cpp/bindings/allocation_scope.h"
10 #include "mojo/public/cpp/environment/environment.h" 10 #include "mojo/public/cpp/environment/environment.h"
11 #include "mojo/public/interfaces/bindings/tests/sample_service.mojom.h" 11 #include "mojo/public/interfaces/bindings/tests/sample_service.mojom.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace mojo { 14 namespace mojo {
15 15
16 template <> 16 template <>
17 class TypeConverter<sample::Bar, int32_t> { 17 class TypeConverter<sample::Bar, int32_t> {
18 public: 18 public:
19 static int32_t ConvertTo(const sample::Bar& bar) { 19 static int32_t ConvertTo(const sample::Bar& bar) {
20 return static_cast<int32_t>(bar.alpha()) << 16 | 20 return static_cast<int32_t>(bar.alpha()) << 16 |
21 static_cast<int32_t>(bar.beta()) << 8 | 21 static_cast<int32_t>(bar.beta()) << 8 |
22 static_cast<int32_t>(bar.gamma()); 22 static_cast<int32_t>(bar.gamma());
23 } 23 }
24
25 MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION();
24 }; 26 };
25 27
26 } // namespace mojo 28 } // namespace mojo
27 29
28 namespace sample { 30 namespace sample {
29 namespace { 31 namespace {
30 32
31 // Set this variable to true to print the message in hex. 33 // Set this variable to true to print the message in hex.
32 bool g_dump_message_as_hex = false; 34 bool g_dump_message_as_hex = false;
33 35
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 348
347 EXPECT_EQ(1u, full.shape_masks().size()); 349 EXPECT_EQ(1u, full.shape_masks().size());
348 EXPECT_EQ(1 << imported::SHAPE_RECTANGLE, full.shape_masks()[0]); 350 EXPECT_EQ(1 << imported::SHAPE_RECTANGLE, full.shape_masks()[0]);
349 351
350 EXPECT_EQ(imported::SHAPE_CIRCLE, full.thing().shape()); 352 EXPECT_EQ(imported::SHAPE_CIRCLE, full.thing().shape());
351 EXPECT_EQ(imported::COLOR_BLACK, full.thing().color()); 353 EXPECT_EQ(imported::COLOR_BLACK, full.thing().color());
352 } 354 }
353 355
354 } // namespace 356 } // namespace
355 } // namespace sample 357 } // namespace sample
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/array.h ('k') | mojo/public/cpp/bindings/tests/type_conversion_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698