summaryrefslogtreecommitdiff
path: root/mojo/public/interfaces/bindings/tests/struct_with_traits.mojom
blob: b50409ee88f37e31b54175fdf460cf1050bad277 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module mojo.test;

// TODO(yzshen): Rename *WithTraits* types to something more readable.

struct NestedStructWithTraits {
  int32 value;
};

enum EnumWithTraits {
  VALUE_0,
  VALUE_1
};

struct StructWithTraits {
  EnumWithTraits f_enum;
  bool f_bool;
  uint32 f_uint32;
  uint64 f_uint64;
  string f_string;
  string f_string2;
  array<string> f_string_array;
  array<string> f_string_set;
  NestedStructWithTraits f_struct;
  array<NestedStructWithTraits> f_struct_array;
  map<string, NestedStructWithTraits> f_struct_map;
};

// Test that this container can be cloned.
struct StructWithTraitsContainer {
  StructWithTraits f_struct;
};

// Maps to a pass-by-value trivial struct.
struct TrivialStructWithTraits {
  int32 value;
};

// Maps to a move-only struct.
struct MoveOnlyStructWithTraits {
  handle f_handle;
};

// The custom type for MoveOnlyStructWithTraits is not clonable. Test that
// this container can compile as long as Clone() is not used.
struct MoveOnlyStructWithTraitsContainer {
  MoveOnlyStructWithTraits f_struct;
};

struct StructWithTraitsForUniquePtr {
  int32 f_int32;
};

union UnionWithTraits {
  int32 f_int32;
  NestedStructWithTraits f_struct;
};

interface TraitsTestService {
  EchoStructWithTraits(StructWithTraits s) => (StructWithTraits passed);

  EchoTrivialStructWithTraits(TrivialStructWithTraits s) =>
      (TrivialStructWithTraits passed);

  EchoMoveOnlyStructWithTraits(MoveOnlyStructWithTraits s) =>
      (MoveOnlyStructWithTraits passed);

  EchoNullableMoveOnlyStructWithTraits(MoveOnlyStructWithTraits? s) =>
      (MoveOnlyStructWithTraits? passed);

  EchoEnumWithTraits(EnumWithTraits e) => (EnumWithTraits passed);

  EchoStructWithTraitsForUniquePtr(StructWithTraitsForUniquePtr e) => (
      StructWithTraitsForUniquePtr passed);

  EchoNullableStructWithTraitsForUniquePtr(StructWithTraitsForUniquePtr? e) => (
      StructWithTraitsForUniquePtr? passed);

  EchoUnionWithTraits(UnionWithTraits u) => (UnionWithTraits passed);
};