• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FlakyTest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testLoadFromLayoutXml

import android.test.FlakyTest; //导入依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testLoadFromLayoutXml() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    mActivityRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.setContentView(R.layout.activity_simple);
        }
    });
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);

    assertNotNull(flexboxLayout);
    assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_ROW_REVERSE));
    assertThat(flexboxLayout.getJustifyContent(), is(FlexboxLayout.JUSTIFY_CONTENT_CENTER));
    assertThat(flexboxLayout.getAlignContent(), is(FlexboxLayout.ALIGN_CONTENT_CENTER));
    assertThat(flexboxLayout.getAlignItems(), is(FlexboxLayout.ALIGN_ITEMS_CENTER));
    assertThat(flexboxLayout.getChildCount(), is(1));

    View child = flexboxLayout.getChildAt(0);
    FlexboxLayout.LayoutParams lp = (FlexboxLayout.LayoutParams) child.getLayoutParams();
    assertThat(lp.order, is(2));
    assertThat(lp.flexGrow, is(1f));
    assertThat(lp.alignSelf, is(FlexboxLayout.LayoutParams.ALIGN_SELF_STRETCH));
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:26,代码来源:FlexboxAndroidTest.java


示例2: testFlexWrap_wrap

import android.test.FlakyTest; //导入依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testFlexWrap_wrap() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    mActivityRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.setContentView(R.layout.activity_flex_wrap_test);
        }
    });
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);

    assertThat(flexboxLayout.getFlexWrap(), is(FlexboxLayout.FLEX_WRAP_WRAP));
    onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
    onView(withId(R.id.text2)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    // The width of the FlexboxLayout is not enough for placing the three text views.
    // The third text view should be placed below the first one
    onView(withId(R.id.text3)).check(isBelow(withId(R.id.text1)));
    onView(withId(R.id.text3)).check(isBelow(withId(R.id.text2)));
    onView(withId(R.id.text3)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:24,代码来源:FlexboxAndroidTest.java


示例3: testFlexItem_match_parent

import android.test.FlakyTest; //导入依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testFlexItem_match_parent() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    mActivityRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.setContentView(R.layout.activity_flex_item_match_parent);
        }
    });
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);
    TextView text1 = (TextView) activity.findViewById(R.id.text1);
    TextView text2 = (TextView) activity.findViewById(R.id.text2);
    TextView text3 = (TextView) activity.findViewById(R.id.text3);

    assertThat(text1.getWidth(), is(flexboxLayout.getWidth()));
    assertThat(text2.getWidth(), is(flexboxLayout.getWidth()));
    assertThat(text3.getWidth(), is(flexboxLayout.getWidth()));
    assertThat(flexboxLayout.getHeight(),
            is(text1.getHeight() + text2.getHeight() + text3.getHeight()));
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:22,代码来源:FlexboxAndroidTest.java


示例4: testFlexboxLayout_wrapContent

import android.test.FlakyTest; //导入依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testFlexboxLayout_wrapContent() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    mActivityRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.setContentView(R.layout.activity_flexbox_wrap_content);
        }
    });
    // The parent FlexboxLayout's layout_width and layout_height are set to wrap_content
    // The size of the FlexboxLayout is aligned with three text views.

    onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text1)).check(isBottomAlignedWith(withId(R.id.flexbox_layout)));

    onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
    onView(withId(R.id.text2)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isBottomAlignedWith(withId(R.id.flexbox_layout)));

    onView(withId(R.id.text3)).check(isRightOf(withId(R.id.text2)));
    onView(withId(R.id.text3)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isBottomAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isRightAlignedWith(withId(R.id.flexbox_layout)));
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:27,代码来源:FlexboxAndroidTest.java


示例5: testJustifyContent_flexStart

