OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/application/application_impl.h" | 5 #include "mojo/public/cpp/application/application_impl.h" |
6 #include "mojo/public/cpp/application/application_test_base.h" | 6 #include "mojo/public/cpp/application/application_test_base.h" |
7 #include "mojo/public/cpp/system/macros.h" | 7 #include "mojo/public/cpp/system/macros.h" |
8 #include "mojo/public/interfaces/bindings/tests/versioning_test_client.mojom.h" | 8 #include "mojo/public/interfaces/bindings/tests/versioning_test_client.mojom.h" |
9 | 9 |
10 namespace mojo { | 10 namespace mojo { |
(...skipping 19 matching lines...) Expand all Loading... |
30 private: | 30 private: |
31 MOJO_DISALLOW_COPY_AND_ASSIGN(VersioningApplicationTest); | 31 MOJO_DISALLOW_COPY_AND_ASSIGN(VersioningApplicationTest); |
32 }; | 32 }; |
33 | 33 |
34 TEST_F(VersioningApplicationTest, Struct) { | 34 TEST_F(VersioningApplicationTest, Struct) { |
35 // The service side uses a newer version of Employee defintion. | 35 // The service side uses a newer version of Employee defintion. |
36 // The returned struct should be truncated. | 36 // The returned struct should be truncated. |
37 EmployeePtr employee(Employee::New()); | 37 EmployeePtr employee(Employee::New()); |
38 employee->employee_id = 1; | 38 employee->employee_id = 1; |
39 employee->name = "Homer Simpson"; | 39 employee->name = "Homer Simpson"; |
40 employee->department = DEPARTMENT_DEV; | 40 employee->department = Department::DEV; |
41 | 41 |
42 database_->QueryEmployee(1, true, | 42 database_->QueryEmployee(1, true, |
43 [&employee](EmployeePtr returned_employee, | 43 [&employee](EmployeePtr returned_employee, |
44 Array<uint8_t> returned_finger_print) { | 44 Array<uint8_t> returned_finger_print) { |
45 EXPECT_TRUE(employee->Equals(*returned_employee)); | 45 EXPECT_TRUE(employee->Equals(*returned_employee)); |
46 EXPECT_FALSE(returned_finger_print.is_null()); | 46 EXPECT_FALSE(returned_finger_print.is_null()); |
47 }); | 47 }); |
48 database_.WaitForIncomingResponse(); | 48 database_.WaitForIncomingResponse(); |
49 | 49 |
50 // Passing a struct of older version to the service side works. | 50 // Passing a struct of older version to the service side works. |
51 EmployeePtr new_employee(Employee::New()); | 51 EmployeePtr new_employee(Employee::New()); |
52 new_employee->employee_id = 2; | 52 new_employee->employee_id = 2; |
53 new_employee->name = "Marge Simpson"; | 53 new_employee->name = "Marge Simpson"; |
54 new_employee->department = DEPARTMENT_SALES; | 54 new_employee->department = Department::SALES; |
55 | 55 |
56 database_->AddEmployee(new_employee.Clone(), | 56 database_->AddEmployee(new_employee.Clone(), |
57 [](bool success) { EXPECT_TRUE(success); }); | 57 [](bool success) { EXPECT_TRUE(success); }); |
58 database_.WaitForIncomingResponse(); | 58 database_.WaitForIncomingResponse(); |
59 | 59 |
60 database_->QueryEmployee( | 60 database_->QueryEmployee( |
61 2, false, [&new_employee](EmployeePtr returned_employee, | 61 2, false, [&new_employee](EmployeePtr returned_employee, |
62 Array<uint8_t> returned_finger_print) { | 62 Array<uint8_t> returned_finger_print) { |
63 EXPECT_TRUE(new_employee->Equals(*returned_employee)); | 63 EXPECT_TRUE(new_employee->Equals(*returned_employee)); |
64 EXPECT_TRUE(returned_finger_print.is_null()); | 64 EXPECT_TRUE(returned_finger_print.is_null()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // Calling a version 2 method (which the service side doesn't support) closes | 112 // Calling a version 2 method (which the service side doesn't support) closes |
113 // the pipe. | 113 // the pipe. |
114 database_->ListEmployeeIds([](Array<uint64_t> ids) { EXPECT_TRUE(false); }); | 114 database_->ListEmployeeIds([](Array<uint64_t> ids) { EXPECT_TRUE(false); }); |
115 database_.WaitForIncomingResponse(); | 115 database_.WaitForIncomingResponse(); |
116 EXPECT_TRUE(database_.encountered_error()); | 116 EXPECT_TRUE(database_.encountered_error()); |
117 } | 117 } |
118 | 118 |
119 } // namespace versioning | 119 } // namespace versioning |
120 } // namespace examples | 120 } // namespace examples |
121 } // namespace mojo | 121 } // namespace mojo |
OLD | NEW |