Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit 8cb6070

Browse files
authored
add check covering constrainthelper features with constraintset (#175)
add check 438, covers b/160714159
1 parent 4b7145c commit 8cb6070

File tree

6 files changed

+283
-1
lines changed

6 files changed

+283
-1
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"duration": "307000",
3+
"layout": {
4+
"children": [
5+
{
6+
"bounds": {
7+
"top": "0",
8+
"left": "0",
9+
"bottom": "0",
10+
"right": "0"
11+
},
12+
"id": "group1",
13+
"class": "Group"
14+
},
15+
{
16+
"bounds": {
17+
"top": "0",
18+
"left": "0",
19+
"bottom": "0",
20+
"right": "0"
21+
},
22+
"id": "group2",
23+
"class": "Group"
24+
},
25+
{
26+
"bounds": {
27+
"top": "1383",
28+
"left": "936",
29+
"bottom": "1440",
30+
"right": "1032"
31+
},
32+
"id": "view1",
33+
"class": "MaterialTextView"
34+
},
35+
{
36+
"bounds": {
37+
"top": "740",
38+
"left": "486",
39+
"bottom": "797",
40+
"right": "594"
41+
},
42+
"id": "view2",
43+
"class": "MaterialTextView"
44+
}
45+
],
46+
"bounds": {
47+
"top": "0",
48+
"left": "0",
49+
"bottom": "1536",
50+
"right": "1080"
51+
},
52+
"class": "ConstraintLayout"
53+
}
54+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"duration": "536500",
3+
"layout": {
4+
"children": [
5+
{
6+
"bounds": {
7+
"top": "0",
8+
"left": "0",
9+
"bottom": "0",
10+
"right": "0"
11+
},
12+
"id": "group1",
13+
"class": "Group"
14+
},
15+
{
16+
"bounds": {
17+
"top": "0",
18+
"left": "0",
19+
"bottom": "0",
20+
"right": "0"
21+
},
22+
"id": "group2",
23+
"class": "Group"
24+
},
25+
{
26+
"bounds": {
27+
"top": "0",
28+
"left": "936",
29+
"bottom": "57",
30+
"right": "1032"
31+
},
32+
"id": "view1",
33+
"class": "MaterialTextView"
34+
},
35+
{
36+
"bounds": {
37+
"top": "0",
38+
"left": "486",
39+
"bottom": "57",
40+
"right": "594"
41+
},
42+
"id": "view2",
43+
"class": "MaterialTextView"
44+
}
45+
],
46+
"bounds": {
47+
"top": "0",
48+
"left": "0",
49+
"bottom": "153",
50+
"right": "1080"
51+
},
52+
"class": "ConstraintLayout"
53+
}
54+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"duration": "911000",
3+
"layout": {
4+
"children": [
5+
{
6+
"bounds": {
7+
"top": "0",
8+
"left": "0",
9+
"bottom": "0",
10+
"right": "0"
11+
},
12+
"id": "group1",
13+
"class": "Group"
14+
},
15+
{
16+
"bounds": {
17+
"top": "0",
18+
"left": "0",
19+
"bottom": "0",
20+
"right": "0"
21+
},
22+
"id": "group2",
23+
"class": "Group"
24+
},
25+
{
26+
"bounds": {
27+
"top": "1383",
28+
"left": "0",
29+
"bottom": "1440",
30+
"right": "96"
31+
},
32+
"id": "view1",
33+
"class": "MaterialTextView"
34+
},
35+
{
36+
"bounds": {
37+
"top": "740",
38+
"left": "0",
39+
"bottom": "797",
40+
"right": "108"
41+
},
42+
"id": "view2",
43+
"class": "MaterialTextView"
44+
}
45+
],
46+
"bounds": {
47+
"top": "0",
48+
"left": "0",
49+
"bottom": "1536",
50+
"right": "144"
51+
},
52+
"class": "ConstraintLayout"
53+
}
54+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"duration": "547000",
3+
"layout": {
4+
"children": [
5+
{
6+
"bounds": {
7+
"top": "0",
8+
"left": "0",
9+
"bottom": "0",
10+
"right": "0"
11+
},
12+
"id": "group1",
13+
"class": "Group"
14+
},
15+
{
16+
"bounds": {
17+
"top": "0",
18+
"left": "0",
19+
"bottom": "0",
20+
"right": "0"
21+
},
22+
"id": "group2",
23+
"class": "Group"
24+
},
25+
{
26+
"bounds": {
27+
"top": "0",
28+
"left": "0",
29+
"bottom": "57",
30+
"right": "96"
31+
},
32+
"id": "view1",
33+
"class": "MaterialTextView"
34+
},
35+
{
36+
"bounds": {
37+
"top": "0",
38+
"left": "0",
39+
"bottom": "57",
40+
"right": "108"
41+
},
42+
"id": "view2",
43+
"class": "MaterialTextView"
44+
}
45+
],
46+
"bounds": {
47+
"top": "0",
48+
"left": "0",
49+
"bottom": "153",
50+
"right": "144"
51+
},
52+
"class": "ConstraintLayout"
53+
}
54+
}