import android.test.FlakyTest; //导入依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testJustifyContent_flexStart() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    mActivityRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.setContentView(R.layout.activity_justify_content_test);
        }
    });
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);

    assertThat(flexboxLayout.getJustifyContent(), is(FlexboxLayout.JUSTIFY_CONTENT_FLEX_START));
    onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
    onView(withId(R.id.text3)).check(isRightOf(withId(R.id.text2)));
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:19,代码来源:FlexboxAndroidTest.java


示例6: testAlignItems_baseline

import android.test.FlakyTest; //导入依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testAlignItems_baseline() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    mActivityRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.setContentView(R.layout.activity_align_items_baseline_test);
        }
    });
    InstrumentationRegistry.getInstrumentation().waitForIdleSync();
    TextView textView1 = (TextView) activity.findViewById(R.id.text1);
    TextView textView2 = (TextView) activity.findViewById(R.id.text2);
    TextView textView3 = (TextView) activity.findViewById(R.id.text3);
    int topPluBaseline1 = textView1.getTop() + textView1.getBaseline();
    int topPluBaseline2 = textView2.getTop() + textView2.getBaseline();
    int topPluBaseline3 = textView3.getTop() + textView3.getBaseline();

    assertThat(topPluBaseline1, is(topPluBaseline2));
    assertThat(topPluBaseline2, is(topPluBaseline3));
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:22,代码来源:FlexboxAndroidTest.java


示例7: testAlignItems_baseline_wrapReverse

import android.test.FlakyTest; //导入依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testAlignItems_baseline_wrapReverse() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    mActivityRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.setContentView(R.layout.activity_align_items_baseline_test);
            FlexboxLayout flexboxLayout = (FlexboxLayout) activity
                    .findViewById(R.id.flexbox_layout);
            flexboxLayout.setFlexWrap(FlexboxLayout.FLEX_WRAP_WRAP_REVERSE);
        }
    });
    InstrumentationRegistry.getInstrumentation().waitForIdleSync();
    TextView textView1 = (TextView) activity.findViewById(R.id.text1);
    TextView textView2 = (TextView) activity.findViewById(R.id.text2);
    TextView textView3 = (TextView) activity.findViewById(R.id.text3);
    int bottomPluBaseline1 = textView1.getBottom() + textView1.getBaseline();
    int bottomPluBaseline2 = textView2.getBottom() + textView2.getBaseline();
    int bottomPluBaseline3 = textView3.getBottom() + textView3.getBaseline();

    assertThat(bottomPluBaseline1, is(bottomPluBaseline2));
    assertThat(bottomPluBaseline2, is(bottomPluBaseline3));
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:25,代码来源:FlexboxAndroidTest.java


示例8: testConfigurationChange

import android.test.FlakyTest; //导入依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testConfigurationChange() {
    MainActivity activity = mActivityRule.getActivity();
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);
    assertNotNull(flexboxLayout);
    onView(withId(R.id.add_fab)).perform(click());
    onView(withId(R.id.add_fab)).perform(click());
    int beforeCount = flexboxLayout.getChildCount();

    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    InstrumentationRegistry.getInstrumentation().waitForIdleSync();

    // Verify the flex items are restored across the configuration change.
    assertThat(flexboxLayout.getChildCount(), is(beforeCount));
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:17,代码来源:MainActivityTest.java


示例9: testEditFragment_changeOrder

import android.test.FlakyTest; //导入依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testEditFragment_changeOrder() {
    MainActivity activity = mActivityRule.getActivity();
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);
    assertNotNull(flexboxLayout);
    onView(withId(R.id.textview1)).perform(click());
    onView(withId(R.id.edit_text_order)).perform(replaceText("3"), closeSoftKeyboard());
    onView(withId(R.id.button_ok)).perform(click());
    TextView first = (TextView) flexboxLayout.getReorderedChildAt(0);
    TextView second = (TextView) flexboxLayout.getReorderedChildAt(1);
    TextView third = (TextView) flexboxLayout.getReorderedChildAt(2);

    assertThat(first.getText().toString(), is("2"));
    assertThat(second.getText().toString(), is("3"));
    assertThat(third.getText().toString(), is("1"));
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:18,代码来源:MainActivityTest.java


