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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/provider/ProviderBookmarkNodeUnitTest.java

Issue 2876273004: Convert Provider tests to JUnit4 (Closed)
Patch Set: Created 3 years, 7 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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.chrome.browser.provider; 5 package org.chromium.chrome.browser.provider;
6 6
7 import android.os.Parcel; 7 import android.os.Parcel;
8 import android.support.test.filters.SmallTest; 8 import android.support.test.filters.SmallTest;
9 import android.test.AndroidTestCase;
10 9
10 import org.junit.Assert;
11 import org.junit.Before;
12 import org.junit.Test;
13 import org.junit.runner.RunWith;
14
15 import org.chromium.base.test.BaseJUnit4ClassRunner;
11 import org.chromium.base.test.util.Feature; 16 import org.chromium.base.test.util.Feature;
12 import org.chromium.chrome.browser.provider.ChromeBrowserProvider.BookmarkNode; 17 import org.chromium.chrome.browser.provider.ChromeBrowserProvider.BookmarkNode;
13 import org.chromium.chrome.browser.provider.ChromeBrowserProvider.Type; 18 import org.chromium.chrome.browser.provider.ChromeBrowserProvider.Type;
14 19
15 import java.util.Random; 20 import java.util.Random;
16 21
17 /** 22 /**
18 * Tests parceling of bookmark node hierarchies used by the provider client API. 23 * Tests parceling of bookmark node hierarchies used by the provider client API.
19 */ 24 */
20 public class ProviderBookmarkNodeUnitTest extends AndroidTestCase { 25 @RunWith(BaseJUnit4ClassRunner.class)
26 public class ProviderBookmarkNodeUnitTest {
21 Random mGenerator = new Random(); 27 Random mGenerator = new Random();
22 byte[][] mImageBlobs = null; 28 byte[][] mImageBlobs = null;
23 29
24 @Override 30 @Before
25 protected void setUp() throws Exception { 31 public void setUp() throws Exception {
26 super.setUp();
27
28 mImageBlobs = new byte[][] { 32 mImageBlobs = new byte[][] {
29 { 1, 2, 3 }, 33 { 1, 2, 3 },
30 { 4, 5, 6, 7 }, 34 { 4, 5, 6, 7 },
31 { 8, 9, 10, 11, 12 }, 35 { 8, 9, 10, 11, 12 },
32 }; 36 };
33 37
34 for (byte[] icon : mImageBlobs) { 38 for (byte[] icon : mImageBlobs) {
35 assertNotNull(icon); 39 Assert.assertNotNull(icon);
36 } 40 }
37 } 41 }
38 42
39 private static BookmarkNode parcelNode(BookmarkNode node) { 43 private static BookmarkNode parcelNode(BookmarkNode node) {
40 Parcel output = Parcel.obtain(); 44 Parcel output = Parcel.obtain();
41 Parcel input = Parcel.obtain(); 45 Parcel input = Parcel.obtain();
42 node.writeToParcel(output, 0); 46 node.writeToParcel(output, 0);
43 byte[] bytes = output.marshall(); 47 byte[] bytes = output.marshall();
44 48
45 input.unmarshall(bytes, 0, bytes.length); 49 input.unmarshall(bytes, 0, bytes.length);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 BookmarkNode parceled = parcelNode(node); 122 BookmarkNode parceled = parcelNode(node);
119 if (!isSameHierarchy(node, parceled)) return false; 123 if (!isSameHierarchy(node, parceled)) return false;
120 124
121 for (BookmarkNode child : node.children()) { 125 for (BookmarkNode child : node.children()) {
122 if (!internalTestNodeHierarchyParceling(child)) return false; 126 if (!internalTestNodeHierarchyParceling(child)) return false;
123 } 127 }
124 128
125 return true; 129 return true;
126 } 130 }
127 131
132 @Test
128 @SmallTest 133 @SmallTest
129 @Feature({"Android-ContentProvider"}) 134 @Feature({"Android-ContentProvider"})
130 public void testBookmarkNodeParceling() throws InterruptedException { 135 public void testBookmarkNodeParceling() throws InterruptedException {
131 assertTrue(internalTestNodeHierarchyParceling(createMockHierarchy())); 136 Assert.assertTrue(internalTestNodeHierarchyParceling(createMockHierarchy ()));
132 } 137 }
133 138
139 @Test
134 @SmallTest 140 @SmallTest
135 @Feature({"Android-ContentProvider"}) 141 @Feature({"Android-ContentProvider"})
136 public void testBookmarkNodeParcelingWithImages() throws InterruptedExceptio n { 142 public void testBookmarkNodeParcelingWithImages() throws InterruptedExceptio n {
137 assertTrue(internalTestNodeHierarchyParceling(createMockHierarchyWithIma ges())); 143 Assert.assertTrue(internalTestNodeHierarchyParceling(createMockHierarchy WithImages()));
138 } 144 }
139 145
146 @Test
140 @SmallTest 147 @SmallTest
141 @Feature({"Android-ContentProvider"}) 148 @Feature({"Android-ContentProvider"})
142 public void testSingleNodeParceling() throws InterruptedException { 149 public void testSingleNodeParceling() throws InterruptedException {
143 BookmarkNode node = new BookmarkNode(1, Type.URL, "Google", "http://www. google.com/", null); 150 BookmarkNode node = new BookmarkNode(1, Type.URL, "Google", "http://www. google.com/", null);
144 assertTrue(internalTestNodeHierarchyParceling(node)); 151 Assert.assertTrue(internalTestNodeHierarchyParceling(node));
145 } 152 }
146 153
154 @Test
147 @SmallTest 155 @SmallTest
148 @Feature({"Android-ContentProvider"}) 156 @Feature({"Android-ContentProvider"})
149 public void testInvalidHierarchy() throws InterruptedException { 157 public void testInvalidHierarchy() throws InterruptedException {
150 BookmarkNode root = new BookmarkNode(1, Type.FOLDER, "Bookmarks", null, null); 158 BookmarkNode root = new BookmarkNode(1, Type.FOLDER, "Bookmarks", null, null);
151 root.addChild(new BookmarkNode(2, Type.URL, "Google", "http://www.google .com/", root)); 159 root.addChild(new BookmarkNode(2, Type.URL, "Google", "http://www.google .com/", root));
152 root.addChild(new BookmarkNode(2, Type.URL, "GoogleMaps", "http://maps.g oogle.com/", root)); 160 root.addChild(new BookmarkNode(2, Type.URL, "GoogleMaps", "http://maps.g oogle.com/", root));
153 assertFalse(internalTestNodeHierarchyParceling(root)); 161 Assert.assertFalse(internalTestNodeHierarchyParceling(root));
154 } 162 }
155 } 163 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698