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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/provider/ProviderTestBase.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
(Empty)
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
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.provider;
6
7 import android.content.ContentProvider;
8 import android.content.ContentResolver;
9 import android.content.pm.ProviderInfo;
10 import android.test.IsolatedContext;
11 import android.test.mock.MockContentResolver;
12
13 import org.chromium.base.ThreadUtils;
14 import org.chromium.chrome.browser.ChromeActivity;
15 import org.chromium.chrome.test.ChromeActivityTestCaseBase;
16
17 /**
18 * Base class for Chrome's ContentProvider tests.
19 * Sets up a local ChromeBrowserProvider associated to a mock resolver in an iso lated context.
20 */
21 public class ProviderTestBase extends ChromeActivityTestCaseBase<ChromeActivity> {
22
23 private IsolatedContext mContext;
24
25 public ProviderTestBase() {
26 super(ChromeActivity.class);
27 }
28
29 @Override
30 public void startMainActivity() throws InterruptedException {
31 startMainActivityOnBlankPage();
32 }
33
34 @Override
35 protected void setUp() throws Exception {
36 super.setUp();
37
38 final ChromeActivity activity = getActivity();
39 assertNotNull(activity);
40
41 final ContentProvider provider = new ChromeBrowserProvider();
42 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
43 @Override
44 public void run() {
45 ProviderInfo providerInfo = new ProviderInfo();
46 providerInfo.authority = ChromeBrowserProvider.getApiAuthority(a ctivity);
47 provider.attachInfo(activity, providerInfo);
48 }
49 });
50
51 MockContentResolver resolver = new MockContentResolver();
52 resolver.addProvider(ChromeBrowserProvider.getApiAuthority(activity), pr ovider);
53
54 mContext = new IsolatedContext(resolver, activity);
55 assertTrue(getContentResolver() instanceof MockContentResolver);
56 }
57
58 protected ContentResolver getContentResolver() {
59 return mContext.getContentResolver();
60 }
61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698