示例10: testEditFragment_changeFlexGrow

import android.test.FlakyTest; //导入依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testEditFragment_changeFlexGrow() {
    MainActivity activity = mActivityRule.getActivity();
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);
    assertNotNull(flexboxLayout);
    onView(withId(R.id.textview1)).perform(click());
    onView(withId(R.id.edit_text_flex_grow)).perform(replaceText("1"), closeSoftKeyboard());
    onView(withId(R.id.button_ok)).perform(click());
    TextView first = (TextView) activity.findViewById(R.id.textview1);
    TextView second = (TextView) activity.findViewById(R.id.textview2);
    TextView third = (TextView) activity.findViewById(R.id.textview3);
    assertNotNull(first);
    assertNotNull(second);
    assertNotNull(third);

    assertThat(first.getWidth(),
            is(flexboxLayout.getWidth() - second.getWidth() - third.getWidth()));
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:20,代码来源:MainActivityTest.java


示例11: testEditFragment_changeFlexBasisPercent

import android.test.FlakyTest; //导入依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testEditFragment_changeFlexBasisPercent() {
    MainActivity activity = mActivityRule.getActivity();
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);
    assertNotNull(flexboxLayout);
    onView(withId(R.id.textview1)).perform(click());
    onView(withId(R.id.edit_text_flex_basis_percent)).perform(replaceText("50"), closeSoftKeyboard());
    onView(withId(R.id.button_ok)).perform(click());
    TextView first = (TextView) activity.findViewById(R.id.textview1);
    TextView second = (TextView) activity.findViewById(R.id.textview2);
    TextView third = (TextView) activity.findViewById(R.id.textview3);
    assertNotNull(first);
    assertNotNull(second);
    assertNotNull(third);

    assertThat(first.getWidth(), is(flexboxLayout.getWidth() / 2));
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:19,代码来源:MainActivityTest.java


示例12: postDelayed

import android.test.FlakyTest; //导入依赖的package包/类
@FlakyTest
@Test
public void postDelayed() throws InterruptedException {
    final CountDownLatch latch = new CountDownLatch(1);

    long startTime = SystemClock.elapsedRealtime();
    final AtomicBoolean executed = new AtomicBoolean(false);
    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            executed.set(true);
            latch.countDown();
        }
    }, 300);

    latch.await(1, TimeUnit.SECONDS);
    assertTrue(executed.get());

    long elapsedTime = SystemClock.elapsedRealtime() - startTime;
    assertTrue("Elapsed time should be 300, but was " + elapsedTime, elapsedTime <= 330 && elapsedTime >= 300);
}
 
开发者ID:lianzhan,项目名称:weakHandler,代码行数:22,代码来源:WeakHandlerTest.java


示例13: test4StateDestroy

import android.test.FlakyTest; //导入依赖的package包/类
@Test
@FlakyTest(tolerance = 2)
public final void test4StateDestroy()
{
	// Destroy the Activity.
	_mainActivity.finish();
	
	// Restart Activity.
	_mainActivity = getActivity();
	
	// Get a reference to the list contact fragment.
	_fragmentContactList = (ContactListFragment) _mainActivity.getFragmentManager().findFragmentByTag(MainActivity.FRAGMENT_CONTACT_LIST_TAG);
	
	assertNotNull("ContactListFragment null", _fragmentContactList);
	
	assertEquals("Number of contacts", _numberOfContacts, _fragmentContactList.getListAdapter().getCount());
}
 
开发者ID:SDSMT-CSC,项目名称:CS492-FA13,代码行数:18,代码来源:Test3MainActivity.java


示例14: testOrderAttribute_fromLayoutXml