projects/ConstraintLayoutValidation/app/src/main/java/androidx/constraintlayout/validation/MainActivity.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import androidx.constraintlayout.core.Metrics;
4040
import androidx.constraintlayout.widget.ConstraintLayout;
4141
//import androidx.constraintlayout.core.Metrics;
42+
import androidx.constraintlayout.widget.ConstraintSet;
4243
import androidx.core.view.ViewCompat;
4344
import androidx.fragment.app.Fragment;
4445
import androidx.recyclerview.widget.LinearLayoutManager;
@@ -244,6 +245,19 @@ public class MainActivity extends AppCompatActivity implements Server.Requests {
244245
return true;
245246
};
246247

248+
TestLayout testLayout_438 = (view, mode, widthMeasureSpec, heightMeasureSpec, layoutParams) -> {
249+
view.forceLayout();
250+
view.measure(widthMeasureSpec, heightMeasureSpec);
251+
view.postDelayed(() -> {
252+
ConstraintSet constraintSet = new ConstraintSet();
253+
constraintSet.clone((ConstraintLayout) view);
254+
constraintSet.setVisibility(R.id.group1, View.VISIBLE);
255+
constraintSet.setVisibility(R.id.group2, View.GONE);
256+
constraintSet.applyTo((ConstraintLayout) view);
257+
}, 20);
258+
return true;
259+
};
260+
247261
Command listCommand = (activity, server, writer, reader, out) -> {
248262
String[] layouts = getLayouts();
249263
for (int i = 0; i < layouts.length; i++) {
@@ -628,11 +642,13 @@ protected void onCreate(Bundle savedInstanceState) {
628642
mTests.put("check_406", testLayout_406);
629643
mTests.put("check_408", testLayout_408);
630644
mTests.put("check_420", testLayout_420);
645+
mTests.put("check_438", testLayout_438);
631646

632647
mTestsDelay.put("check_265", 1500);
633648
mTestsDelay.put("check_335", 1500);
634649
mTestsDelay.put("check_397", 1500);
635650
mTestsDelay.put("check_420", 500);
651+
mTestsDelay.put("check_438", 500);
636652

637653
// We skip those for now
638654
// (depends on moving to LayoutParams instead of MarginLayoutParams)
@@ -660,7 +676,7 @@ protected void onCreate(Bundle savedInstanceState) {
660676
// list_view.setLayoutManager(linearLayoutManager);
661677
// list_view.setAdapter(new Adapter339(getApplicationContext(), xVals));
662678

663-
setContentView(R.layout.check_410);
679+
setContentView(R.layout.check_438);
664680

665681
//setContentView(R.layout.check_251);
666682
// setContentView(R.layout.check_024);
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent">
7+
8+
<!-- b/160714159 -->
9+
10+
<androidx.constraintlayout.widget.Group
11+
android:id="@+id/group1"
12+
android:layout_width="wrap_content"
13+
android:layout_height="wrap_content"
14+
app:constraint_referenced_ids="view1"
15+
android:visibility="gone"/>
16+
17+
<androidx.constraintlayout.widget.Group
18+
android:id="@+id/group2"
19+
android:layout_width="wrap_content"
20+
android:layout_height="wrap_content"
21+
app:constraint_referenced_ids="view2"
22+
android:visibility="visible"/>
23+
24+
<TextView
25+
android:id="@+id/view1"
26+
android:layout_width="wrap_content"
27+
android:layout_height="wrap_content"
28+
android:layout_marginEnd="16dp"
29+
android:layout_marginRight="16dp"
30+
android:layout_marginBottom="32dp"
31+
android:textColor="#fff"
32+
android:background="@color/colorPrimary"
33+
android:text="Hello"
34+
app:layout_constraintBottom_toBottomOf="parent"
35+
app:layout_constraintEnd_toEndOf="parent" />
36+
37+
<TextView
38+
android:id="@+id/view2"
39+
android:layout_width="wrap_content"
40+
android:layout_height="wrap_content"
41+
android:background="@color/colorPrimary"
42+
android:visibility="gone"
43+
android:text="World"
44+
android:textColor="#fff"
45+
app:layout_constraintBottom_toBottomOf="parent"
46+
app:layout_constraintEnd_toEndOf="parent"
47+
app:layout_constraintStart_toStartOf="parent"
48+
app:layout_constraintTop_toTopOf="parent" />
49+
50+
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)