提交 2287622d 编写于 作者: T Takeshi Hagikura

Add a DialogFragment that edits properties for a flex item.

Add the @FlakyTest annotation for the UI tests for the library.

Change-Id: Ic4c3250b3c43c7aa9463c73f71912b2c1e389a25
上级 66923137
......@@ -18,6 +18,8 @@ package com.google.android.apps.flexbox.test;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
import static android.support.test.espresso.action.ViewActions.replaceText;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static junit.framework.Assert.assertNotNull;
import static org.hamcrest.MatcherAssert.assertThat;
......@@ -38,6 +40,7 @@ import android.test.FlakyTest;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import org.junit.Rule;
import org.junit.Test;
......@@ -286,4 +289,42 @@ public class MainActivityTest {
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(flexboxLayout.getAlignContent(), is(FlexboxLayout.ALIGN_CONTENT_STRETCH));
}
@Test
@FlakyTest(tolerance = 3)
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"));
}
@Test
@FlakyTest(tolerance = 3)
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()));
}
}
/*
* Copyright 2016 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.apps.flexbox;
import com.google.android.libraries.flexbox.FlexboxLayout;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TextInputLayout;
import android.support.v4.app.DialogFragment;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
/**
* DialogFragment that changes the properties for a flex item.
*/
public class FlexItemEditFragment extends DialogFragment {
private static final String FLEX_ITEM_KEY = "flex_item";
private String ALIGN_SELF_AUTO;
private String ALIGN_SELF_FLEX_START;
private String ALIGN_SELF_FLEX_END;
private String ALIGN_SELF_CENTER;
private String ALIGN_SELF_BASELINE;
private String ALIGN_SELF_STRETCH;
private FlexItem mFlexItem;
private FlexItemChangedListener mFlexItemChangedListener;
public static FlexItemEditFragment newInstance(FlexItem flexItem) {
FlexItemEditFragment fragment = new FlexItemEditFragment();
Bundle args = new Bundle();
args.putParcelable(FLEX_ITEM_KEY, flexItem);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Material_Light_Dialog);
} else {
setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Dialog);
}
Bundle args = getArguments();
mFlexItem = args.getParcelable(FLEX_ITEM_KEY);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Activity activity = getActivity();
ALIGN_SELF_AUTO = activity.getString(R.string.auto);
ALIGN_SELF_FLEX_START = activity.getString(R.string.flex_start);
ALIGN_SELF_FLEX_END = activity.getString(R.string.flex_end);
ALIGN_SELF_CENTER = activity.getString(R.string.center);
ALIGN_SELF_BASELINE = activity.getString(R.string.baseline);
ALIGN_SELF_STRETCH = activity.getString(R.string.stretch);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_flex_item_edit, container, false);
getDialog().setTitle(String.valueOf(mFlexItem.index + 1));
final TextInputLayout orderTextInput = (TextInputLayout) view
.findViewById(R.id.input_layout_order);
EditText orderEdit = (EditText) view.findViewById(R.id.edit_text_order);
orderEdit.setText(String.valueOf(mFlexItem.order));
orderEdit.addTextChangedListener(
new FlexEditTextWatcher(orderTextInput, new IntegerInputVerifier(),
R.string.must_be_integer));
final TextInputLayout flexGrowInput = (TextInputLayout) view
.findViewById(R.id.input_layout_flex_grow);
EditText flexGrowEdit = (EditText) view.findViewById(R.id.edit_text_flex_grow);
flexGrowEdit.setText(String.valueOf(mFlexItem.flexGrow));
flexGrowEdit.addTextChangedListener(
new FlexEditTextWatcher(flexGrowInput, new NonNegativeIntegerInputVerifier(),
R.string.must_be_non_negative_integer));
final TextInputLayout flexShrinkInput = (TextInputLayout) view
.findViewById(R.id.input_layout_flex_shrink);
EditText flexShrinkEdit = (EditText) view.findViewById(
R.id.edit_text_flex_shrink);
flexShrinkEdit.setText(String.valueOf(mFlexItem.flexShrink));
flexShrinkEdit.addTextChangedListener(
new FlexEditTextWatcher(flexShrinkInput, new NonNegativeIntegerInputVerifier(),
R.string.must_be_non_negative_integer));
final TextInputLayout minWidthInput = (TextInputLayout) view
.findViewById(R.id.input_layout_min_width);
EditText minWidthEdit = (EditText) view.findViewById(R.id.edit_text_min_width);
minWidthEdit.setText(String.valueOf(mFlexItem.minWidth));
minWidthEdit.addTextChangedListener(
new FlexEditTextWatcher(minWidthInput, new SizeUnitInputVerifier(),
R.string.must_be_minus_one_or_minus_two_or_non_negative_integer));
final TextInputLayout minHeightInput = (TextInputLayout) view
.findViewById(R.id.input_layout_min_height);
EditText minHeightEdit = (EditText) view.findViewById(
R.id.edit_text_min_height);
minHeightEdit.setText(String.valueOf(mFlexItem.minHeight));
minHeightEdit.addTextChangedListener(
new FlexEditTextWatcher(minHeightInput, new SizeUnitInputVerifier(),
R.string.must_be_minus_one_or_minus_two_or_non_negative_integer));
Spinner alignSelfSpinner = (Spinner) view.findViewById(
R.id.spinner_align_self);
ArrayAdapter<CharSequence> arrayAdapter = ArrayAdapter.createFromResource(getActivity(),
R.array.array_align_self, R.layout.spinner_item);
alignSelfSpinner.setAdapter(arrayAdapter);
alignSelfSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String selected = parent.getItemAtPosition(position).toString();
if (selected.equals(ALIGN_SELF_AUTO)) {
mFlexItem.alignSelf = FlexboxLayout.LayoutParams.ALIGN_SELF_AUTO;
} else if (selected.equals(ALIGN_SELF_FLEX_START)) {
mFlexItem.alignSelf = FlexboxLayout.LayoutParams.ALIGN_SELF_FLEX_START;
} else if (selected.equals(ALIGN_SELF_FLEX_END)) {
mFlexItem.alignSelf = FlexboxLayout.LayoutParams.ALIGN_SELF_FLEX_END;
} else if (selected.equals(ALIGN_SELF_CENTER)) {
mFlexItem.alignSelf = FlexboxLayout.LayoutParams.ALIGN_SELF_CENTER;
} else if (selected.equals(ALIGN_SELF_BASELINE)) {
mFlexItem.alignSelf = FlexboxLayout.LayoutParams.ALIGN_SELF_BASELINE;
} else if (selected.equals(ALIGN_SELF_STRETCH)) {
mFlexItem.alignSelf = FlexboxLayout.LayoutParams.ALIGN_SELF_STRETCH;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// No op
}
});
int alignSelfPosition = arrayAdapter.getPosition(alignSelfAsString(mFlexItem.alignSelf));
alignSelfSpinner.setSelection(alignSelfPosition);
view.findViewById(
R.id.button_cancel).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
final Button okButton = (Button) view.findViewById(R.id.button_ok);
okButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (orderTextInput.isErrorEnabled() || flexGrowInput.isErrorEnabled() ||
flexShrinkInput.isErrorEnabled() || minWidthInput.isErrorEnabled() ||
minHeightInput.isErrorEnabled()) {
Toast.makeText(getActivity(), R.string.invalid_values_exist, Toast.LENGTH_SHORT)
.show();
return;
}
if (mFlexItemChangedListener != null) {
mFlexItemChangedListener.onFlexItemChanged(mFlexItem);
}
dismiss();
}
});
return view;
}
public void setFlexItemChangedListener(FlexItemChangedListener flexItemChangedListener) {
mFlexItemChangedListener = flexItemChangedListener;
}
private String alignSelfAsString(int alignSelf) {
switch (alignSelf) {
case FlexboxLayout.LayoutParams.ALIGN_SELF_AUTO:
return ALIGN_SELF_AUTO;
case FlexboxLayout.LayoutParams.ALIGN_SELF_FLEX_START:
return ALIGN_SELF_FLEX_START;
case FlexboxLayout.LayoutParams.ALIGN_SELF_FLEX_END:
return ALIGN_SELF_FLEX_END;
case FlexboxLayout.LayoutParams.ALIGN_SELF_CENTER:
return ALIGN_SELF_CENTER;
case FlexboxLayout.LayoutParams.ALIGN_SELF_BASELINE:
return ALIGN_SELF_BASELINE;
case FlexboxLayout.LayoutParams.ALIGN_SELF_STRETCH:
return ALIGN_SELF_STRETCH;
default:
return ALIGN_SELF_AUTO;
}
}
private class FlexEditTextWatcher implements TextWatcher {
TextInputLayout mTextInputLayout;
InputVerifier mInputVerifier;
int mErrorMessageId;
FlexEditTextWatcher(TextInputLayout textInputLayout, InputVerifier inputVerifier,
int errorMessageId) {
mTextInputLayout = textInputLayout;
mInputVerifier = inputVerifier;
mErrorMessageId = errorMessageId;
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// No op
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (mInputVerifier.isValidInput(s)) {
mTextInputLayout.setErrorEnabled(false);
mTextInputLayout.setError("");
} else {
mTextInputLayout.setErrorEnabled(true);
mTextInputLayout.setError(getActivity().getResources()
.getString(mErrorMessageId));
}
}
@Override
public void afterTextChanged(Editable editable) {
if (mTextInputLayout.isErrorEnabled() || TextUtils.isEmpty(editable)) {
return;
}
int intValue = Integer.valueOf(editable.toString());
switch (mTextInputLayout.getId()) {
case R.id.input_layout_order:
mFlexItem.order = intValue;
break;
case R.id.input_layout_flex_grow:
mFlexItem.flexGrow = intValue;
break;
case R.id.input_layout_flex_shrink:
mFlexItem.flexShrink = intValue;
break;
case R.id.input_layout_min_width:
mFlexItem.minWidth = intValue;
break;
case R.id.input_layout_min_height:
mFlexItem.minHeight = intValue;
break;
}
}
}
/**
* Verifies the input in a EditText
*/
private interface InputVerifier {
boolean isValidInput(CharSequence charSequence);
}
private static class IntegerInputVerifier implements InputVerifier {
@Override
public boolean isValidInput(CharSequence charSequence) {
try {
Integer.parseInt(charSequence.toString());
} catch (NumberFormatException | NullPointerException e) {
return false;
}
return true;
}
}
private static class NonNegativeIntegerInputVerifier implements InputVerifier {
@Override
public boolean isValidInput(CharSequence charSequence) {
return !TextUtils.isEmpty(charSequence) && TextUtils.isDigitsOnly(charSequence)
&& Integer.valueOf(charSequence.toString()) >= 0;
}
}
private static class SizeUnitInputVerifier implements InputVerifier {
@Override
public boolean isValidInput(CharSequence charSequence) {
// -1 represents match_parent, -2 represents wrap_content
return !TextUtils.isEmpty(charSequence) &&
(TextUtils.isDigitsOnly(charSequence) ||
charSequence.toString().equals("-1") ||
charSequence.toString().equals("-2"));
}
}
/**
* A listener that listens to the change of a flex item
*/
public interface FlexItemChangedListener {
void onFlexItemChanged(FlexItem flexItem);
}
}
......@@ -45,6 +45,7 @@ public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
private static final String FLEX_ITEMS_KEY = "flex_items";
private static final String EDIT_DIALOG_TAG = "edit_dialog_tag";
private String ROW;
private String COLUMN;
......@@ -118,6 +119,10 @@ public class MainActivity extends AppCompatActivity
}
}
for (int i = 0; i < mFlexboxLayout.getChildCount(); i++) {
mFlexboxLayout.getChildAt(i).setOnClickListener(new FlexItemClickListener(i));
}
FloatingActionButton addFab = (FloatingActionButton) findViewById(R.id.add_fab);
if (addFab != null) {
addFab.setOnClickListener(new View.OnClickListener() {
......@@ -477,7 +482,37 @@ public class MainActivity extends AppCompatActivity
@Override
public void onClick(View v) {
// TODO: Implement the onClick listener
FlexboxLayout.LayoutParams lp = (FlexboxLayout.LayoutParams) v.getLayoutParams();
FlexItem flexItem = new FlexItem();
flexItem.index = mViewIndex;
flexItem.order = lp.order;
flexItem.flexGrow = lp.flexGrow;
flexItem.flexShrink = lp.flexShrink;
flexItem.alignSelf = lp.alignSelf;
flexItem.minWidth = Util.pixelToDp(MainActivity.this, lp.width);
flexItem.minHeight = Util.pixelToDp(MainActivity.this, lp.height);
FlexItemEditFragment fragment = FlexItemEditFragment.newInstance(flexItem);
fragment.setFlexItemChangedListener(new FlexItemChangeListenerImpl());
fragment.show(getSupportFragmentManager(), EDIT_DIALOG_TAG);
}
}
private class FlexItemChangeListenerImpl
implements FlexItemEditFragment.FlexItemChangedListener {
@Override
public void onFlexItemChanged(FlexItem flexItem) {
View view = mFlexboxLayout.getChildAt(flexItem.index);
FlexboxLayout.LayoutParams lp = (FlexboxLayout.LayoutParams) view.getLayoutParams();
lp.order = flexItem.order;
lp.flexGrow = flexItem.flexGrow;
lp.flexShrink = flexItem.flexShrink;
lp.alignSelf = flexItem.alignSelf;
lp.width = Util.dpToPixel(MainActivity.this, flexItem.minWidth);
lp.height = Util.dpToPixel(MainActivity.this, flexItem.minHeight);
view.setLayoutParams(lp);
// TODO: Update the layout only related views
mFlexboxLayout.requestLayout();
}
}
......
......@@ -22,15 +22,20 @@ limitations under the License.
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:flexWrap="wrap"
app:alignItems="flex_start"
app:alignContent="flex_start"
tools:showIn="@layout/activity_main" >
<TextView
android:id="@+id/textview1"
android:layout_width="@dimen/flex_item_length2"
android:layout_height="@dimen/flex_item_length"
android:text="@string/one"
style="@style/FlexItem" />
<TextView
android:id="@+id/textview2"
android:layout_width="@dimen/flex_item_length3"
android:layout_height="@dimen/flex_item_length"
android:text="@string/two"
......@@ -38,6 +43,7 @@ limitations under the License.
/>
<TextView
android:id="@+id/textview3"
android:layout_width="@dimen/flex_item_length"
android:layout_height="@dimen/flex_item_length"
android:text="@string/three"
......
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2016 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="@dimen/activity_horizontal_margin"
android:paddingEnd="@dimen/activity_horizontal_margin">
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_order"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/edit_text_order"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:singleLine="true"
android:inputType="numberSigned"
android:hint="@string/hint_order" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_flex_grow"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/edit_text_flex_grow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:singleLine="true"
android:inputType="number"
android:hint="@string/hint_flex_grow" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_flex_shrink"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/edit_text_flex_shrink"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:singleLine="true"
android:inputType="number"
android:hint="@string/hint_flex_shrink" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_min_width"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/edit_text_min_width"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:singleLine="true"
android:inputType="numberSigned"
android:hint="@string/hint_min_width" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_min_height"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/edit_text_min_height"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:singleLine="true"
android:inputType="numberSigned"
android:hint="@string/hint_min_height" />
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="@dimen/margin_tiny"
android:paddingLeft="@dimen/margin_tiny"
android:paddingEnd="@dimen/margin_tiny"
android:paddingRight="@dimen/margin_tiny"
android:text="@string/hint_align_self" />
<Spinner
android:id="@+id/spinner_align_self"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="end" />
</LinearLayout>
<LinearLayout
android:id="@+id/button_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="@dimen/margin_small"
android:paddingBottom="@dimen/margin_small"
android:gravity="bottom"
style="?android:attr/buttonBarStyle">
<View
android:id="@+id/spacer"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"
android:visibility="invisible" />
<!-- TODO Prepare style for API level less thatn 21 -->
<Button
android:id="@+id/button_cancel"
style="?android:attr/buttonBarNegativeButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cancel" />
<!-- TODO Prepare style for API level less thatn 21 -->
<Button
android:id="@+id/button_ok"
style="?android:attr/buttonBarPositiveButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ok" />
</LinearLayout>
</LinearLayout>
</ScrollView>
\ No newline at end of file
......@@ -93,4 +93,16 @@ limitations under the License.
<item>@string/baseline</item>
<item>@string/stretch</item>
</string-array>
<string name="hint_order">Order</string>
<string name="hint_flex_grow">Flex Grow</string>
<string name="hint_flex_shrink">Flex Shrink</string>
<string name="hint_align_self">Align Self</string>
<string name="hint_min_width">Minimum Width (-1: match_parent, -2: wrap_content)</string>
<string name="hint_min_height">Minimum Height (-1: match_parent, -2: wrap_content)</string>
<string name="must_be_non_negative_integer">Must be a non-negative integer value</string>
<string name="must_be_minus_one_or_minus_two_or_non_negative_integer">Must be -1 or -2 or a non-negative integer value</string>
<string name="must_be_integer">Must be an integer value</string>
<string name="invalid_values_exist">Invalid values exist</string>
</resources>
......@@ -39,6 +39,7 @@ import android.support.test.InstrumentationRegistry;
import android.support.test.filters.MediumTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.FlakyTest;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
......@@ -59,6 +60,7 @@ public class FlexboxAndroidTest {
new ActivityTestRule<>(FlexboxTestActivity.class);
@Test
@FlakyTest(tolerance = 3)
public void testLoadFromLayoutXml() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -84,6 +86,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testOrderAttribute_fromLayoutXml() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -112,6 +115,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testOrderAttribute_fromCode() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -151,6 +155,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testFlexWrap_wrap() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -174,6 +179,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testFlexWrap_nowrap() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -201,6 +207,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testFlexWrap_wrap_reverse() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -227,6 +234,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testFlexboxLayout_wrapContent() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -253,6 +261,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testFlexboxLayout_wrapped_with_ScrollView() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -281,6 +290,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testJustifyContent_flexStart() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -299,6 +309,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testJustifyContent_flexEnd() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -320,6 +331,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testJustifyContent_center() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -349,6 +361,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testJustifyContent_spaceBetween() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -381,6 +394,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testJustifyContent_spaceAround() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -413,6 +427,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testFlexGrow_withExactParentLength() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -440,6 +455,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testAlignContent_stretch() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -468,6 +484,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testAlignContent_flexStart() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -497,6 +514,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testAlignContent_flexEnd() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -523,6 +541,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testAlignContent_center() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -551,6 +570,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testAlignContent_spaceBetween() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -574,6 +594,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testAlignContent_spaceAround() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -602,6 +623,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testAlignContent_stretch_parentWrapContent() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -636,6 +658,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testAlignItems_stretch() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -666,6 +689,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testAlignSelf_stretch() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -696,6 +720,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testAlignItems_flexStart() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -727,6 +752,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testAlignItems_flexEnd() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -762,6 +788,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testAlignItems_center() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -799,6 +826,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testAlignItems_flexEnd_wrapReverse() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......@@ -835,6 +863,7 @@ public class FlexboxAndroidTest {
}
@Test
@FlakyTest(tolerance = 3)
public void testAlignItems_center_wrapReverse() throws Throwable {
final FlexboxTestActivity activity = mActivityRule.getActivity();
mActivityRule.runOnUiThread(new Runnable() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册