import android.test.FlakyTest; //导入依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testOrderAttribute_fromLayoutXml() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    mActivityRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.setContentView(R.layout.activity_order_test);
        }
    });
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);
    InstrumentationRegistry.getInstrumentation().waitForIdleSync();

    assertNotNull(flexboxLayout);
    assertThat(flexboxLayout.getChildCount(), is(4));
    // order: -1, index 1
    assertThat(((TextView) flexboxLayout.getReorderedChildAt(0)).getText().toString(),
            is(String.valueOf(2)));
    // order: 0, index 2
    assertThat(((TextView) flexboxLayout.getReorderedChildAt(1)).getText().toString(),
            is(String.valueOf(3)));
    // order: 1, index 3
    assertThat(((TextView) flexboxLayout.getReorderedChildAt(2)).getText().toString(),
            is(String.valueOf(4)));
    // order: 2, index 0
    assertThat(((TextView) flexboxLayout.getReorderedChildAt(3)).getText().toString(),
            is(String.valueOf(1)));
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:29,代码来源:FlexboxAndroidTest.java


示例15: testFlexboxLayout_wrapped_with_ScrollView

import android.test.FlakyTest; //导入依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testFlexboxLayout_wrapped_with_ScrollView() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    mActivityRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.setContentView(R.layout.activity_flexbox_wrapped_with_scrollview);
        }
    });
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);

    onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));

    onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
    onView(withId(R.id.text2)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));

    onView(withId(R.id.text3)).check(isBelow(withId(R.id.text1)));
    onView(withId(R.id.text3)).check(isBelow(withId(R.id.text2)));
    onView(withId(R.id.text3)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));

    // The heightMode of the FlexboxLayout is set as MeasureSpec.UNSPECIFIED, the height of the
    // layout will be expanded to include the all children views
    TextView textView1 = (TextView) activity.findViewById(R.id.text1);
    TextView textView3 = (TextView) activity.findViewById(R.id.text3);
    assertThat(flexboxLayout.getHeight(), is(textView1.getHeight() + textView3.getHeight()));
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:29,代码来源:FlexboxAndroidTest.java


示例16: testFlexboxLayout_wrapped_with_HorizontalScrollView

import android.test.FlakyTest; //导入依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testFlexboxLayout_wrapped_with_HorizontalScrollView() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    mActivityRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.setContentView(
                    R.layout.activity_flexbox_wrapped_with_horizontalscrollview);
        }
    });
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);

    onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));

    onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
    onView(withId(R.id.text2)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));

    onView(withId(R.id.text3)).check(isRightOf(withId(R.id.text1)));
    onView(withId(R.id.text3)).check(isRightOf(withId(R.id.text2)));
    onView(withId(R.id.text3)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));

    // The widthMode of the FlexboxLayout is set as MeasureSpec.UNSPECIFIED, the widht of the
    // layout will be expanded to include the all children views
    TextView textView1 = (TextView) activity.findViewById(R.id.text1);
    TextView textView2 = (TextView) activity.findViewById(R.id.text2);
    TextView textView3 = (TextView) activity.findViewById(R.id.text3);
    assertThat(flexboxLayout.getWidth(), is(textView1.getWidth() + textView2.getWidth() +
            textView3.getWidth()));
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:32,代码来源:FlexboxAndroidTest.java


示例17: testFlexGrow_withExactParentLength

import android.test.FlakyTest; //导入依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testFlexGrow_withExactParentLength() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    mActivityRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.setContentView(R.layout.activity_flex_grow_test);
        }
    });
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);

    onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
    // the third TextView is expanded to the right edge of the FlexboxLayout
    onView(withId(R.id.text3)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isRightAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isRightOf(withId(R.id.text2)));

    TextView textView1 = (TextView) activity.findViewById(R.id.text1);
    TextView textView2 = (TextView) activity.findViewById(R.id.text2);
    TextView textView3 = (TextView) activity.findViewById(R.id.text3);
    assertThat(textView3.getWidth(),
            is(flexboxLayout.getWidth() - textView1.getWidth() - textView2.getWidth()));
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:28,代码来源:FlexboxAndroidTest.java


示例18: testAlignContent_stretch

