Home | History | Annotate | Download | only in tests
      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
      3 // found in the LICENSE file.
      4 
      5 import "sample_import.mojom"
      6 import "sample_import2.mojom"
      7 
      8 [JavaPackage="org.chromium.mojo.bindings.test.sample"]
      9 module sample {
     10 
     11 const uint8 kTwelve = 12;
     12 
     13 struct Bar {
     14   enum Type {
     15     TYPE_VERTICAL = 1,
     16     TYPE_HORIZONTAL,
     17     TYPE_BOTH,
     18     TYPE_INVALID
     19   };
     20   uint8 alpha@0 = 0xff;
     21   uint8 beta@1;
     22   uint8 gamma@2;
     23   Type type@3 = sample.Bar.TYPE_VERTICAL;
     24 };
     25 
     26 [RequiredFields=7]
     27 struct Foo {
     28   const string kFooby = "Fooby";
     29   string name@8 = kFooby;
     30   int32 x@0;
     31   int32 y@1;
     32   bool a@2 = true;
     33   bool b@3;
     34   bool c@4;
     35   Bar bar@5;
     36   Bar[] extra_bars@7;
     37   uint8[] data@6;
     38   handle<message_pipe> source@9;
     39   handle<data_pipe_consumer>[] input_streams@10;
     40   handle<data_pipe_producer>[] output_streams@11;
     41   bool[][] array_of_array_of_bools@12;
     42   string[][][] multi_array_of_strings@13;
     43 };
     44 
     45 struct DefaultsTest {
     46   int8 a0@0 = -12;
     47   uint8 a1@1 = sample.kTwelve;
     48   int16 a2@2 = 1234;
     49   uint16 a3@3 = 34567;
     50   int32 a4@4 = 123456;
     51   // TODO(vtl): crbug.com/375522
     52   uint32 a5@5 /* = 3456789012 */;
     53   int64 a6@6 = 111111111111;
     54   // TODO(vtl): crbug.com/375522
     55   uint64 a7@7 /* = 9999999999999999999 */;
     56   int32 a8@8 = 0x12345;
     57   int32 a9@9 = -0x12345;
     58   int32 a10@10 = +1234;
     59   bool a11@11 = true;
     60   bool a12@12 = false;
     61   float a13@13 = 123.25;
     62   double a14@14 = 1234567890.123;
     63   double a15@15 = 1E10;
     64   double a16@16 = -1.2E+20;
     65   double a17@17 = +1.23E-20;
     66 
     67   // TODO(vtl): Add tests for default vs null when those are implemented (for
     68   // structs, arrays, and strings).
     69   uint8[] a18@18;
     70   string a19@19;
     71 
     72   Bar.Type a20@20 = Bar.TYPE_BOTH;
     73   imported.Point a21@21;
     74   imported.Thing a22@22 = default;
     75 };
     76 
     77 struct StructWithHoleV1 {
     78   int32 v1 = 1;
     79   int64 v2 = 2;
     80 };
     81 
     82 struct StructWithHoleV2 {
     83   int32 v1 = 1;
     84   int64 v2 = 2;
     85   int32 v3 = 3;
     86 };
     87 
     88 [Client=ServiceClient]
     89 interface Service {
     90   enum BazOptions {
     91     BAZ_REGULAR = 0,
     92     BAZ_EXTRA
     93   };
     94   const uint8 kFavoriteBaz = 1;
     95   Frobinate@0(Foo foo@0, BazOptions baz@1, Port port@2);
     96   GetPort@1(Port& port @0);
     97 };
     98 
     99 interface ServiceClient {
    100   DidFrobinate@0(int32 result@0);
    101 };
    102 
    103 // This interface is referenced above where it is defined. It also refers to
    104 // itself from a method.
    105 interface Port {
    106   PostMessage@0(string message_text@0, Port port@1);
    107 };
    108 
    109 }
    110