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

Side by Side Diff: mojo/android/javatests/src/org/chromium/mojo/TestUtils.java

Issue 371603003: Adding a router class to handle messages that expect responses. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix findbugs issue Created 6 years, 5 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 package org.chromium.mojo; 5 package org.chromium.mojo;
6 6
7 import java.nio.ByteBuffer; 7 import java.nio.ByteBuffer;
8 import java.nio.ByteOrder;
8 import java.util.Random; 9 import java.util.Random;
9 10
10 /** 11 /**
11 * Utilities methods for tests. 12 * Utilities methods for tests.
12 */ 13 */
13 public final class TestUtils { 14 public final class TestUtils {
14 15
15 private static final Random RANDOM = new Random(); 16 private static final Random RANDOM = new Random();
16 17
17 /** 18 /**
18 * Returns a new direct ByteBuffer of the given size with random (but reprod ucible) data. 19 * Returns a new direct ByteBuffer of the given size with random (but reprod ucible) data.
19 */ 20 */
20 public static ByteBuffer newRandomBuffer(int size) { 21 public static ByteBuffer newRandomBuffer(int size) {
21 byte bytes[] = new byte[size]; 22 byte bytes[] = new byte[size];
22 RANDOM.setSeed(size); 23 RANDOM.setSeed(size);
23 RANDOM.nextBytes(bytes); 24 RANDOM.nextBytes(bytes);
24 ByteBuffer data = ByteBuffer.allocateDirect(size); 25 ByteBuffer data = ByteBuffer.allocateDirect(size);
26 data.order(ByteOrder.nativeOrder());
25 data.put(bytes); 27 data.put(bytes);
26 data.flip(); 28 data.flip();
27 return data; 29 return data;
28 } 30 }
29 31
30 } 32 }
OLDNEW
« no previous file with comments | « build/android/lint/suppressions.xml ('k') | mojo/android/javatests/src/org/chromium/mojo/bindings/BindingsTestUtils.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698