import android.test.FlakyTest; //导入依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testAlignContent_stretch() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    mActivityRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.setContentView(R.layout.activity_align_content_test);
        }
    });
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);

    assertThat(flexboxLayout.getAlignContent(), is(FlexboxLayout.ALIGN_CONTENT_STRETCH));
    onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
    // the third TextView is wrapped to the next flex line
    onView(withId(R.id.text3)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isBelow(withId(R.id.text1)));
    onView(withId(R.id.text3)).check(isBelow(withId(R.id.text2)));

    TextView textView3 = (TextView) activity.findViewById(R.id.text3);
    int flexLineCrossSize = flexboxLayout.getHeight() / 2;
    // Two flex line's cross sizes are expanded to the half of the height of the FlexboxLayout.
    // The third textView's top should be aligned witht the second flex line.
    assertThat(textView3.getTop(), is(flexLineCrossSize));
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:29,代码来源:FlexboxAndroidTest.java


示例19: testAlignItems_stretch

import android.test.FlakyTest; //导入依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testAlignItems_stretch() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    mActivityRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.setContentView(R.layout.activity_stretch_test);
        }
    });
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);

    assertThat(flexboxLayout.getAlignItems(), is(FlexboxLayout.ALIGN_ITEMS_STRETCH));
    onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
    onView(withId(R.id.text3)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isBelow(withId(R.id.text1)));
    onView(withId(R.id.text3)).check(isBelow(withId(R.id.text2)));

    // There should be 2 flex lines in the layout with the given layout.
    int flexLineSize = flexboxLayout.getHeight() / 2;
    TextView textView1 = (TextView) activity.findViewById(R.id.text1);
    TextView textView2 = (TextView) activity.findViewById(R.id.text2);
    TextView textView3 = (TextView) activity.findViewById(R.id.text3);
    assertTrue(flexLineSize - 1 <= textView1.getHeight()
            && textView1.getHeight() <= flexLineSize + 1);
    assertTrue(flexLineSize - 1 <= textView2.getHeight() &&
            flexLineSize <= flexLineSize + 1);
    assertTrue(flexLineSize - 1 <= textView3.getHeight() &&
            textView3.getHeight() <= flexLineSize + 1);
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:34,代码来源:FlexboxAndroidTest.java


示例20: testAlignSelf_stretch

import android.test.FlakyTest; //导入依赖的package包/类
@Test
@FlakyTest(tolerance = TOLERANCE)
public void testAlignSelf_stretch() throws Throwable {
    final FlexboxTestActivity activity = mActivityRule.getActivity();
    mActivityRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.setContentView(R.layout.activity_align_self_stretch_test);
        }
    });
    FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);

    onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text1)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text2)).check(isRightOf(withId(R.id.text1)));
    onView(withId(R.id.text3)).check(isLeftAlignedWith(withId(R.id.flexbox_layout)));
    onView(withId(R.id.text3)).check(isBelow(withId(R.id.text1)));
    onView(withId(R.id.text3)).check(isBelow(withId(R.id.text2)));

    // There should be 2 flex lines in the layout with the given layout.
    // Only the first TextView's alignSelf is set to ALIGN_SELF_STRETCH
    int flexLineSize = flexboxLayout.getHeight() / 2;
    TextView textView1 = (TextView) activity.findViewById(R.id.text1);
    TextView textView2 = (TextView) activity.findViewById(R.id.text2);
    TextView textView3 = (TextView) activity.findViewById(R.id.text3);
    assertTrue(flexLineSize - 1 <= textView1.getHeight() &&
            textView1.getHeight() <= flexLineSize + 1);
    assertThat(textView2.getHeight(), not(flexLineSize));
    assertThat(textView3.getHeight(), not(flexLineSize));
}
 
开发者ID:canceel,项目名称:flexboxlayout,代码行数:32,代码来源:FlexboxAndroidTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ColorPickerView类代码示例发布时间:2022-05-23
下一篇:
Java JFXSpinner类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap