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

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

Issue 2583933003: Replace deprecated Android java test annotations (Closed)
Patch Set: Rebase again :( Created 3 years, 12 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
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.bindings; 5 package org.chromium.mojo.bindings;
6 6
7 import android.test.suitebuilder.annotation.SmallTest; 7 import android.support.test.filters.SmallTest;
8 8
9 import junit.framework.TestCase; 9 import junit.framework.TestCase;
10 10
11 import java.nio.charset.Charset; 11 import java.nio.charset.Charset;
12 12
13 /** 13 /**
14 * Testing {@link BindingsHelper}. 14 * Testing {@link BindingsHelper}.
15 */ 15 */
16 public class BindingsHelperTest extends TestCase { 16 public class BindingsHelperTest extends TestCase {
17 17
18 /** 18 /**
19 * Testing {@link BindingsHelper#utf8StringSizeInBytes(String)}. 19 * Testing {@link BindingsHelper#utf8StringSizeInBytes(String)}.
20 */ 20 */
21 @SmallTest 21 @SmallTest
22 public void testUTF8StringLength() { 22 public void testUTF8StringLength() {
23 String[] stringsToTest = { 23 String[] stringsToTest = {
24 "", 24 "",
25 "a", 25 "a",
26 "hello world", 26 "hello world",
27 "éléphant", 27 "éléphant",
28 "𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕", 28 "𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕",
29 "你午饭想吃什么", 29 "你午饭想吃什么",
30 "你午饭想吃什么\0éléphant", 30 "你午饭想吃什么\0éléphant",
31 }; 31 };
32 for (String s : stringsToTest) { 32 for (String s : stringsToTest) {
33 assertEquals(s.getBytes(Charset.forName("utf8")).length, 33 assertEquals(s.getBytes(Charset.forName("utf8")).length,
34 BindingsHelper.utf8StringSizeInBytes(s)); 34 BindingsHelper.utf8StringSizeInBytes(s));
35 } 35 }
36 assertEquals(1, BindingsHelper.utf8StringSizeInBytes("\0")); 36 assertEquals(1, BindingsHelper.utf8StringSizeInBytes("\0"));
37 String s = new StringBuilder().appendCodePoint(0x0).appendCodePoint(0x80 ). 37 String s = new StringBuilder().appendCodePoint(0x0).appendCodePoint(0x80 )
38 appendCodePoint(0x800).appendCodePoint(0x10000).toString(); 38 .appendCodePoint(0x800).appendCodePoint(0x10000).toString();
39 assertEquals(10, BindingsHelper.utf8StringSizeInBytes(s)); 39 assertEquals(10, BindingsHelper.utf8StringSizeInBytes(s));
40 assertEquals(10, s.getBytes(Charset.forName("utf8")).length); 40 assertEquals(10, s.getBytes(Charset.forName("utf8")).length);
41 } 41 }
42 42
43 /** 43 /**
44 * Testing {@link BindingsHelper#align(int)}. 44 * Testing {@link BindingsHelper#align(int)}.
45 */ 45 */
46 @SmallTest 46 @SmallTest
47 public void testAlign() { 47 public void testAlign() {
48 for (int i = 0; i < 3 * BindingsHelper.ALIGNMENT; ++i) { 48 for (int i = 0; i < 3 * BindingsHelper.ALIGNMENT; ++i) {
49 int j = BindingsHelper.align(i); 49 int j = BindingsHelper.align(i);
50 assertTrue(j >= i); 50 assertTrue(j >= i);
51 assertTrue(j % BindingsHelper.ALIGNMENT == 0); 51 assertTrue(j % BindingsHelper.ALIGNMENT == 0);
52 assertTrue(j - i < BindingsHelper.ALIGNMENT); 52 assertTrue(j - i < BindingsHelper.ALIGNMENT);
53 } 53 }
54 } 54 }
55 } 55 }
OLDNEW
« no previous file with comments | « mojo/android/BUILD.gn ('k') | mojo/android/javatests/src/org/chromium/mojo/bindings/BindingsTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698