| OLD | NEW |
| 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 package org.chromium.mojo.bindings; | 5 package org.chromium.mojo.bindings; |
| 6 | 6 |
| 7 import android.test.suitebuilder.annotation.SmallTest; | 7 import android.test.suitebuilder.annotation.SmallTest; |
| 8 import android.util.Log; | 8 import android.util.Log; |
| 9 | 9 |
| 10 import org.chromium.base.test.util.UrlUtils; | 10 import org.chromium.base.test.util.UrlUtils; |
| 11 import org.chromium.mojo.HandleMock; |
| 11 import org.chromium.mojo.MojoTestCase; | 12 import org.chromium.mojo.MojoTestCase; |
| 12 import org.chromium.mojo.bindings.test.mojom.mojo.ConformanceTestInterface; | 13 import org.chromium.mojo.bindings.test.mojom.mojo.ConformanceTestInterface; |
| 13 import org.chromium.mojo.bindings.test.mojom.mojo.IntegrationTestInterface1; | 14 import org.chromium.mojo.bindings.test.mojom.mojo.IntegrationTestInterface1; |
| 14 import org.chromium.mojo.bindings.test.mojom.mojo.IntegrationTestInterface2TestH
elper; | 15 import org.chromium.mojo.bindings.test.mojom.mojo.IntegrationTestInterface2TestH
elper; |
| 15 import org.chromium.mojo.system.Handle; | 16 import org.chromium.mojo.system.Handle; |
| 16 import org.chromium.mojo.system.InvalidHandle; | |
| 17 | 17 |
| 18 import java.io.File; | 18 import java.io.File; |
| 19 import java.io.FileFilter; | 19 import java.io.FileFilter; |
| 20 import java.io.FileNotFoundException; | 20 import java.io.FileNotFoundException; |
| 21 import java.util.ArrayList; | 21 import java.util.ArrayList; |
| 22 import java.util.List; | 22 import java.util.List; |
| 23 import java.util.Scanner; | 23 import java.util.Scanner; |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * Testing validation upon deserialization using the interfaces defined in the | 26 * Testing validation upon deserialization using the interfaces defined in the |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 /** | 93 /** |
| 94 * Runs all the test with the given prefix on the given {@link MessageReceiv
er}. | 94 * Runs all the test with the given prefix on the given {@link MessageReceiv
er}. |
| 95 */ | 95 */ |
| 96 private static void runTest(String prefix, MessageReceiver messageReceiver) | 96 private static void runTest(String prefix, MessageReceiver messageReceiver) |
| 97 throws FileNotFoundException { | 97 throws FileNotFoundException { |
| 98 List<TestData> testData = getTestData(prefix); | 98 List<TestData> testData = getTestData(prefix); |
| 99 for (TestData test : testData) { | 99 for (TestData test : testData) { |
| 100 assertNull(test.inputData.getErrorMessage()); | 100 assertNull(test.inputData.getErrorMessage()); |
| 101 List<Handle> handles = new ArrayList<Handle>(); | 101 List<Handle> handles = new ArrayList<Handle>(); |
| 102 for (int i = 0; i < test.inputData.getHandlesCount(); ++i) { | 102 for (int i = 0; i < test.inputData.getHandlesCount(); ++i) { |
| 103 handles.add(InvalidHandle.INSTANCE); | 103 handles.add(new HandleMock()); |
| 104 } | 104 } |
| 105 Message message = new SimpleMessage(test.inputData.getData(), handle
s); | 105 Message message = new SimpleMessage(test.inputData.getData(), handle
s); |
| 106 boolean passed = messageReceiver.accept(message); | 106 boolean passed = messageReceiver.accept(message); |
| 107 if (passed && !test.expectedResult.equals("PASS")) { | 107 if (passed && !test.expectedResult.equals("PASS")) { |
| 108 fail("Input: " + test.dataFile.getName() + | 108 fail("Input: " + test.dataFile.getName() + |
| 109 ": The message should have been refused. Expected error:
" + | 109 ": The message should have been refused. Expected error:
" + |
| 110 test.expectedResult); | 110 test.expectedResult); |
| 111 } | 111 } |
| 112 if (!passed && test.expectedResult.equals("PASS")) { | 112 if (!passed && test.expectedResult.equals("PASS")) { |
| 113 fail("Input: " + test.dataFile.getName() + | 113 fail("Input: " + test.dataFile.getName() + |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 @Override | 168 @Override |
| 169 public boolean acceptWithResponder(Message message, MessageReceiver resp
onder) { | 169 public boolean acceptWithResponder(Message message, MessageReceiver resp
onder) { |
| 170 return false; | 170 return false; |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 /** | 174 /** |
| 175 * Testing the conformance suite. | 175 * Testing the conformance suite. |
| 176 */ | 176 */ |
| 177 @SmallTest | 177 @SmallTest |
| 178 public void DisabledTestConformance() throws FileNotFoundException { | 178 public void testConformance() throws FileNotFoundException { |
| 179 runTest("conformance_", ConformanceTestInterface.MANAGER.buildStub(null, | 179 runTest("conformance_", ConformanceTestInterface.MANAGER.buildStub(null, |
| 180 ConformanceTestInterface.MANAGER.buildProxy(null, new SinkMessag
eReceiver()))); | 180 ConformanceTestInterface.MANAGER.buildProxy(null, new SinkMessag
eReceiver()))); |
| 181 } | 181 } |
| 182 | 182 |
| 183 /** | 183 /** |
| 184 * Testing the integration suite. | 184 * Testing the integration suite. |
| 185 */ | 185 */ |
| 186 @SmallTest | 186 @SmallTest |
| 187 public void DisabledTestIntegration() throws FileNotFoundException { | 187 public void testIntegration() throws FileNotFoundException { |
| 188 runTest("integration_", | 188 runTest("integration_", |
| 189 new RoutingMessageReceiver(IntegrationTestInterface1.MANAGER.bui
ldStub(null, | 189 new RoutingMessageReceiver(IntegrationTestInterface1.MANAGER.bui
ldStub(null, |
| 190 IntegrationTestInterface1.MANAGER.buildProxy(null, | 190 IntegrationTestInterface1.MANAGER.buildProxy(null, |
| 191 new SinkMessageReceiver())), | 191 new SinkMessageReceiver())), |
| 192 IntegrationTestInterface2TestHelper. | 192 IntegrationTestInterface2TestHelper. |
| 193 newIntegrationTestInterface2MethodCallback())); | 193 newIntegrationTestInterface2MethodCallback())); |
| 194 } | 194 } |
| 195 } | 195 } |
| OLD | NEW |