当前位置: 首页>>代码示例>>Java>>正文


Java UiThreadTest类代码示例

本文整理汇总了Java中android.test.UiThreadTest的典型用法代码示例。如果您正苦于以下问题:Java UiThreadTest类的具体用法?Java UiThreadTest怎么用?Java UiThreadTest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UiThreadTest类属于android.test包,在下文中一共展示了UiThreadTest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testBack

import android.test.UiThreadTest; //导入依赖的package包/类
@UiThreadTest
public void testBack() throws Exception {
    FragmentManager manager = activity.getSupportFragmentManager();
    FragmentStack stack = new FragmentStack(activity, manager, CONTAINER_ID);

    assertFalse(stack.back());

    stack.push(new TestFragment1());
    assertEquals(1, stack.size());
    assertFalse(stack.back());

    stack.push(new TestFragment1());
    assertEquals(2, stack.size());
    assertTrue(stack.back());

    assertEquals(1, stack.size());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:FragmentStackTest.java

示例2: testConnectivityManagerDelegateDoesNotCrash

import android.test.UiThreadTest; //导入依赖的package包/类
@UiThreadTest
@MediumTest
@Feature({"Android-AppBase"})
public void testConnectivityManagerDelegateDoesNotCrash() {
    ConnectivityManagerDelegate delegate =
            new ConnectivityManagerDelegate(getInstrumentation().getTargetContext());
    delegate.getNetworkState();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // getNetworkState(Network) doesn't crash upon invalid Network argument.
        Network invalidNetwork = netIdToNetwork(NetId.INVALID);
        NetworkState invalidNetworkState = delegate.getNetworkState(invalidNetwork);
        assertFalse(invalidNetworkState.isConnected());
        assertEquals(-1, invalidNetworkState.getNetworkType());
        assertEquals(-1, invalidNetworkState.getNetworkSubType());

        Network[] networks = delegate.getAllNetworksUnfiltered();
        if (networks.length >= 1) {
            delegate.getNetworkState(networks[0]);
        }
        delegate.getDefaultNetId();
        NetworkCallback networkCallback = new NetworkCallback();
        NetworkRequest networkRequest = new NetworkRequest.Builder().build();
        delegate.registerNetworkCallback(networkRequest, networkCallback);
        delegate.unregisterNetworkCallback(networkCallback);
    }
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:27,代码来源:NetworkChangeNotifierTest.java

示例3: testPushPop

import android.test.UiThreadTest; //导入依赖的package包/类
@UiThreadTest
public void testPushPop() throws Exception {
    FragmentManager manager = activity.getSupportFragmentManager();
    FragmentStack stack = new FragmentStack(activity, manager, CONTAINER_ID);

    TestFragment1 fragment = new TestFragment1();
    stack.push(fragment);
    assertTopFragment(manager, stack, fragment, 0);

    TestFragment2 fragment2 = new TestFragment2();
    stack.push(fragment2);
    assertFragment(manager, fragment, 0);
    assertTopFragment(manager, stack, fragment2, 1);

    assertFalse(fragment.isAdded());
    assertTrue(fragment2.isAdded());

    assertTrue(stack.pop());
    assertTopFragment(manager, stack, fragment, 0);

    assertNull(manager.findFragmentByTag("1"));

    assertFalse(stack.pop());
    assertTopFragment(manager, stack, fragment, 0);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:FragmentStackTest.java

示例4: testPushReplace

import android.test.UiThreadTest; //导入依赖的package包/类
@UiThreadTest
public void testPushReplace() throws Exception {

    FragmentManager manager = activity.getSupportFragmentManager();
    FragmentStack stack = new FragmentStack(activity, manager, CONTAINER_ID);

    TestFragment1 fragment = new TestFragment1();
    stack.push(fragment);
    TestFragment2 fragment2 = new TestFragment2();
    stack.push(fragment2);

    TestFragment1 fragment3 = new TestFragment1();
    stack.replace(fragment3);
    assertTopFragment(manager, stack, fragment3, 0);

    assertNull(manager.findFragmentByTag("1"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:FragmentStackTest.java

示例5: testNetworkChangeNotifierIsOnline

import android.test.UiThreadTest; //导入依赖的package包/类
@UiThreadTest
@MediumTest
@Feature({"Android-AppBase"})
public void testNetworkChangeNotifierIsOnline() throws InterruptedException {
    Intent intent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
    // For any connection type it should return true.
    for (int i = ConnectivityManager.TYPE_MOBILE; i < ConnectivityManager.TYPE_VPN; i++) {
        mConnectivityDelegate.setActiveNetworkExists(true);
        mConnectivityDelegate.setNetworkType(i);
        mReceiver.onReceive(getInstrumentation().getTargetContext(), intent);
        assertTrue(NetworkChangeNotifier.isOnline());
    }
    mConnectivityDelegate.setActiveNetworkExists(false);
    mReceiver.onReceive(getInstrumentation().getTargetContext(), intent);
    assertFalse(NetworkChangeNotifier.isOnline());
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:17,代码来源:NetworkChangeNotifierTest.java

示例6: testAdd_requestProcessedInCorrectOrder

import android.test.UiThreadTest; //导入依赖的package包/类
@UiThreadTest
public void testAdd_requestProcessedInCorrectOrder() throws Exception {
    int requestsToMake = 100;

    OrderCheckingNetwork network = new OrderCheckingNetwork();
    RequestQueue queue = new RequestQueue(new NoCache(), network, 1, mDelivery);

    for (Request<?> request : makeRequests(requestsToMake)) {
        queue.add(request);
    }

    network.setExpectedRequests(requestsToMake);
    queue.start();
    network.waitUntilExpectedDone(2000); // 2 seconds
    queue.stop();
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:17,代码来源:RequestQueueTest.java

示例7: testLogChannelViewStop

import android.test.UiThreadTest; //导入依赖的package包/类
@UiThreadTest
public void testLogChannelViewStop() throws Exception {
    startAndWaitForComplete();
    long fakeId = 100000000;
    long time = System.currentTimeMillis();
    long duration = TimeUnit.MINUTES.toMillis(10);
    Channel channel = new Channel.Builder().setId(fakeId).build();
    mWatchedHistoryManager.logChannelViewStop(channel, time, duration);

    WatchedRecord record = mWatchedHistoryManager.getRecord(0);
    WatchedRecord recordFromSharedPreferences =
            mWatchedHistoryManager.getRecordFromSharedPreferences(0);
    assertEquals(record.channelId, fakeId);
    assertEquals(record.watchedStartTime, time - duration);
    assertEquals(record.duration, duration);
    assertEquals(record, recordFromSharedPreferences);
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:18,代码来源:WatchedHistoryManagerTest.java

示例8: testCircularHistoryQueue

import android.test.UiThreadTest; //导入依赖的package包/类
@UiThreadTest
public void testCircularHistoryQueue() throws Exception {
    startAndWaitForComplete();
    final long startChannelId = 100000000;
    long time = System.currentTimeMillis();
    long duration = TimeUnit.MINUTES.toMillis(10);

    int size = MAX_HISTORY_SIZE * 2;
    for (int i = 0; i < size; ++i) {
        Channel channel = new Channel.Builder().setId(startChannelId + i).build();
        mWatchedHistoryManager.logChannelViewStop(channel, time + duration * i, duration);
    }
    for (int i = 0; i < MAX_HISTORY_SIZE; ++i) {
        WatchedRecord record = mWatchedHistoryManager.getRecord(i);
        WatchedRecord recordFromSharedPreferences =
                mWatchedHistoryManager.getRecordFromSharedPreferences(i);
        assertEquals(record, recordFromSharedPreferences);
        assertEquals(record.channelId, startChannelId + size - 1 - i);
    }
    // Since the WatchedHistory is a circular queue, the value for 0 and maxHistorySize
    // are same.
    assertEquals(mWatchedHistoryManager.getRecordFromSharedPreferences(0),
            mWatchedHistoryManager.getRecordFromSharedPreferences(MAX_HISTORY_SIZE));
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:25,代码来源:WatchedHistoryManagerTest.java

示例9: testDefaultLocaleAndAcceptLanguageAgree

import android.test.UiThreadTest; //导入依赖的package包/类
/** Ensure that the more specific dialect is first in the list. */
@UiThreadTest
public void testDefaultLocaleAndAcceptLanguageAgree() throws Throwable {
    preserveAppState();

    testDefaultLocaleAndAcceptLanguageAgree("zh,zh-hant;q=0.8", "zh",
            Locale.TRADITIONAL_CHINESE);
    testDefaultLocaleAndAcceptLanguageAgree("zh,zh-hans;q=0.8", "zh",
            Locale.SIMPLIFIED_CHINESE);
    testDefaultLocaleAndAcceptLanguageAgree("zh,en;q=0.8", "zh", Locale.US);
    testDefaultLocaleAndAcceptLanguageAgree("zh,en;q=0.8", "zh", Locale.ENGLISH);
    testDefaultLocaleAndAcceptLanguageAgree("en,zh-hans;q=0.8", "en",
            Locale.SIMPLIFIED_CHINESE);
    testDefaultLocaleAndAcceptLanguageAgree("test,zh-hans;q=0.8", "test",
            Locale.SIMPLIFIED_CHINESE);
    testDefaultLocaleAndAcceptLanguageAgree("es,zh-hans;q=0.9,zh-hant;q=0.8",
            AppLanguageLookUpTable.SIMPLIFIED_CHINESE_LANGUAGE_CODE,
            Locale.TRADITIONAL_CHINESE, Site.forLanguage("es"));
    testDefaultLocaleAndAcceptLanguageAgree("zh-hant",
            AppLanguageLookUpTable.TRADITIONAL_CHINESE_LANGUAGE_CODE,
            Locale.TRADITIONAL_CHINESE);

    restoreAppState();
}
 
开发者ID:gnosygnu,项目名称:xowa_android,代码行数:25,代码来源:LanguageVariantTests.java

示例10: testSignup

import android.test.UiThreadTest; //导入依赖的package包/类
@UiThreadTest
public void testSignup() {
    try {
        signUp(name1, username1, email1, motto1);
        assertEquals(username1, AppUserSingleton.getInstance().getUser().getJestID());
        assertEquals(motto1, AppUserSingleton.getInstance().getUser().getMotto());
        assertEquals(email1, AppUserSingleton.getInstance().getUser().getEmailAddress());
        assertEquals(name1, AppUserSingleton.getInstance().getUser().getFullName());

        User dave = ShareoData.getInstance().getUser(username1);
        dave.new Deleter().useMainThread().delete();

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:CMPUT301W16T15,项目名称:Shareo,代码行数:17,代码来源:LoginTest.java

示例11: testSignupAndLogin

import android.test.UiThreadTest; //导入依赖的package包/类
@UiThreadTest
public void testSignupAndLogin() {
    try {
        signUp(name2, username2, email2, motto2);
        assertEquals(username2, AppUserSingleton.getInstance().getUser().getJestID());
        assertEquals(motto2, AppUserSingleton.getInstance().getUser().getMotto());
        assertEquals(email2, AppUserSingleton.getInstance().getUser().getEmailAddress());
        assertEquals(name2, AppUserSingleton.getInstance().getUser().getFullName());

        testLogin(username2);
        User user = ShareoData.getInstance().getUser(username2);
        user.new Deleter().useMainThread().delete();

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:CMPUT301W16T15,项目名称:Shareo,代码行数:18,代码来源:LoginTest.java

示例12: testTheSequence

import android.test.UiThreadTest; //导入依赖的package包/类
/**
 * To verify if it proceeds to the next tourGuide
 */
@UiThreadTest
public void testTheSequence(){
    int size = mActivity.mSequence.getTourGuideArray().length;
    int currentSequence = 0;

    try {
        assertEquals(getActualSequence(), currentSequence); //to make sure it proceeds to the next sequence
        Thread.sleep(1500);
        button.performClick();
        currentSequence += 1;

        assertEquals(getActualSequence(), currentSequence); //to make sure it proceeds to the next sequence
        button2.performClick();
        currentSequence += 1;
        Thread.sleep(1500);

        assertEquals(getActualSequence(), currentSequence);//to make sure it proceeds to the next sequence
        button3.performClick();

        assertEquals(mActivity.mSequence.mCurrentSequence, size); //to check if it reaches to the end of tourguide
    }
    catch (InterruptedException e){
        Log.d(TAG, "InterruptedException occur in testTheSequence");
    }
}
 
开发者ID:worker8,项目名称:TourGuide,代码行数:29,代码来源:SequenceTest.java

示例13: testNewSettingSave

import android.test.UiThreadTest; //导入依赖的package包/类
/**
 * Tests creation of a new setting, that the UI is initialized to the right state, and that changes are
 * properly saved
 */
@MediumTest
@UiThreadTest
public void testNewSettingSave() throws Throwable {
    final Activity activity = getActivity();

    assertTitle();

    assertMessageAutoSync(""); //$NON-NLS-1$
    assertHintAutoSync(mTargetContext.getString(R.string.manual_cmd_hint));

    setMessageAutoSync(getName());

    activity.finish();

    assertActivityResultAutoSync(getName());
}
 
开发者ID:souliss,项目名称:soulissapp,代码行数:21,代码来源:TaskerEditActivityTest.java

示例14: testIntChanged

import android.test.UiThreadTest; //导入依赖的package包/类
@UiThreadTest
@SmallTest
public void testIntChanged() {
    final AtomicInteger value = new AtomicInteger(-1);
    final OnPreferenceValueChangedListener<Integer> listener =
            new OnPreferenceValueChangedListener<Integer>() {
                @Override
                public void onChanged(Integer newValue) {
                    value.set(newValue);
                }
            };
    
    uut.registerIntChangeListener(listener);
    uut.setInt(1);
    
    assertEquals(1, value.get());
}
 
开发者ID:martino2k6,项目名称:StoreBox,代码行数:18,代码来源:ChangesListenersTestCase.java

示例15: testIntUnregistered

import android.test.UiThreadTest; //导入依赖的package包/类
@UiThreadTest
@SmallTest
public void testIntUnregistered() {
    final AtomicBoolean called = new AtomicBoolean();
    final OnPreferenceValueChangedListener<Integer> listener =
            new OnPreferenceValueChangedListener<Integer>() {
                @Override
                public void onChanged(Integer newValue) {
                    called.set(true);
                }
            };

    uut.registerIntChangeListener(listener);
    uut.unregisterIntChangeListener(listener);
    uut.setInt(1);

    assertFalse(called.get());
}
 
开发者ID:martino2k6,项目名称:StoreBox,代码行数:19,代码来源:ChangesListenersTestCase.java


注:本文中的android.test.UiThreadTest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。