[go: nahoru, domu]

Adds emptyContent() function to signify empty content for a composable

Refactors existing declarations of empty lambdas as necessary
Also adds orEmpty() extension to handle nullable lambdas in a nice way.

Bug: b/149308612
Test: ./gradlew bOS
Change-Id: I8f0cf38331ac11adb5a63e2253fca41ad84bc073
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt
index 56b6eb9..19d667d 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt
@@ -18,6 +18,7 @@
 
 import android.os.SystemClock.sleep
 import androidx.compose.Model
+import androidx.compose.emptyContent
 import androidx.test.filters.MediumTest
 import androidx.ui.core.OnChildPositioned
 import androidx.ui.core.OnPositioned
@@ -68,7 +69,7 @@
                         position = coords.localToGlobal(PxPosition.Origin)
                     }
                 }
-            }) {}
+            }, bodyContent = emptyContent())
         }
         composeTestRule.runOnIdleCompose {
             assertThat(position!!.x.value).isEqualTo(0f)
@@ -85,7 +86,7 @@
                         position = coords.localToGlobal(PxPosition.Origin)
                     }
                 }
-            }) {}
+            }, bodyContent = emptyContent())
         }
         val width = composeTestRule.displayMetrics.widthPixels
         composeTestRule.runOnIdleCompose {
@@ -103,7 +104,7 @@
                         size = coords.size
                     }
                 }
-            }) {}
+            }, bodyContent = emptyContent())
         }
 
         val width = composeTestRule.displayMetrics.widthPixels
@@ -123,7 +124,7 @@
                         position = coords.localToGlobal(PxPosition.Origin)
                     }
                 }
-            }) {}
+            }, bodyContent = emptyContent())
         }
 
         val width = composeTestRule.displayMetrics.widthPixels
@@ -145,7 +146,7 @@
                         position = coords.localToGlobal(PxPosition.Origin)
                     }
                 }
-            }) {}
+            }, bodyContent = emptyContent())
         }
         val height = composeTestRule.displayMetrics.heightPixels
         composeTestRule.runOnIdleCompose {
@@ -158,7 +159,7 @@
         composeTestRule
             .setMaterialContentAndCollectSizes {
                 StaticDrawer {
-                    Container(expanded = true) {}
+                    Container(expanded = true, children = emptyContent())
                 }
             }
             .assertWidthEqualsTo(256.dp)
@@ -186,12 +187,12 @@
                                     closedLatch?.countDown()
                                 }
                             }) {
-                                Container(expanded = true) {}
+                                Container(expanded = true, children = emptyContent())
                             }
                         },
                         bodyContent = {
                             OnChildPositioned({ contentWidth = it.size.width }) {
-                                Container(expanded = true) {}
+                                Container(expanded = true, children = emptyContent())
                             }
                         })
                 }
@@ -229,12 +230,12 @@
                     ModalDrawerLayout(drawerState.state, { drawerState.state = it },
                         drawerContent = {
                             Clickable( drawerClicks += 1 }) {
-                                Container(expanded = true) {}
+                                Container(expanded = true, children = emptyContent())
                             }
                         },
                         bodyContent = {
                             Clickable( bodyClicks += 1 }) {
-                                Container(expanded = true) {}
+                                Container(expanded = true, children = emptyContent())
                             }
                         })
                 }
@@ -288,7 +289,7 @@
                                     closedLatch?.countDown()
                                 }
                             }) {
-                                Container(expanded = true) {}
+                                Container(expanded = true, children = emptyContent())
                             }
                         },
                         bodyContent = {
@@ -296,7 +297,7 @@
                                 contentHeight = it.size.height
                                 openedHeight = it.size.height * BottomDrawerOpenFraction
                             }) {
-                                Container(expanded = true) {}
+                                Container(expanded = true, children = emptyContent())
                             }
                         })
                 }
@@ -334,12 +335,12 @@
                     BottomDrawerLayout(drawerState.state, { drawerState.state = it },
                         drawerContent = {
                             Clickable( drawerClicks += 1 }) {
-                                Container(expanded = true) {}
+                                Container(expanded = true, children = emptyContent())
                             }
                         },
                         bodyContent = {
                             Clickable( bodyClicks += 1 }) {
-                                Container(expanded = true) {}
+                                Container(expanded = true, children = emptyContent())
                             }
                         })
                 }