Merge "Lint check to to detect utility classes and suggest making them un-instantiable through private constructor(s)." into androidx-master-dev
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/ActivityUnitTestSetActivityContextTest.java b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/ActivityUnitTestSetActivityContextTest.java
index 5e50f36..813440c9 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/ActivityUnitTestSetActivityContextTest.java
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/ActivityUnitTestSetActivityContextTest.java
@@ -52,7 +52,12 @@
@Override
public void tearDown() throws Exception {
if (mActivity != null) {
- getInstrumentation().callActivityOnPause(mActivity);
+ getInstrumentation().runOnMainSync(new Runnable() {
+ @Override
+ public void run() {
+ getInstrumentation().callActivityOnPause(mActivity);
+ }
+ });
}
super.tearDown();
}
@@ -71,8 +76,13 @@
});
Looper.prepare();
- mActivity = startActivity(mStartIntent, null, null);
- getInstrumentation().callActivityOnResume(mActivity);
+ getInstrumentation().runOnMainSync(new Runnable() {
+ @Override
+ public void run() {
+ mActivity = startActivity(mStartIntent, null, null);
+ getInstrumentation().callActivityOnResume(mActivity);
+ }
+ });
runTestOnUiThread(new Runnable() {
@Override
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/DialogTestCase.java b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/DialogTestCase.java
index e23fb01..378cdf5 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/DialogTestCase.java
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/app/DialogTestCase.java
@@ -38,20 +38,29 @@
public final ActivityTestRule<WindowDecorAppCompatActivity> mActivityTestRule =
new ActivityTestRule<>(WindowDecorAppCompatActivity.class);
+ private TestDialogFragment mFragment;
+
@Test
public void testDialogFragmentShows() {
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
- TestDialogFragment fragment = new TestDialogFragment();
- fragment.show(mActivityTestRule.getActivity().getSupportFragmentManager(), null);
+ InstrumentationRegistry.getInstrumentation().runOnMainSync(
+ new Runnable() {
+ @Override
+ public void run() {
+ mFragment = new TestDialogFragment();
+ }
+ }
+ );
+ mFragment.show(mActivityTestRule.getActivity().getSupportFragmentManager(), null);
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
- assertNotNull("Dialog was null", fragment.getDialog());
- assertTrue("Dialog was not being shown", fragment.getDialog().isShowing());
+ assertNotNull("Dialog was null", mFragment.getDialog());
+ assertTrue("Dialog was not being shown", mFragment.getDialog().isShowing());
// And make sure we dismiss the dialog
- fragment.dismissAllowingStateLoss();
+ mFragment.dismissAllowingStateLoss();
}
public static class TestDialogFragment extends AppCompatDialogFragment {
diff --git a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/PopupMenuTest.java b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/PopupMenuTest.java
index f87fcd5..35cbe49 100644
--- a/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/PopupMenuTest.java
+++ b/appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/PopupMenuTest.java
@@ -601,8 +601,9 @@
onView(withClassName(Matchers.is(DROP_DOWN_CLASS_NAME))).check(doesNotExist());
}
+ // Broken on API 30 b/151920359
@Test
- @SdkSuppress(minSdkVersion = Build.VERSION_CODES.O)
+ @SdkSuppress(minSdkVersion = Build.VERSION_CODES.O, maxSdkVersion = 29)
public void testHoverSelectsMenuItem() throws Throwable {
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
diff --git a/appsearch/appsearch/build.gradle b/appsearch/appsearch/build.gradle
index 73bf8a8..b526ab1 100644
--- a/appsearch/appsearch/build.gradle
+++ b/appsearch/appsearch/build.gradle
@@ -15,6 +15,7 @@
*/
import androidx.build.LibraryGroups
+import androidx.build.LibraryVersions
import androidx.build.Publish
import static androidx.build.dependencies.DependenciesKt.*
@@ -24,10 +25,6 @@
id('com.android.library')
}
-configurations {
- jarjarConf
-}
-
android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
@@ -39,36 +36,31 @@
'proguard-android-optimize.txt'),
'proguard-rules.pro'
}
- sourceSets {
- main.java.srcDirs += '../../../../external/icing/java/src/'
- androidTest {
- java.srcDirs += '../../../../external/icing/java/tests/instrumentation'
- }
- }
- lintOptions {
- // TODO(b/160643524): Don't do this. This temporarily disables lint
- // checks that require getters and setters to have the same return
- // and input values, respectively
- disable 'KotlinPropertyAccess'
- }
+}
+
+// Add :icing:java as jarjar dependency
+android.libraryVariants.all { variant ->
+ def variantName = variant.name
+ def suffix = variantName.capitalize()
+ def jarjarConfigName = "jarjar${suffix}"
+ def jarjarConf = configurations.register(jarjarConfigName)
+ // Treat icing-java as a local jar and package it inside the aar.
+ dependencies.add(jarjarConfigName, project.dependencies.project(
+ path: ":icing:java",
+ configuration: jarjarConfigName))
+ dependencies.add("${variantName}Implementation", files(jarjarConf))
}
dependencies {
- // Treat icing-java as a local jar and package it inside the aar.
- jarjarConf project(path: ':icing:java', configuration: 'jarjarConf')
- implementation files(configurations.jarjarConf)
- compileOnly project(path: ':icing:java', configuration: 'jarjarConf')
-
api('androidx.annotation:annotation:1.1.0')
+ implementation project(':icing:nativeLib')
implementation('androidx.collection:collection:1.1.0')
implementation('androidx.concurrent:concurrent-futures:1.0.0')
implementation('androidx.core:core:1.2.0')
- implementation project(':icing:nativeLib')
androidTestAnnotationProcessor project(':appsearch:appsearch-annotation')
androidTestImplementation(ANDROIDX_TEST_CORE)
- androidTestImplementation(ANDROIDX_TEST_EXT_JUNIT)
androidTestImplementation(ANDROIDX_TEST_RULES)
androidTestImplementation(TRUTH)
//TODO(b/149787478) upgrade and link to Dependencies.kt
@@ -90,6 +82,7 @@
name = 'AndroidX AppSearch'
publish = Publish.SNAPSHOT_AND_RELEASE
mavenGroup = LibraryGroups.APPSEARCH
+ mavenVersion = LibraryVersions.APPSEARCH
inceptionYear = '2019'
description = 'AndroidX AppSearch - App Indexing'
}
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/app/AppSearchManagerTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/app/AppSearchManagerTest.java
index 3943f92..048a64a 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/app/AppSearchManagerTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/app/AppSearchManagerTest.java
@@ -781,8 +781,7 @@
Future<AppSearchBatchResult<K, V>> future) throws Exception {
AppSearchBatchResult<K, V> result = future.get();
if (!result.isSuccess()) {
- throw new AssertionFailedError(
- "AppSearchBatchResult not successful: " + result.getFailures());
+ throw new AssertionFailedError("AppSearchBatchResult not successful: " + result);
}
return result;
}
@@ -791,8 +790,7 @@
Future<AppSearchResult<ValueType>> future) throws Exception {
AppSearchResult<ValueType> result = future.get();
if (!result.isSuccess()) {
- throw new AssertionFailedError(
- "AppSearchBatchResult not successful: " + result);
+ throw new AssertionFailedError("AppSearchResult not successful: " + result);
}
return result.getResultValue();
}
diff --git a/appsearch/appsearch/src/main/java/androidx/appsearch/app/AppSearchManager.java b/appsearch/appsearch/src/main/java/androidx/appsearch/app/AppSearchManager.java
index e760af4..490e55e 100644
--- a/appsearch/appsearch/src/main/java/androidx/appsearch/app/AppSearchManager.java
+++ b/appsearch/appsearch/src/main/java/androidx/appsearch/app/AppSearchManager.java
@@ -790,6 +790,6 @@
} else {
resultCode = AppSearchResult.RESULT_UNKNOWN_ERROR;
}
- return newFailedResult(resultCode, t.getMessage());
+ return newFailedResult(resultCode, t.toString());
}
}
diff --git a/biometric/biometric/build.gradle b/biometric/biometric/build.gradle
index aa65293..558d992 100644
--- a/biometric/biometric/build.gradle
+++ b/biometric/biometric/build.gradle
@@ -26,12 +26,12 @@
dependencies {
// Public API dependencies
api("androidx.annotation:annotation:1.1.0")
+ api("androidx.core:core:1.2.0")
api("androidx.fragment:fragment:1.2.5")
// Internal dependencies
implementation("androidx.activity:activity:1.1.0")
implementation("androidx.appcompat:appcompat:1.1.0")
- implementation("androidx.core:core:1.2.0")
implementation("androidx.lifecycle:lifecycle-livedata-core:2.2.0")
implementation("androidx.lifecycle:lifecycle-viewmodel:2.2.0")
@@ -56,10 +56,16 @@
noCompress 'ttf'
}
+ buildTypes.all {
+ consumerProguardFiles 'proguard-rules.pro'
+ }
+
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
+
+ testOptions.unitTests.includeAndroidResources = true
}
androidx {
diff --git a/browser/browser/api/1.3.0-alpha05.txt b/browser/browser/api/1.3.0-alpha05.txt
index 5344700..df79b5a 100644
--- a/browser/browser/api/1.3.0-alpha05.txt
+++ b/browser/browser/api/1.3.0-alpha05.txt
@@ -55,6 +55,7 @@
public final class CustomTabColorSchemeParams {
field @ColorInt public final Integer? navigationBarColor;
+ field @ColorInt public final Integer? navigationBarDividerColor;
field @ColorInt public final Integer? secondaryToolbarColor;
field @ColorInt public final Integer? toolbarColor;
}
@@ -63,6 +64,7 @@
ctor public CustomTabColorSchemeParams.Builder();
method public androidx.browser.customtabs.CustomTabColorSchemeParams build();
method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setNavigationBarColor(@ColorInt int);
+ method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setNavigationBarDividerColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setSecondaryToolbarColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setToolbarColor(@ColorInt int);
}
@@ -114,6 +116,7 @@
field public static final String EXTRA_EXIT_ANIMATION_BUNDLE = "android.support.customtabs.extra.EXIT_ANIMATION_BUNDLE";
field public static final String EXTRA_MENU_ITEMS = "android.support.customtabs.extra.MENU_ITEMS";
field public static final String EXTRA_NAVIGATION_BAR_COLOR = "androidx.browser.customtabs.extra.NAVIGATION_BAR_COLOR";
+ field public static final String EXTRA_NAVIGATION_BAR_DIVIDER_COLOR = "androidx.browser.customtabs.extra.NAVIGATION_BAR_DIVIDER_COLOR";
field public static final String EXTRA_REMOTEVIEWS = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS";
field public static final String EXTRA_REMOTEVIEWS_CLICKED_ID = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_CLICKED_ID";
field public static final String EXTRA_REMOTEVIEWS_PENDINGINTENT = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_PENDINGINTENT";
@@ -153,6 +156,7 @@
method public androidx.browser.customtabs.CustomTabsIntent.Builder setExitAnimations(android.content.Context, @AnimRes int, @AnimRes int);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setInstantAppsEnabled(boolean);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setNavigationBarColor(@ColorInt int);
+ method public androidx.browser.customtabs.CustomTabsIntent.Builder setNavigationBarDividerColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setSecondaryToolbarColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setSecondaryToolbarViews(android.widget.RemoteViews, int[]?, android.app.PendingIntent?);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setSession(androidx.browser.customtabs.CustomTabsSession);
@@ -307,6 +311,7 @@
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setColorSchemeParams(int, androidx.browser.customtabs.CustomTabColorSchemeParams);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setDisplayMode(androidx.browser.trusted.TrustedWebActivityDisplayMode);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setNavigationBarColor(@ColorInt int);
+ method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setNavigationBarDividerColor(@ColorInt int);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setShareParams(androidx.browser.trusted.sharing.ShareTarget, androidx.browser.trusted.sharing.ShareData);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setSplashScreenParams(android.os.Bundle);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setToolbarColor(@ColorInt int);
diff --git a/browser/browser/api/api_lint.ignore b/browser/browser/api/api_lint.ignore
index 0a088b5..6a0ba47 100644
--- a/browser/browser/api/api_lint.ignore
+++ b/browser/browser/api/api_lint.ignore
@@ -51,6 +51,8 @@
AutoBoxing: androidx.browser.customtabs.CustomTabColorSchemeParams#navigationBarColor:
Must avoid boxed primitives (`java.lang.Integer`)
+AutoBoxing: androidx.browser.customtabs.CustomTabColorSchemeParams#navigationBarDividerColor:
+ Must avoid boxed primitives (`java.lang.Integer`)
AutoBoxing: androidx.browser.customtabs.CustomTabColorSchemeParams#secondaryToolbarColor:
Must avoid boxed primitives (`java.lang.Integer`)
AutoBoxing: androidx.browser.customtabs.CustomTabColorSchemeParams#toolbarColor:
diff --git a/browser/browser/api/current.txt b/browser/browser/api/current.txt
index 5344700..df79b5a 100644
--- a/browser/browser/api/current.txt
+++ b/browser/browser/api/current.txt
@@ -55,6 +55,7 @@
public final class CustomTabColorSchemeParams {
field @ColorInt public final Integer? navigationBarColor;
+ field @ColorInt public final Integer? navigationBarDividerColor;
field @ColorInt public final Integer? secondaryToolbarColor;
field @ColorInt public final Integer? toolbarColor;
}
@@ -63,6 +64,7 @@
ctor public CustomTabColorSchemeParams.Builder();
method public androidx.browser.customtabs.CustomTabColorSchemeParams build();
method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setNavigationBarColor(@ColorInt int);
+ method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setNavigationBarDividerColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setSecondaryToolbarColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setToolbarColor(@ColorInt int);
}
@@ -114,6 +116,7 @@
field public static final String EXTRA_EXIT_ANIMATION_BUNDLE = "android.support.customtabs.extra.EXIT_ANIMATION_BUNDLE";
field public static final String EXTRA_MENU_ITEMS = "android.support.customtabs.extra.MENU_ITEMS";
field public static final String EXTRA_NAVIGATION_BAR_COLOR = "androidx.browser.customtabs.extra.NAVIGATION_BAR_COLOR";
+ field public static final String EXTRA_NAVIGATION_BAR_DIVIDER_COLOR = "androidx.browser.customtabs.extra.NAVIGATION_BAR_DIVIDER_COLOR";
field public static final String EXTRA_REMOTEVIEWS = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS";
field public static final String EXTRA_REMOTEVIEWS_CLICKED_ID = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_CLICKED_ID";
field public static final String EXTRA_REMOTEVIEWS_PENDINGINTENT = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_PENDINGINTENT";
@@ -153,6 +156,7 @@
method public androidx.browser.customtabs.CustomTabsIntent.Builder setExitAnimations(android.content.Context, @AnimRes int, @AnimRes int);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setInstantAppsEnabled(boolean);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setNavigationBarColor(@ColorInt int);
+ method public androidx.browser.customtabs.CustomTabsIntent.Builder setNavigationBarDividerColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setSecondaryToolbarColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setSecondaryToolbarViews(android.widget.RemoteViews, int[]?, android.app.PendingIntent?);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setSession(androidx.browser.customtabs.CustomTabsSession);
@@ -307,6 +311,7 @@
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setColorSchemeParams(int, androidx.browser.customtabs.CustomTabColorSchemeParams);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setDisplayMode(androidx.browser.trusted.TrustedWebActivityDisplayMode);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setNavigationBarColor(@ColorInt int);
+ method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setNavigationBarDividerColor(@ColorInt int);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setShareParams(androidx.browser.trusted.sharing.ShareTarget, androidx.browser.trusted.sharing.ShareData);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setSplashScreenParams(android.os.Bundle);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setToolbarColor(@ColorInt int);
diff --git a/browser/browser/api/public_plus_experimental_1.3.0-alpha05.txt b/browser/browser/api/public_plus_experimental_1.3.0-alpha05.txt
index 5344700..df79b5a 100644
--- a/browser/browser/api/public_plus_experimental_1.3.0-alpha05.txt
+++ b/browser/browser/api/public_plus_experimental_1.3.0-alpha05.txt
@@ -55,6 +55,7 @@
public final class CustomTabColorSchemeParams {
field @ColorInt public final Integer? navigationBarColor;
+ field @ColorInt public final Integer? navigationBarDividerColor;
field @ColorInt public final Integer? secondaryToolbarColor;
field @ColorInt public final Integer? toolbarColor;
}
@@ -63,6 +64,7 @@
ctor public CustomTabColorSchemeParams.Builder();
method public androidx.browser.customtabs.CustomTabColorSchemeParams build();
method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setNavigationBarColor(@ColorInt int);
+ method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setNavigationBarDividerColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setSecondaryToolbarColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setToolbarColor(@ColorInt int);
}
@@ -114,6 +116,7 @@
field public static final String EXTRA_EXIT_ANIMATION_BUNDLE = "android.support.customtabs.extra.EXIT_ANIMATION_BUNDLE";
field public static final String EXTRA_MENU_ITEMS = "android.support.customtabs.extra.MENU_ITEMS";
field public static final String EXTRA_NAVIGATION_BAR_COLOR = "androidx.browser.customtabs.extra.NAVIGATION_BAR_COLOR";
+ field public static final String EXTRA_NAVIGATION_BAR_DIVIDER_COLOR = "androidx.browser.customtabs.extra.NAVIGATION_BAR_DIVIDER_COLOR";
field public static final String EXTRA_REMOTEVIEWS = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS";
field public static final String EXTRA_REMOTEVIEWS_CLICKED_ID = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_CLICKED_ID";
field public static final String EXTRA_REMOTEVIEWS_PENDINGINTENT = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_PENDINGINTENT";
@@ -153,6 +156,7 @@
method public androidx.browser.customtabs.CustomTabsIntent.Builder setExitAnimations(android.content.Context, @AnimRes int, @AnimRes int);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setInstantAppsEnabled(boolean);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setNavigationBarColor(@ColorInt int);
+ method public androidx.browser.customtabs.CustomTabsIntent.Builder setNavigationBarDividerColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setSecondaryToolbarColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setSecondaryToolbarViews(android.widget.RemoteViews, int[]?, android.app.PendingIntent?);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setSession(androidx.browser.customtabs.CustomTabsSession);
@@ -307,6 +311,7 @@
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setColorSchemeParams(int, androidx.browser.customtabs.CustomTabColorSchemeParams);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setDisplayMode(androidx.browser.trusted.TrustedWebActivityDisplayMode);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setNavigationBarColor(@ColorInt int);
+ method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setNavigationBarDividerColor(@ColorInt int);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setShareParams(androidx.browser.trusted.sharing.ShareTarget, androidx.browser.trusted.sharing.ShareData);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setSplashScreenParams(android.os.Bundle);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setToolbarColor(@ColorInt int);
diff --git a/browser/browser/api/public_plus_experimental_current.txt b/browser/browser/api/public_plus_experimental_current.txt
index 5344700..df79b5a 100644
--- a/browser/browser/api/public_plus_experimental_current.txt
+++ b/browser/browser/api/public_plus_experimental_current.txt
@@ -55,6 +55,7 @@
public final class CustomTabColorSchemeParams {
field @ColorInt public final Integer? navigationBarColor;
+ field @ColorInt public final Integer? navigationBarDividerColor;
field @ColorInt public final Integer? secondaryToolbarColor;
field @ColorInt public final Integer? toolbarColor;
}
@@ -63,6 +64,7 @@
ctor public CustomTabColorSchemeParams.Builder();
method public androidx.browser.customtabs.CustomTabColorSchemeParams build();
method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setNavigationBarColor(@ColorInt int);
+ method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setNavigationBarDividerColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setSecondaryToolbarColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setToolbarColor(@ColorInt int);
}
@@ -114,6 +116,7 @@
field public static final String EXTRA_EXIT_ANIMATION_BUNDLE = "android.support.customtabs.extra.EXIT_ANIMATION_BUNDLE";
field public static final String EXTRA_MENU_ITEMS = "android.support.customtabs.extra.MENU_ITEMS";
field public static final String EXTRA_NAVIGATION_BAR_COLOR = "androidx.browser.customtabs.extra.NAVIGATION_BAR_COLOR";
+ field public static final String EXTRA_NAVIGATION_BAR_DIVIDER_COLOR = "androidx.browser.customtabs.extra.NAVIGATION_BAR_DIVIDER_COLOR";
field public static final String EXTRA_REMOTEVIEWS = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS";
field public static final String EXTRA_REMOTEVIEWS_CLICKED_ID = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_CLICKED_ID";
field public static final String EXTRA_REMOTEVIEWS_PENDINGINTENT = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_PENDINGINTENT";
@@ -153,6 +156,7 @@
method public androidx.browser.customtabs.CustomTabsIntent.Builder setExitAnimations(android.content.Context, @AnimRes int, @AnimRes int);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setInstantAppsEnabled(boolean);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setNavigationBarColor(@ColorInt int);
+ method public androidx.browser.customtabs.CustomTabsIntent.Builder setNavigationBarDividerColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setSecondaryToolbarColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setSecondaryToolbarViews(android.widget.RemoteViews, int[]?, android.app.PendingIntent?);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setSession(androidx.browser.customtabs.CustomTabsSession);
@@ -307,6 +311,7 @@
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setColorSchemeParams(int, androidx.browser.customtabs.CustomTabColorSchemeParams);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setDisplayMode(androidx.browser.trusted.TrustedWebActivityDisplayMode);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setNavigationBarColor(@ColorInt int);
+ method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setNavigationBarDividerColor(@ColorInt int);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setShareParams(androidx.browser.trusted.sharing.ShareTarget, androidx.browser.trusted.sharing.ShareData);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setSplashScreenParams(android.os.Bundle);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setToolbarColor(@ColorInt int);
diff --git a/browser/browser/api/restricted_1.3.0-alpha05.txt b/browser/browser/api/restricted_1.3.0-alpha05.txt
index 2c7d35c..1504743 100644
--- a/browser/browser/api/restricted_1.3.0-alpha05.txt
+++ b/browser/browser/api/restricted_1.3.0-alpha05.txt
@@ -66,6 +66,7 @@
public final class CustomTabColorSchemeParams {
field @ColorInt public final Integer? navigationBarColor;
+ field @ColorInt public final Integer? navigationBarDividerColor;
field @ColorInt public final Integer? secondaryToolbarColor;
field @ColorInt public final Integer? toolbarColor;
}
@@ -74,6 +75,7 @@
ctor public CustomTabColorSchemeParams.Builder();
method public androidx.browser.customtabs.CustomTabColorSchemeParams build();
method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setNavigationBarColor(@ColorInt int);
+ method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setNavigationBarDividerColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setSecondaryToolbarColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setToolbarColor(@ColorInt int);
}
@@ -125,6 +127,7 @@
field public static final String EXTRA_EXIT_ANIMATION_BUNDLE = "android.support.customtabs.extra.EXIT_ANIMATION_BUNDLE";
field public static final String EXTRA_MENU_ITEMS = "android.support.customtabs.extra.MENU_ITEMS";
field public static final String EXTRA_NAVIGATION_BAR_COLOR = "androidx.browser.customtabs.extra.NAVIGATION_BAR_COLOR";
+ field public static final String EXTRA_NAVIGATION_BAR_DIVIDER_COLOR = "androidx.browser.customtabs.extra.NAVIGATION_BAR_DIVIDER_COLOR";
field public static final String EXTRA_REMOTEVIEWS = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS";
field public static final String EXTRA_REMOTEVIEWS_CLICKED_ID = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_CLICKED_ID";
field public static final String EXTRA_REMOTEVIEWS_PENDINGINTENT = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_PENDINGINTENT";
@@ -164,6 +167,7 @@
method public androidx.browser.customtabs.CustomTabsIntent.Builder setExitAnimations(android.content.Context, @AnimRes int, @AnimRes int);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setInstantAppsEnabled(boolean);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setNavigationBarColor(@ColorInt int);
+ method public androidx.browser.customtabs.CustomTabsIntent.Builder setNavigationBarDividerColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setSecondaryToolbarColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setSecondaryToolbarViews(android.widget.RemoteViews, int[]?, android.app.PendingIntent?);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setSession(androidx.browser.customtabs.CustomTabsSession);
@@ -318,6 +322,7 @@
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setColorSchemeParams(int, androidx.browser.customtabs.CustomTabColorSchemeParams);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setDisplayMode(androidx.browser.trusted.TrustedWebActivityDisplayMode);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setNavigationBarColor(@ColorInt int);
+ method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setNavigationBarDividerColor(@ColorInt int);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setShareParams(androidx.browser.trusted.sharing.ShareTarget, androidx.browser.trusted.sharing.ShareData);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setSplashScreenParams(android.os.Bundle);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setToolbarColor(@ColorInt int);
diff --git a/browser/browser/api/restricted_current.txt b/browser/browser/api/restricted_current.txt
index 2c7d35c..1504743 100644
--- a/browser/browser/api/restricted_current.txt
+++ b/browser/browser/api/restricted_current.txt
@@ -66,6 +66,7 @@
public final class CustomTabColorSchemeParams {
field @ColorInt public final Integer? navigationBarColor;
+ field @ColorInt public final Integer? navigationBarDividerColor;
field @ColorInt public final Integer? secondaryToolbarColor;
field @ColorInt public final Integer? toolbarColor;
}
@@ -74,6 +75,7 @@
ctor public CustomTabColorSchemeParams.Builder();
method public androidx.browser.customtabs.CustomTabColorSchemeParams build();
method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setNavigationBarColor(@ColorInt int);
+ method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setNavigationBarDividerColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setSecondaryToolbarColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabColorSchemeParams.Builder setToolbarColor(@ColorInt int);
}
@@ -125,6 +127,7 @@
field public static final String EXTRA_EXIT_ANIMATION_BUNDLE = "android.support.customtabs.extra.EXIT_ANIMATION_BUNDLE";
field public static final String EXTRA_MENU_ITEMS = "android.support.customtabs.extra.MENU_ITEMS";
field public static final String EXTRA_NAVIGATION_BAR_COLOR = "androidx.browser.customtabs.extra.NAVIGATION_BAR_COLOR";
+ field public static final String EXTRA_NAVIGATION_BAR_DIVIDER_COLOR = "androidx.browser.customtabs.extra.NAVIGATION_BAR_DIVIDER_COLOR";
field public static final String EXTRA_REMOTEVIEWS = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS";
field public static final String EXTRA_REMOTEVIEWS_CLICKED_ID = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_CLICKED_ID";
field public static final String EXTRA_REMOTEVIEWS_PENDINGINTENT = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_PENDINGINTENT";
@@ -164,6 +167,7 @@
method public androidx.browser.customtabs.CustomTabsIntent.Builder setExitAnimations(android.content.Context, @AnimRes int, @AnimRes int);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setInstantAppsEnabled(boolean);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setNavigationBarColor(@ColorInt int);
+ method public androidx.browser.customtabs.CustomTabsIntent.Builder setNavigationBarDividerColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setSecondaryToolbarColor(@ColorInt int);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setSecondaryToolbarViews(android.widget.RemoteViews, int[]?, android.app.PendingIntent?);
method public androidx.browser.customtabs.CustomTabsIntent.Builder setSession(androidx.browser.customtabs.CustomTabsSession);
@@ -318,6 +322,7 @@
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setColorSchemeParams(int, androidx.browser.customtabs.CustomTabColorSchemeParams);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setDisplayMode(androidx.browser.trusted.TrustedWebActivityDisplayMode);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setNavigationBarColor(@ColorInt int);
+ method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setNavigationBarDividerColor(@ColorInt int);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setShareParams(androidx.browser.trusted.sharing.ShareTarget, androidx.browser.trusted.sharing.ShareData);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setSplashScreenParams(android.os.Bundle);
method public androidx.browser.trusted.TrustedWebActivityIntentBuilder setToolbarColor(@ColorInt int);
diff --git a/browser/browser/src/main/java/androidx/browser/customtabs/CustomTabColorSchemeParams.java b/browser/browser/src/main/java/androidx/browser/customtabs/CustomTabColorSchemeParams.java
index 10ee69b..5c9f0a9 100644
--- a/browser/browser/src/main/java/androidx/browser/customtabs/CustomTabColorSchemeParams.java
+++ b/browser/browser/src/main/java/androidx/browser/customtabs/CustomTabColorSchemeParams.java
@@ -17,6 +17,7 @@
package androidx.browser.customtabs;
import static androidx.browser.customtabs.CustomTabsIntent.EXTRA_NAVIGATION_BAR_COLOR;
+import static androidx.browser.customtabs.CustomTabsIntent.EXTRA_NAVIGATION_BAR_DIVIDER_COLOR;
import static androidx.browser.customtabs.CustomTabsIntent.EXTRA_SECONDARY_TOOLBAR_COLOR;
import static androidx.browser.customtabs.CustomTabsIntent.EXTRA_TOOLBAR_COLOR;
@@ -47,14 +48,21 @@
*/
@Nullable @ColorInt public final Integer navigationBarColor;
+ /**
+ * Navigation bar color. See {@link CustomTabsIntent.Builder#setNavigationBarDividerColor(int)}.
+ */
+ @Nullable @ColorInt public final Integer navigationBarDividerColor;
+
@SuppressWarnings("WeakerAccess") /* synthetic access */
CustomTabColorSchemeParams(
@Nullable @ColorInt Integer toolbarColor,
@Nullable @ColorInt Integer secondaryToolbarColor,
- @Nullable @ColorInt Integer navigationBarColor) {
+ @Nullable @ColorInt Integer navigationBarColor,
+ @Nullable @ColorInt Integer navigationBarDividerColor) {
this.toolbarColor = toolbarColor;
this.secondaryToolbarColor = secondaryToolbarColor;
this.navigationBarColor = navigationBarColor;
+ this.navigationBarDividerColor = navigationBarDividerColor;
}
/**
@@ -74,6 +82,9 @@
if (navigationBarColor != null) {
bundle.putInt(EXTRA_NAVIGATION_BAR_COLOR, navigationBarColor);
}
+ if (navigationBarDividerColor != null) {
+ bundle.putInt(EXTRA_NAVIGATION_BAR_DIVIDER_COLOR, navigationBarDividerColor);
+ }
return bundle;
}
@@ -91,7 +102,8 @@
return new CustomTabColorSchemeParams(
(Integer) bundle.get(EXTRA_TOOLBAR_COLOR),
(Integer) bundle.get(EXTRA_SECONDARY_TOOLBAR_COLOR),
- (Integer) bundle.get(EXTRA_NAVIGATION_BAR_COLOR));
+ (Integer) bundle.get(EXTRA_NAVIGATION_BAR_COLOR),
+ (Integer) bundle.get(EXTRA_NAVIGATION_BAR_DIVIDER_COLOR));
}
/**
@@ -103,7 +115,9 @@
toolbarColor == null ? defaults.toolbarColor : toolbarColor,
secondaryToolbarColor == null ? defaults.secondaryToolbarColor
: secondaryToolbarColor,
- navigationBarColor == null ? defaults.navigationBarColor : navigationBarColor);
+ navigationBarColor == null ? defaults.navigationBarColor : navigationBarColor,
+ navigationBarDividerColor == null ? defaults.navigationBarDividerColor
+ : navigationBarDividerColor);
}
/**
@@ -115,6 +129,7 @@
@Nullable @ColorInt private Integer mToolbarColor;
@Nullable @ColorInt private Integer mSecondaryToolbarColor;
@Nullable @ColorInt private Integer mNavigationBarColor;
+ @Nullable @ColorInt private Integer mNavigationBarDividerColor;
/**
* @see CustomTabsIntent.Builder#setToolbarColor(int)
@@ -144,13 +159,22 @@
}
/**
+ * @see CustomTabsIntent.Builder#setNavigationBarDividerColor(int)
+ */
+ @NonNull
+ public Builder setNavigationBarDividerColor(@ColorInt int color) {
+ mNavigationBarDividerColor = color;
+ return this;
+ }
+
+ /**
* Combines all the options that have been into a {@link CustomTabColorSchemeParams}
* object.
*/
@NonNull
public CustomTabColorSchemeParams build() {
return new CustomTabColorSchemeParams(mToolbarColor, mSecondaryToolbarColor,
- mNavigationBarColor);
+ mNavigationBarColor, mNavigationBarDividerColor);
}
}
}
diff --git a/browser/browser/src/main/java/androidx/browser/customtabs/CustomTabsClient.java b/browser/browser/src/main/java/androidx/browser/customtabs/CustomTabsClient.java
index e37a841..03a6892 100644
--- a/browser/browser/src/main/java/androidx/browser/customtabs/CustomTabsClient.java
+++ b/browser/browser/src/main/java/androidx/browser/customtabs/CustomTabsClient.java
@@ -161,7 +161,7 @@
if (pm.resolveService(serviceIntent, 0) != null) return packageName;
}
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ if (Build.VERSION.SDK_INT >= 30) {
Log.w(TAG, "Unable to find any Custom Tabs packages, you may need to add a "
+ "<queries> element to your manifest. See the docs for "
+ "CustomTabsClient#getPackageName.");
diff --git a/browser/browser/src/main/java/androidx/browser/customtabs/CustomTabsIntent.java b/browser/browser/src/main/java/androidx/browser/customtabs/CustomTabsIntent.java
index 4ff330f..2e662e6 100644
--- a/browser/browser/src/main/java/androidx/browser/customtabs/CustomTabsIntent.java
+++ b/browser/browser/src/main/java/androidx/browser/customtabs/CustomTabsIntent.java
@@ -296,6 +296,13 @@
"androidx.browser.customtabs.extra.NAVIGATION_BAR_COLOR";
/**
+ * Extra that contains the color of the navigation bar divider.
+ * See {@link Builder#setNavigationBarDividerColor}.
+ */
+ public static final String EXTRA_NAVIGATION_BAR_DIVIDER_COLOR =
+ "androidx.browser.customtabs.extra.NAVIGATION_BAR_DIVIDER_COLOR";
+
+ /**
* Key that specifies the unique ID for an action button. To make a button to show on the
* toolbar, use {@link #TOOLBAR_ACTION_BUTTON_ID} as its ID.
*/
@@ -617,6 +624,19 @@
}
/**
+ * Sets the navigation bar divider color. Has no effect on API versions below P.
+ *
+ * Can be overridden for particular color schemes, see {@link #setColorSchemeParams}.
+ *
+ * @param color The color for the navigation bar divider.
+ */
+ @NonNull
+ public Builder setNavigationBarDividerColor(@ColorInt int color) {
+ mDefaultColorSchemeBuilder.setNavigationBarDividerColor(color);
+ return this;
+ }
+
+ /**
* Sets the remote views displayed in the secondary toolbar in a custom tab.
*
* @param remoteViews The {@link RemoteViews} that will be shown on the secondary toolbar.
diff --git a/browser/browser/src/main/java/androidx/browser/trusted/TrustedWebActivityIntentBuilder.java b/browser/browser/src/main/java/androidx/browser/trusted/TrustedWebActivityIntentBuilder.java
index 354c098..f0ca580 100644
--- a/browser/browser/src/main/java/androidx/browser/trusted/TrustedWebActivityIntentBuilder.java
+++ b/browser/browser/src/main/java/androidx/browser/trusted/TrustedWebActivityIntentBuilder.java
@@ -116,6 +116,16 @@
}
/**
+ * Sets the navigation bar divider color, see
+ * {@link CustomTabsIntent.Builder#setNavigationBarDividerColor}.
+ */
+ @NonNull
+ public TrustedWebActivityIntentBuilder setNavigationBarDividerColor(@ColorInt int color) {
+ mIntentBuilder.setNavigationBarDividerColor(color);
+ return this;
+ }
+
+ /**
* Sets the color scheme, see {@link CustomTabsIntent.Builder#setColorScheme}.
* In Trusted Web Activities color scheme may effect such UI elements as info bars and context
* menus.
diff --git a/browser/browser/src/test/java/androidx/browser/customtabs/CustomTabColorSchemeParamsTest.java b/browser/browser/src/test/java/androidx/browser/customtabs/CustomTabColorSchemeParamsTest.java
index d7cd6fa..f7eec06 100644
--- a/browser/browser/src/test/java/androidx/browser/customtabs/CustomTabColorSchemeParamsTest.java
+++ b/browser/browser/src/test/java/androidx/browser/customtabs/CustomTabColorSchemeParamsTest.java
@@ -50,18 +50,21 @@
.setToolbarColor(0x0000ff)
.setSecondaryToolbarColor(0x00aaff)
.setNavigationBarColor(0xaabbcc)
+ .setNavigationBarDividerColor(0x00ff00)
.build();
CustomTabColorSchemeParams darkParams = new CustomTabColorSchemeParams.Builder()
.setToolbarColor(0xff0000)
.setSecondaryToolbarColor(0xff8800)
.setNavigationBarColor(0x112233)
+ .setNavigationBarDividerColor(0xff00ff)
.build();
Intent intent = new CustomTabsIntent.Builder()
.setToolbarColor(0xaaaaaa) // These colors should get overridden.
.setSecondaryToolbarColor(0x555555)
.setNavigationBarColor(0x111111)
+ .setNavigationBarDividerColor(0xdddddd)
.setColorSchemeParams(COLOR_SCHEME_LIGHT, lightParams)
.setColorSchemeParams(COLOR_SCHEME_DARK, darkParams)
.build()
@@ -86,17 +89,20 @@
int defaultToolbarColor = 0x0000ff;
int defaultSecondaryToolbarColor = 0x00aaff;
int defaultNavigationBarColor = 0xaabbcc;
+ int defaultNavigationBarDividerColor = 0xdddddd;
CustomTabColorSchemeParams darkParams = new CustomTabColorSchemeParams.Builder()
.setToolbarColor(0xff0000)
.setSecondaryToolbarColor(0xff8800)
.setNavigationBarColor(0x112233)
+ .setNavigationBarDividerColor(0xff00ff)
.build();
Intent intent = new CustomTabsIntent.Builder()
.setToolbarColor(defaultToolbarColor)
.setSecondaryToolbarColor(defaultSecondaryToolbarColor)
.setNavigationBarColor(defaultNavigationBarColor)
+ .setNavigationBarDividerColor(defaultNavigationBarDividerColor)
.setColorSchemeParams(COLOR_SCHEME_DARK, darkParams)
.build()
.intent;
@@ -111,6 +117,7 @@
.setToolbarColor(defaultToolbarColor)
.setSecondaryToolbarColor(defaultSecondaryToolbarColor)
.setNavigationBarColor(defaultNavigationBarColor)
+ .setNavigationBarDividerColor(defaultNavigationBarDividerColor)
.build();
assertSchemeParamsEqual(expectedLightParams, lightParamsFromIntent);
diff --git a/browser/browser/src/test/java/androidx/browser/customtabs/CustomTabsIntentTest.java b/browser/browser/src/test/java/androidx/browser/customtabs/CustomTabsIntentTest.java
index e8a9654..6415e02 100644
--- a/browser/browser/src/test/java/androidx/browser/customtabs/CustomTabsIntentTest.java
+++ b/browser/browser/src/test/java/androidx/browser/customtabs/CustomTabsIntentTest.java
@@ -68,6 +68,16 @@
}
@Test
+ public void testNavBarDividerColor() {
+ int color = Color.RED;
+ Intent intent = new CustomTabsIntent.Builder()
+ .setNavigationBarDividerColor(color).build().intent;
+ assertTrue(intent.hasExtra(CustomTabsIntent.EXTRA_NAVIGATION_BAR_DIVIDER_COLOR));
+ assertEquals(color, intent.getIntExtra(CustomTabsIntent.EXTRA_NAVIGATION_BAR_DIVIDER_COLOR,
+ 0));
+ }
+
+ @Test
public void testToolbarColorIsNotAResource() {
@ColorRes int colorId = android.R.color.background_dark;
int color = ApplicationProvider.getApplicationContext().getResources().getColor(colorId);
diff --git a/browser/browser/src/test/java/androidx/browser/trusted/TrustedWebActivityIntentBuilderTest.java b/browser/browser/src/test/java/androidx/browser/trusted/TrustedWebActivityIntentBuilderTest.java
index a9537fa..003865d 100644
--- a/browser/browser/src/test/java/androidx/browser/trusted/TrustedWebActivityIntentBuilderTest.java
+++ b/browser/browser/src/test/java/androidx/browser/trusted/TrustedWebActivityIntentBuilderTest.java
@@ -63,6 +63,7 @@
Uri url = Uri.parse("https://test.com/page");
int toolbarColor = 0xffaabbcc;
int navigationBarColor = 0xffccaabb;
+ int navigationBarDividerColor = 0xffdddddd;
List<String> additionalTrustedOrigins =
Arrays.asList("https://m.test.com", "https://test.org");
@@ -84,6 +85,7 @@
Intent intent = new TrustedWebActivityIntentBuilder(url)
.setToolbarColor(toolbarColor)
.setNavigationBarColor(navigationBarColor)
+ .setNavigationBarDividerColor(navigationBarDividerColor)
.setColorScheme(COLOR_SCHEME_DARK)
.setColorSchemeParams(COLOR_SCHEME_DARK, colorSchemeParams)
.setAdditionalTrustedOrigins(additionalTrustedOrigins)
@@ -99,10 +101,12 @@
assertEquals(toolbarColor, intent.getIntExtra(CustomTabsIntent.EXTRA_TOOLBAR_COLOR, 0));
assertEquals(navigationBarColor, intent.getIntExtra(
CustomTabsIntent.EXTRA_NAVIGATION_BAR_COLOR, 0));
+ assertEquals(navigationBarDividerColor, intent.getIntExtra(
+ CustomTabsIntent.EXTRA_NAVIGATION_BAR_DIVIDER_COLOR, 0));
assertEquals(additionalTrustedOrigins, intent.getStringArrayListExtra(
TrustedWebActivityIntentBuilder.EXTRA_ADDITIONAL_TRUSTED_ORIGINS));
- assertEquals(COLOR_SCHEME_DARK, intent.getIntExtra(CustomTabsIntent.EXTRA_COLOR_SCHEME,
- -1));
+ assertEquals(COLOR_SCHEME_DARK, intent.getIntExtra(
+ CustomTabsIntent.EXTRA_COLOR_SCHEME, -1));
assertEquals(colorSchemeParams.toolbarColor,
CustomTabsIntent.getColorSchemeParams(intent, COLOR_SCHEME_DARK).toolbarColor);
diff --git a/buildSrc/src/main/kotlin/androidx/build/AndroidXExtension.kt b/buildSrc/src/main/kotlin/androidx/build/AndroidXExtension.kt
index 051a48d..75e6c63 100644
--- a/buildSrc/src/main/kotlin/androidx/build/AndroidXExtension.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/AndroidXExtension.kt
@@ -86,7 +86,7 @@
// add per-project overrides here
// for example
// the following project is intended to be accessed from Java
- // ":ui:ui-internal-lint-checks" -> return true
+ // ":compose:internal-lint-checks" -> return true
// the following project is not intended to be accessed from Java
// ":annotation:annotation" -> return false
}
diff --git a/buildSrc/src/main/kotlin/androidx/build/AndroidXUiPlugin.kt b/buildSrc/src/main/kotlin/androidx/build/AndroidXUiPlugin.kt
index 510ad0a..d113801 100644
--- a/buildSrc/src/main/kotlin/androidx/build/AndroidXUiPlugin.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/AndroidXUiPlugin.kt
@@ -52,7 +52,7 @@
project.dependencies.add(
"lintChecks",
project.dependencies.project(mapOf(
- "path" to ":ui:ui-internal-lint-checks", "configuration" to "shadow"
+ "path" to ":compose:internal-lint-checks", "configuration" to "shadow"
))
)
diff --git a/buildSrc/src/main/kotlin/androidx/build/LibraryGroups.kt b/buildSrc/src/main/kotlin/androidx/build/LibraryGroups.kt
index b6d7479..e5215b9 100644
--- a/buildSrc/src/main/kotlin/androidx/build/LibraryGroups.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/LibraryGroups.kt
@@ -97,7 +97,6 @@
val TRACING = LibraryGroup("androidx.tracing", LibraryVersions.TRACING)
val TRANSITION = LibraryGroup("androidx.transition", LibraryVersions.TRANSITION)
val TVPROVIDER = LibraryGroup("androidx.tvprovider", LibraryVersions.TVPROVIDER)
- val UI = LibraryGroup("androidx.ui", null)
val VECTORDRAWABLE = LibraryGroup("androidx.vectordrawable", null)
val VERSIONEDPARCELABLE = LibraryGroup("androidx.versionedparcelable", null)
val VIEWPAGER = LibraryGroup("androidx.viewpager", LibraryVersions.VIEWPAGER)
diff --git a/buildSrc/src/main/kotlin/androidx/build/uptodatedness/TaskUpToDateValidator.kt b/buildSrc/src/main/kotlin/androidx/build/uptodatedness/TaskUpToDateValidator.kt
index bad0c9c..ef565da 100644
--- a/buildSrc/src/main/kotlin/androidx/build/uptodatedness/TaskUpToDateValidator.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/uptodatedness/TaskUpToDateValidator.kt
@@ -94,7 +94,10 @@
"unzipDokkaPublicDocsDeps",
"verifyDependencyVersions",
"verifyReleaseResources",
- "zipEcFiles"
+ "zipEcFiles",
+
+ ":camera:integration-tests:camera-testapp-view:mergeLibDexDebug",
+ ":camera:integration-tests:camera-testapp-view:packageDebug"
)
class TaskUpToDateValidator {
companion object {
diff --git a/camera/camera-camera2/build.gradle b/camera/camera-camera2/build.gradle
index 161598a..4edc250 100644
--- a/camera/camera-camera2/build.gradle
+++ b/camera/camera-camera2/build.gradle
@@ -32,6 +32,7 @@
api("androidx.annotation:annotation-experimental:1.0.0-beta01")
implementation("androidx.concurrent:concurrent-futures:1.0.0")
implementation(GUAVA_LISTENABLE_FUTURE)
+ implementation(AUTO_VALUE_ANNOTATIONS)
annotationProcessor(AUTO_VALUE)
diff --git a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/CameraDeviceId.java b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/CameraDeviceId.java
new file mode 100644
index 0000000..4a5b643
--- /dev/null
+++ b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/CameraDeviceId.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * 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 androidx.camera.camera2.internal;
+
+import androidx.annotation.NonNull;
+
+import com.google.auto.value.AutoValue;
+
+/**
+ * Camera device id that is composed by Brand, Device, Model and CameraId.
+ */
+@AutoValue
+abstract class CameraDeviceId {
+ CameraDeviceId() {
+ }
+
+ /**
+ * Creates a new instance of CameraDeviceId with the given parameters.
+ *
+ * <p>Be noticed that all CameraDeviceId related info will be stored in lower case.
+ */
+ @NonNull
+ public static CameraDeviceId create(@NonNull String brand, @NonNull String device,
+ @NonNull String model, @NonNull String cameraId) {
+ return new AutoValue_CameraDeviceId(brand.toLowerCase(), device.toLowerCase(),
+ model.toLowerCase(), cameraId.toLowerCase());
+ }
+
+ /** Returns the brand. */
+ @NonNull
+ public abstract String getBrand();
+
+ /** Returns the device. */
+ @NonNull
+ public abstract String getDevice();
+
+ /** Returns the model. */
+ @NonNull
+ public abstract String getModel();
+
+ /** Returns the camera id. */
+ @NonNull
+ public abstract String getCameraId();
+}
diff --git a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/SupportedSizeConstraints.java b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/SupportedSizeConstraints.java
new file mode 100644
index 0000000..63b8e9a
--- /dev/null
+++ b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/SupportedSizeConstraints.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * 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 androidx.camera.camera2.internal;
+
+import android.graphics.ImageFormat;
+import android.os.Build;
+import android.util.Range;
+import android.util.Size;
+
+import androidx.annotation.NonNull;
+
+import com.google.auto.value.AutoValue;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+/**
+ * Supported sizes constraints.
+ *
+ * <p>All supported sizes related constraints can be added in this class.
+ */
+final class SupportedSizeConstraints {
+ private static final String ALL_MODELS = "allmodels";
+ private static final Range<Integer> ALL_API_LEVELS = new Range<>(0, Integer.MAX_VALUE);
+
+ // The map to store the sizes that need to be excluded from some camera device. The key is
+ // CameraDeviceId composed by Brand, Device, Model, ApiLevel and CameraId. The Model and
+ // ApiLevel are optional. It depends on whether the excluded sizes need to be applied for a
+ // series of devices or for a specific model. And whether the excluded sizes need to be
+ // applied for all API levels or a specific API level.
+ private static final Map<CameraDeviceId, List<ExcludedSizeConstraint>> EXCLUDED_SIZES_MAP;
+
+ // Adds the excluded sizes that need to be excluded from some camera device here.
+ static {
+ EXCLUDED_SIZES_MAP = new TreeMap<>(new Comparator<CameraDeviceId>() {
+ @Override
+ public int compare(CameraDeviceId lhs, CameraDeviceId rhs) {
+ if (lhs.equals(rhs)) {
+ return 0;
+ }
+
+ int cmp = 0;
+
+ // Compares brand
+ if ((cmp = lhs.getBrand().compareTo(rhs.getBrand()))
+ != 0) {
+ return cmp;
+ }
+
+ // Compares device
+ if ((cmp = lhs.getDevice().compareTo(rhs.getDevice()))
+ != 0) {
+ return cmp;
+ }
+
+ // Compares model
+ if (!ALL_MODELS.equals(lhs.getModel()) && !ALL_MODELS.equals(rhs.getModel())
+ && (cmp = lhs.getModel().compareTo(rhs.getModel())) != 0) {
+ return cmp;
+ }
+
+ // Compares camera id
+ if ((cmp = lhs.getCameraId().compareTo(rhs.getCameraId())) != 0) {
+ return cmp;
+ }
+
+ return 0;
+ }
+ });
+
+ EXCLUDED_SIZES_MAP.put(CameraDeviceId.create("OnePlus", "OnePlus6T", ALL_MODELS, "0"),
+ Collections.singletonList(
+ ExcludedSizeConstraint.create(Collections.singleton(ImageFormat.JPEG),
+ ALL_API_LEVELS,
+ Arrays.asList(new Size(4160, 3120), new Size(4000, 3000)))));
+ EXCLUDED_SIZES_MAP.put(CameraDeviceId.create("OnePlus", "OnePlus6", ALL_MODELS, "0"),
+ Collections.singletonList(
+ ExcludedSizeConstraint.create(Collections.singleton(ImageFormat.JPEG),
+ ALL_API_LEVELS,
+ Arrays.asList(new Size(4160, 3120), new Size(4000, 3000)))));
+
+ }
+
+ /**
+ * Gets the sizes that need to be excluded for the camera device and image format.
+ *
+ * @param cameraId The target camera id.
+ * @param imageFormat The target image format.
+ */
+ @NonNull
+ static List<Size> getExcludedSizes(@NonNull String cameraId, int imageFormat) {
+ CameraDeviceId cameraDeviceId = CameraDeviceId.create(Build.BRAND, Build.DEVICE,
+ Build.MODEL, cameraId);
+
+ if (EXCLUDED_SIZES_MAP.containsKey(cameraDeviceId)) {
+ List<Size> excludedSizes = new ArrayList<>();
+ List<ExcludedSizeConstraint> excludedSizeConstraintList =
+ EXCLUDED_SIZES_MAP.get(cameraDeviceId);
+
+ for (ExcludedSizeConstraint constraint : excludedSizeConstraintList) {
+ if (constraint.getAffectedFormats().contains(imageFormat)
+ && constraint.getAffectedApiLevels().contains(Build.VERSION.SDK_INT)) {
+ excludedSizes.addAll(constraint.getExcludedSizes());
+ }
+ }
+
+ return excludedSizes;
+ }
+
+ return Collections.emptyList();
+ }
+
+ private SupportedSizeConstraints() {
+ }
+
+ interface Constraint {
+ Set<Integer> getAffectedFormats();
+ Range<Integer> getAffectedApiLevels();
+ }
+
+ @AutoValue
+ abstract static class ExcludedSizeConstraint implements Constraint {
+ ExcludedSizeConstraint() {
+ }
+
+ @NonNull
+ public static ExcludedSizeConstraint create(Set<Integer> affectedFormats,
+ Range<Integer> affectedApiLevels, List<Size> exclusedSizes) {
+ return new AutoValue_SupportedSizeConstraints_ExcludedSizeConstraint(affectedFormats,
+ affectedApiLevels, exclusedSizes);
+ }
+
+ @Override
+ public abstract Set<Integer> getAffectedFormats();
+
+ @Override
+ public abstract Range<Integer> getAffectedApiLevels();
+
+ public abstract List<Size> getExcludedSizes();
+ }
+}
diff --git a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/SupportedSurfaceCombination.java b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/SupportedSurfaceCombination.java
index 56f8602..ae3a85c 100644
--- a/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/SupportedSurfaceCombination.java
+++ b/camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/SupportedSurfaceCombination.java
@@ -84,6 +84,7 @@
private final CamcorderProfileHelper mCamcorderProfileHelper;
private final CameraCharacteristics mCharacteristics;
private final int mHardwareLevel;
+ private final Map<Integer, List<Size>> mExcludedSizeListCache = new HashMap<>();
private boolean mIsRawSupported = false;
private boolean mIsBurstCaptureSupported = false;
private SurfaceSizeDefinition mSurfaceSizeDefinition;
@@ -687,6 +688,12 @@
"Can not get supported output size for the format: " + imageFormat);
}
+ // Remove sizes that may cause problem.
+ List<Size> excludedSizes = fetchExcludedSizes(imageFormat);
+ List<Size> resultSizesList = new ArrayList<>(Arrays.asList(outputSizes));
+ resultSizesList.removeAll(excludedSizes);
+ outputSizes = resultSizesList.toArray(new Size[0]);
+
// Sort the output sizes. The Comparator result must be reversed to have a descending order
// result.
Arrays.sort(outputSizes, new CompareSizesByArea(true));
@@ -1140,6 +1147,18 @@
return recordSize;
}
+ @NonNull
+ private List<Size> fetchExcludedSizes(int imageFormat) {
+ List<Size> excludedSizes = mExcludedSizeListCache.get(imageFormat);
+
+ if (excludedSizes == null) {
+ excludedSizes = SupportedSizeConstraints.getExcludedSizes(mCameraId, imageFormat);
+ mExcludedSizeListCache.put(imageFormat, excludedSizes);
+ }
+
+ return excludedSizes;
+ }
+
/** Comparator based on area of the given {@link Size} objects. */
static final class CompareSizesByArea implements Comparator<Size> {
private boolean mReverse = false;
diff --git a/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SupportedSizeConstraintsTest.java b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SupportedSizeConstraintsTest.java
new file mode 100644
index 0000000..d747a00
--- /dev/null
+++ b/camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/SupportedSizeConstraintsTest.java
@@ -0,0 +1,247 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * 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 androidx.camera.camera2.internal;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.graphics.ImageFormat;
+import android.hardware.camera2.CameraCharacteristics;
+import android.hardware.camera2.CameraManager;
+import android.os.Build;
+import android.util.Size;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.camera.camera2.Camera2Config;
+import androidx.camera.core.CameraSelector;
+import androidx.camera.core.CameraX;
+import androidx.camera.core.CameraXConfig;
+import androidx.camera.core.impl.ImageFormatConstants;
+import androidx.camera.testing.CameraUtil;
+import androidx.camera.testing.StreamConfigurationMapUtil;
+import androidx.camera.testing.fakes.FakeCamera;
+import androidx.camera.testing.fakes.FakeCameraFactory;
+import androidx.camera.testing.fakes.FakeUseCase;
+import androidx.camera.testing.fakes.FakeUseCaseConfig;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.filters.SmallTest;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.annotation.internal.DoNotInstrument;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowCameraCharacteristics;
+import org.robolectric.shadows.ShadowCameraManager;
+
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+
+import edu.emory.mathcs.backport.java.util.Arrays;
+
+/** Robolectric test for {@link SupportedSizeConstraints} class */
+@SmallTest
+@RunWith(RobolectricTestRunner.class)
+@DoNotInstrument
+@Config(minSdk = Build.VERSION_CODES.LOLLIPOP,
+ maxSdk = Build.VERSION_CODES.P //TODO (b/149669465) : Some robolectric tests will fail on Q
+)
+public class SupportedSizeConstraintsTest {
+ private static final String BACK_CAMERA_ID = "0";
+ private static final int DEFAULT_SENSOR_ORIENTATION = 90;
+ private static final String TEST_BRAND_NAME = "OnePlus";
+ private static final String TEST_DEVICE_NAME = "OnePlus6T";
+ private final CamcorderProfileHelper mMockCamcorderProfileHelper =
+ Mockito.mock(CamcorderProfileHelper.class);
+ /**
+ * Except for ImageFormat.JPEG, ImageFormat.YUV, and ImageFormat.RAW_SENSOR, other image formats
+ * will be mapped to ImageFormat.PRIVATE (0x22) including SurfaceTexture or MediaCodec classes.
+ * Before Android level 23, there is no ImageFormat.PRIVATE. But there is same internal code
+ * 0x22 for internal corresponding format HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED. Therefore,
+ * set 0x22 as default image format.
+ */
+ private final int[] mSupportedFormats =
+ new int[]{
+ ImageFormat.YUV_420_888,
+ ImageFormatConstants.INTERNAL_DEFINED_IMAGE_FORMAT_JPEG,
+ ImageFormatConstants.INTERNAL_DEFINED_IMAGE_FORMAT_PRIVATE
+ };
+
+ private final Size[] mSupportedSizes =
+ new Size[]{
+ new Size(4160, 3120), // will be excluded by some OEM devices for JPEG format.
+ new Size(4032, 3024),
+ new Size(4000, 3000), // will be excluded by some OEM devices for JPEG format.
+ new Size(3840, 2160),
+ new Size(1920, 1440),
+ new Size(1920, 1080),
+ new Size(1280, 960),
+ new Size(1280, 720),
+ new Size(640, 480),
+ new Size(320, 240)
+ };
+
+ private final Context mContext = RuntimeEnvironment.application.getApplicationContext();
+ private FakeCameraFactory mCameraFactory;
+
+ @Before
+ @SuppressWarnings("deprecation") /* defaultDisplay */
+ public void setUp() {
+ when(mMockCamcorderProfileHelper.hasProfile(anyInt(), anyInt())).thenReturn(true);
+ }
+
+ @After
+ public void tearDown() throws ExecutionException, InterruptedException {
+ CameraX.shutdown().get();
+ }
+
+ @Test
+ public void sizesCanBeExcluded() throws Exception {
+ // Mock the environment to simulate a device that some supported sizes will be excluded.
+ Map<Field, Object> fieldSettingsMap = new HashMap<>();
+ fieldSettingsMap.put(Build.class.getField("BRAND"), TEST_BRAND_NAME);
+ fieldSettingsMap.put(Build.class.getField("DEVICE"), TEST_DEVICE_NAME);
+ setFakeBuildEnvironments(fieldSettingsMap);
+
+ // Setup fake camera with supported sizes.
+ setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY, mSupportedSizes,
+ null);
+ SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
+ mContext, BACK_CAMERA_ID, mMockCamcorderProfileHelper);
+
+ List<Size> excludedSizes = Arrays.asList(
+ new Size[]{new Size(4160, 3120), new Size(4000, 3000)});
+
+ // Check the original mSupportedSizes contains the excluded sizes to avoid
+ // mSupportedSizes modified unexpectedly.
+ assertThat(Arrays.asList(mSupportedSizes).containsAll(excludedSizes)).isTrue();
+ // Make the fake use case have JPEG format since those sizes are excluded for JPEG format.
+ FakeUseCase useCase = new FakeUseCaseConfig.Builder().setBufferFormat(
+ ImageFormat.JPEG).build();
+ List<Size> resultList = supportedSurfaceCombination.getSupportedOutputSizes(
+ useCase.getUseCaseConfig());
+
+ for (Size size : excludedSizes) {
+ assertThat(resultList.contains(size)).isFalse();
+ }
+ }
+
+ @Test
+ public void sizesCanBeExcluded_withLowerCaseBrandDeviceName() throws Exception {
+ // Mock the environment to simulate a device that some supported sizes will be excluded.
+ Map<Field, Object> fieldSettingsMap = new HashMap<>();
+ fieldSettingsMap.put(Build.class.getField("BRAND"), TEST_BRAND_NAME.toLowerCase());
+ fieldSettingsMap.put(Build.class.getField("DEVICE"), TEST_DEVICE_NAME.toLowerCase());
+ setFakeBuildEnvironments(fieldSettingsMap);
+
+ // Setup fake camera with supported sizes.
+ setupCamera(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY, mSupportedSizes,
+ null);
+ SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination(
+ mContext, BACK_CAMERA_ID, mMockCamcorderProfileHelper);
+
+ List<Size> excludedSizes = Arrays.asList(
+ new Size[]{new Size(4160, 3120), new Size(4000, 3000)});
+
+ // Check the original mSupportedSizes contains the excluded sizes to avoid
+ // mSupportedSizes modified unexpectedly.
+ assertThat(Arrays.asList(mSupportedSizes).containsAll(excludedSizes)).isTrue();
+ // Make the fake use case have JPEG format since those sizes are excluded for JPEG format.
+ FakeUseCase useCase = new FakeUseCaseConfig.Builder().setBufferFormat(
+ ImageFormat.JPEG).build();
+ List<Size> resultList = supportedSurfaceCombination.getSupportedOutputSizes(
+ useCase.getUseCaseConfig());
+
+ for (Size size : excludedSizes) {
+ assertThat(resultList.contains(size)).isFalse();
+ }
+ }
+
+ static void setFakeBuildEnvironments(@NonNull Map<Field, Object> fieldSettingsMap)
+ throws Exception {
+ for (Field field : fieldSettingsMap.keySet()) {
+ field.setAccessible(true);
+ field.set(null, fieldSettingsMap.get(field));
+ }
+ }
+
+ private void setupCamera(int hardwareLevel, @NonNull Size[] supportedSizes,
+ @Nullable int[] capabilities) {
+ mCameraFactory = new FakeCameraFactory();
+ CameraCharacteristics characteristics =
+ ShadowCameraCharacteristics.newCameraCharacteristics();
+
+ ShadowCameraCharacteristics shadowCharacteristics = Shadow.extract(characteristics);
+ shadowCharacteristics.set(
+ CameraCharacteristics.LENS_FACING, CameraCharacteristics.LENS_FACING_BACK);
+
+ shadowCharacteristics.set(
+ CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL, hardwareLevel);
+
+ shadowCharacteristics.set(
+ CameraCharacteristics.SENSOR_ORIENTATION, DEFAULT_SENSOR_ORIENTATION);
+
+ if (capabilities != null) {
+ shadowCharacteristics.set(
+ CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES, capabilities);
+ }
+
+ CameraManager cameraManager = (CameraManager) ApplicationProvider.getApplicationContext()
+ .getSystemService(Context.CAMERA_SERVICE);
+
+ ((ShadowCameraManager) Shadow.extract(cameraManager))
+ .addCamera(BACK_CAMERA_ID, characteristics);
+
+ int[] supportedFormats = mSupportedFormats;
+
+ shadowCharacteristics.set(
+ CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP,
+ StreamConfigurationMapUtil.generateFakeStreamConfigurationMap(supportedFormats,
+ supportedSizes));
+
+ @CameraSelector.LensFacing int lensFacingEnum = CameraUtil.getLensFacingEnumFromInt(
+ CameraCharacteristics.LENS_FACING_BACK);
+
+ mCameraFactory.insertCamera(lensFacingEnum, BACK_CAMERA_ID,
+ () -> new FakeCamera(BACK_CAMERA_ID, null,
+ new Camera2CameraInfoImpl(BACK_CAMERA_ID, characteristics,
+ mock(Camera2CameraControl.class))));
+
+ initCameraX();
+ }
+
+ private void initCameraX() {
+ CameraXConfig cameraXConfig = CameraXConfig.Builder.fromConfig(
+ Camera2Config.defaultConfig())
+ .setCameraFactoryProvider((ignored0, ignored1) -> mCameraFactory)
+ .build();
+ CameraX.initialize(mContext, cameraXConfig);
+ }
+}
diff --git a/camera/camera-core/src/main/java/androidx/camera/core/internal/CameraUseCaseAdapter.java b/camera/camera-core/src/main/java/androidx/camera/core/internal/CameraUseCaseAdapter.java
index 987f612..a89d2f9 100644
--- a/camera/camera-core/src/main/java/androidx/camera/core/internal/CameraUseCaseAdapter.java
+++ b/camera/camera-core/src/main/java/androidx/camera/core/internal/CameraUseCaseAdapter.java
@@ -242,7 +242,7 @@
@NonNull
public List<UseCase> getUseCases() {
synchronized (mLock) {
- return mUseCases;
+ return new ArrayList<>(mUseCases);
}
}
diff --git a/camera/camera-extensions/src/main/java/androidx/camera/extensions/AutoImageCaptureExtender.java b/camera/camera-extensions/src/main/java/androidx/camera/extensions/AutoImageCaptureExtender.java
index d20f956..a0aee25 100644
--- a/camera/camera-extensions/src/main/java/androidx/camera/extensions/AutoImageCaptureExtender.java
+++ b/camera/camera-extensions/src/main/java/androidx/camera/extensions/AutoImageCaptureExtender.java
@@ -36,7 +36,8 @@
* @param builder Builder that will be used to create the configurations for the
* {@link androidx.camera.core.ImageCapture}.
*/
- public static AutoImageCaptureExtender create(ImageCapture.Builder builder) {
+ @NonNull
+ public static AutoImageCaptureExtender create(@NonNull ImageCapture.Builder builder) {
if (ExtensionVersion.isExtensionVersionSupported()) {
try {
return new VendorAutoImageCaptureExtender(builder);
diff --git a/camera/camera-extensions/src/main/java/androidx/camera/extensions/AutoPreviewExtender.java b/camera/camera-extensions/src/main/java/androidx/camera/extensions/AutoPreviewExtender.java
index 6ec296b..72b7ecc 100644
--- a/camera/camera-extensions/src/main/java/androidx/camera/extensions/AutoPreviewExtender.java
+++ b/camera/camera-extensions/src/main/java/androidx/camera/extensions/AutoPreviewExtender.java
@@ -36,7 +36,8 @@
* @param builder Builder that will be used to create the configurations for the
* {@link androidx.camera.core.Preview}.
*/
- public static AutoPreviewExtender create(Preview.Builder builder) {
+ @NonNull
+ public static AutoPreviewExtender create(@NonNull Preview.Builder builder) {
if (ExtensionVersion.isExtensionVersionSupported()) {
try {
return new VendorAutoPreviewExtender(builder);
diff --git a/camera/camera-extensions/src/main/java/androidx/camera/extensions/BeautyImageCaptureExtender.java b/camera/camera-extensions/src/main/java/androidx/camera/extensions/BeautyImageCaptureExtender.java
index 1b6f321..ed38c59 100644
--- a/camera/camera-extensions/src/main/java/androidx/camera/extensions/BeautyImageCaptureExtender.java
+++ b/camera/camera-extensions/src/main/java/androidx/camera/extensions/BeautyImageCaptureExtender.java
@@ -36,7 +36,8 @@
* @param builder Builder that will be used to create the configurations for the
* {@link androidx.camera.core.ImageCapture}.
*/
- public static BeautyImageCaptureExtender create(ImageCapture.Builder builder) {
+ @NonNull
+ public static BeautyImageCaptureExtender create(@NonNull ImageCapture.Builder builder) {
if (ExtensionVersion.isExtensionVersionSupported()) {
try {
return new VendorBeautyImageCaptureExtender(builder);
diff --git a/camera/camera-extensions/src/main/java/androidx/camera/extensions/BeautyPreviewExtender.java b/camera/camera-extensions/src/main/java/androidx/camera/extensions/BeautyPreviewExtender.java
index dcaff72..f0cf76c 100644
--- a/camera/camera-extensions/src/main/java/androidx/camera/extensions/BeautyPreviewExtender.java
+++ b/camera/camera-extensions/src/main/java/androidx/camera/extensions/BeautyPreviewExtender.java
@@ -36,7 +36,8 @@
* @param builder Builder that will be used to create the configurations for the
* {@link androidx.camera.core.Preview}.
*/
- public static BeautyPreviewExtender create(Preview.Builder builder) {
+ @NonNull
+ public static BeautyPreviewExtender create(@NonNull Preview.Builder builder) {
if (ExtensionVersion.isExtensionVersionSupported()) {
try {
return new VendorBeautyPreviewExtender(builder);
diff --git a/camera/camera-extensions/src/main/java/androidx/camera/extensions/BokehImageCaptureExtender.java b/camera/camera-extensions/src/main/java/androidx/camera/extensions/BokehImageCaptureExtender.java
index a2dfa0f..b5d7e1d 100644
--- a/camera/camera-extensions/src/main/java/androidx/camera/extensions/BokehImageCaptureExtender.java
+++ b/camera/camera-extensions/src/main/java/androidx/camera/extensions/BokehImageCaptureExtender.java
@@ -36,7 +36,8 @@
* @param builder Builder that will be used to create the configurations for the
* {@link androidx.camera.core.ImageCapture}.
*/
- public static BokehImageCaptureExtender create(ImageCapture.Builder builder) {
+ @NonNull
+ public static BokehImageCaptureExtender create(@NonNull ImageCapture.Builder builder) {
if (ExtensionVersion.isExtensionVersionSupported()) {
try {
return new VendorBokehImageCaptureExtender(builder);
diff --git a/camera/camera-extensions/src/main/java/androidx/camera/extensions/BokehPreviewExtender.java b/camera/camera-extensions/src/main/java/androidx/camera/extensions/BokehPreviewExtender.java
index ccf88a0..07f62e5 100644
--- a/camera/camera-extensions/src/main/java/androidx/camera/extensions/BokehPreviewExtender.java
+++ b/camera/camera-extensions/src/main/java/androidx/camera/extensions/BokehPreviewExtender.java
@@ -36,7 +36,8 @@
* @param builder Builder that will be used to create the configurations for the
* {@link androidx.camera.core.Preview}.
*/
- public static BokehPreviewExtender create(Preview.Builder builder) {
+ @NonNull
+ public static BokehPreviewExtender create(@NonNull Preview.Builder builder) {
if (ExtensionVersion.isExtensionVersionSupported()) {
try {
return new VendorBokehPreviewExtender(builder);
diff --git a/camera/camera-extensions/src/main/java/androidx/camera/extensions/ExtensionsManager.java b/camera/camera-extensions/src/main/java/androidx/camera/extensions/ExtensionsManager.java
index c4385e9..dca706a 100644
--- a/camera/camera-extensions/src/main/java/androidx/camera/extensions/ExtensionsManager.java
+++ b/camera/camera-extensions/src/main/java/androidx/camera/extensions/ExtensionsManager.java
@@ -148,7 +148,7 @@
* @param lensFacing The lensFacing of the camera device to be checked.
* @return True if the specific extension function is supported for the camera device.
*/
- public static boolean isExtensionAvailable(EffectMode effectMode,
+ public static boolean isExtensionAvailable(@NonNull EffectMode effectMode,
@CameraSelector.LensFacing int lensFacing) {
boolean isImageCaptureAvailable = checkImageCaptureExtensionCapability(effectMode,
lensFacing);
@@ -171,8 +171,8 @@
* @param lensFacing The lensFacing of the camera device to be checked.
* @return True if the specific extension function is supported for the camera device.
*/
- public static boolean isExtensionAvailable(
- Class<?> klass, EffectMode effectMode, @CameraSelector.LensFacing int lensFacing) {
+ public static boolean isExtensionAvailable(@NonNull Class<?> klass,
+ @NonNull EffectMode effectMode, @CameraSelector.LensFacing int lensFacing) {
boolean isAvailable = false;
if (klass == ImageCapture.class) {
diff --git a/camera/camera-extensions/src/main/java/androidx/camera/extensions/HdrImageCaptureExtender.java b/camera/camera-extensions/src/main/java/androidx/camera/extensions/HdrImageCaptureExtender.java
index ba0c681..52d4a66 100644
--- a/camera/camera-extensions/src/main/java/androidx/camera/extensions/HdrImageCaptureExtender.java
+++ b/camera/camera-extensions/src/main/java/androidx/camera/extensions/HdrImageCaptureExtender.java
@@ -35,7 +35,8 @@
* @param builder Builder that will be used to create the configurations for the
* {@link androidx.camera.core.ImageCapture}.
*/
- public static HdrImageCaptureExtender create(ImageCapture.Builder builder) {
+ @NonNull
+ public static HdrImageCaptureExtender create(@NonNull ImageCapture.Builder builder) {
if (ExtensionVersion.isExtensionVersionSupported()) {
try {
return new VendorHdrImageCaptureExtender(builder);
diff --git a/camera/camera-extensions/src/main/java/androidx/camera/extensions/HdrPreviewExtender.java b/camera/camera-extensions/src/main/java/androidx/camera/extensions/HdrPreviewExtender.java
index cf5be4d..35cac20 100644
--- a/camera/camera-extensions/src/main/java/androidx/camera/extensions/HdrPreviewExtender.java
+++ b/camera/camera-extensions/src/main/java/androidx/camera/extensions/HdrPreviewExtender.java
@@ -36,7 +36,8 @@
* @param builder Builder that will be used to create the configurations for the
* {@link androidx.camera.core.Preview}.
*/
- public static HdrPreviewExtender create(Preview.Builder builder) {
+ @NonNull
+ public static HdrPreviewExtender create(@NonNull Preview.Builder builder) {
if (ExtensionVersion.isExtensionVersionSupported()) {
try {
return new VendorHdrPreviewExtender(builder);
diff --git a/camera/camera-extensions/src/main/java/androidx/camera/extensions/NightImageCaptureExtender.java b/camera/camera-extensions/src/main/java/androidx/camera/extensions/NightImageCaptureExtender.java
index 3f0d41e..355656d 100644
--- a/camera/camera-extensions/src/main/java/androidx/camera/extensions/NightImageCaptureExtender.java
+++ b/camera/camera-extensions/src/main/java/androidx/camera/extensions/NightImageCaptureExtender.java
@@ -36,7 +36,8 @@
* @param builder Builder that will be used to create the configurations for the
* {@link androidx.camera.core.ImageCapture}.
*/
- public static NightImageCaptureExtender create(ImageCapture.Builder builder) {
+ @NonNull
+ public static NightImageCaptureExtender create(@NonNull ImageCapture.Builder builder) {
if (ExtensionVersion.isExtensionVersionSupported()) {
try {
return new VendorNightImageCaptureExtender(builder);
diff --git a/camera/camera-extensions/src/main/java/androidx/camera/extensions/NightPreviewExtender.java b/camera/camera-extensions/src/main/java/androidx/camera/extensions/NightPreviewExtender.java
index 4e5210b..8140dd0 100644
--- a/camera/camera-extensions/src/main/java/androidx/camera/extensions/NightPreviewExtender.java
+++ b/camera/camera-extensions/src/main/java/androidx/camera/extensions/NightPreviewExtender.java
@@ -36,7 +36,8 @@
* @param builder Builder that will be used to create the configurations for the
* {@link androidx.camera.core.Preview}.
*/
- public static NightPreviewExtender create(Preview.Builder builder) {
+ @NonNull
+ public static NightPreviewExtender create(@NonNull Preview.Builder builder) {
if (ExtensionVersion.isExtensionVersionSupported()) {
try {
return new VendorNightPreviewExtender(builder);
diff --git a/camera/camera-testing/src/main/java/androidx/camera/testing/fakes/FakeUseCaseConfig.java b/camera/camera-testing/src/main/java/androidx/camera/testing/fakes/FakeUseCaseConfig.java
index 3d2c5f7..4f420357 100644
--- a/camera/camera-testing/src/main/java/androidx/camera/testing/fakes/FakeUseCaseConfig.java
+++ b/camera/camera-testing/src/main/java/androidx/camera/testing/fakes/FakeUseCaseConfig.java
@@ -53,7 +53,8 @@
@Override
public int getInputFormat() {
- return ImageFormatConstants.INTERNAL_DEFINED_IMAGE_FORMAT_PRIVATE;
+ return retrieveOption(OPTION_INPUT_FORMAT,
+ ImageFormatConstants.INTERNAL_DEFINED_IMAGE_FORMAT_PRIVATE);
}
/** Builder for an empty Config */
@@ -214,5 +215,14 @@
getMutableConfig().insertOption(OPTION_SUPPORTED_RESOLUTIONS, resolutionsList);
return this;
}
+
+ /**
+ * Sets specific image format to the fake use case.
+ */
+ @NonNull
+ public Builder setBufferFormat(int imageFormat) {
+ getMutableConfig().insertOption(OPTION_INPUT_FORMAT, imageFormat);
+ return this;
+ }
}
}
diff --git a/camera/integration-tests/viewtestapp/build.gradle b/camera/integration-tests/viewtestapp/build.gradle
index be69973..806881c 100644
--- a/camera/integration-tests/viewtestapp/build.gradle
+++ b/camera/integration-tests/viewtestapp/build.gradle
@@ -53,6 +53,7 @@
// Internal library
implementation(project(":camera:camera-camera2"))
implementation(project(":camera:camera-lifecycle"))
+ implementation(project(":lifecycle:lifecycle-runtime"))
implementation(project(":camera:camera-view"))
implementation(GUAVA_ANDROID)
@@ -71,6 +72,7 @@
androidTestImplementation(ESPRESSO_CORE)
androidTestImplementation(project(":camera:camera-testing"))
androidTestImplementation(project(":lifecycle:lifecycle-runtime-testing"))
+ androidTestImplementation(project(":lifecycle:lifecycle-runtime"))
androidTestImplementation("androidx.lifecycle:lifecycle-livedata-ktx:2.2.0")
androidTestImplementation(TRUTH)
debugImplementation(ANDROIDX_TEST_CORE)
diff --git a/compose/android-view/placeholder.txt b/compose/android-view/placeholder.txt
new file mode 100644
index 0000000..b8f7c1a
--- /dev/null
+++ b/compose/android-view/placeholder.txt
@@ -0,0 +1,4 @@
+This file exists to make sure the directory this is in gets created by git, so that
+settings.gradle can point to this directory and not complain about it missing.
+
+TODO: b/160233169 remove this file once the directory structure is migrated from ui/ to here.
diff --git a/compose/compose-compiler-hosted/integration-tests/build.gradle b/compose/compose-compiler-hosted/integration-tests/build.gradle
index e5aa55b..bd63a06 100644
--- a/compose/compose-compiler-hosted/integration-tests/build.gradle
+++ b/compose/compose-compiler-hosted/integration-tests/build.gradle
@@ -38,7 +38,7 @@
testImplementation(KOTLIN_STDLIB)
testImplementation(project(":compose:runtime:runtime"))
testImplementation(project(":compose:core:core"))
- testImplementation(project(":ui:ui-android-view"))
+ testImplementation(project(":compose:android-view:android-view"))
testImplementation(project(":compose:compose-compiler-hosted"))
testImplementation("androidx.core:core-ktx:1.1.0")
}
diff --git a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/LiveLiteralTransformTests.kt b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/LiveLiteralTransformTests.kt
index 725c136..98ff7b1 100644
--- a/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/LiveLiteralTransformTests.kt
+++ b/compose/compose-compiler-hosted/integration-tests/src/test/java/androidx/compose/plugins/kotlin/LiveLiteralTransformTests.kt
@@ -370,104 +370,112 @@
}
@LiveLiteralFileInfo(file = "/Test.kt")
internal class LiveLiterals%TestKt {
- private var Int%arg-0%call-print%fun-A: State<Int>?
+ private var Int%arg-0%call-print%fun-A: Int = 1
+ private var State%Int%arg-0%call-print%fun-A: State<Int>?
@LiveLiteralInfo(key = "Int%arg-0%call-print%fun-A", offset = 54)
fun Int%arg-0%call-print%fun-A(): Int {
- val tmp0 = <this>.Int%arg-0%call-print%fun-A
+ val tmp0 = <this>.State%Int%arg-0%call-print%fun-A
return if (tmp0 == null) {
- val tmp1 = liveLiteral("Int%arg-0%call-print%fun-A", 1)
- <this>.Int%arg-0%call-print%fun-A = tmp1
+ val tmp1 = liveLiteral("Int%arg-0%call-print%fun-A", <this>.Int%arg-0%call-print%fun-A)
+ <this>.State%Int%arg-0%call-print%fun-A = tmp1
tmp1
} else {
tmp0
}
.value
}
- private var String%arg-0%call-print-1%fun-A: State<String>?
+ private var String%arg-0%call-print-1%fun-A: String = "Hello World"
+ private var State%String%arg-0%call-print-1%fun-A: State<String>?
@LiveLiteralInfo(key = "String%arg-0%call-print-1%fun-A", offset = 66)
fun String%arg-0%call-print-1%fun-A(): String {
- val tmp0 = <this>.String%arg-0%call-print-1%fun-A
+ val tmp0 = <this>.State%String%arg-0%call-print-1%fun-A
return if (tmp0 == null) {
- val tmp1 = liveLiteral("String%arg-0%call-print-1%fun-A", "Hello World")
- <this>.String%arg-0%call-print-1%fun-A = tmp1
+ val tmp1 = liveLiteral("String%arg-0%call-print-1%fun-A", <this>.String%arg-0%call-print-1%fun-A)
+ <this>.State%String%arg-0%call-print-1%fun-A = tmp1
tmp1
} else {
tmp0
}
.value
}
- private var Boolean%cond%if%fun-A: State<Boolean>?
+ private var Boolean%cond%if%fun-A: Boolean = true
+ private var State%Boolean%cond%if%fun-A: State<Boolean>?
@LiveLiteralInfo(key = "Boolean%cond%if%fun-A", offset = 86)
fun Boolean%cond%if%fun-A(): Boolean {
- val tmp0 = <this>.Boolean%cond%if%fun-A
+ val tmp0 = <this>.State%Boolean%cond%if%fun-A
return if (tmp0 == null) {
- val tmp1 = liveLiteral("Boolean%cond%if%fun-A", true)
- <this>.Boolean%cond%if%fun-A = tmp1
+ val tmp1 = liveLiteral("Boolean%cond%if%fun-A", <this>.Boolean%cond%if%fun-A)
+ <this>.State%Boolean%cond%if%fun-A = tmp1
tmp1
} else {
tmp0
}
.value
}
- private var Int%%this%call-plus%arg-0%call-print%branch%if%fun-A: State<Int>?
+ private var Int%%this%call-plus%arg-0%call-print%branch%if%fun-A: Int = 3
+ private var State%Int%%this%call-plus%arg-0%call-print%branch%if%fun-A: State<Int>?
@LiveLiteralInfo(key = "Int%%this%call-plus%arg-0%call-print%branch%if%fun-A", offset = 104)
fun Int%%this%call-plus%arg-0%call-print%branch%if%fun-A(): Int {
- val tmp0 = <this>.Int%%this%call-plus%arg-0%call-print%branch%if%fun-A
+ val tmp0 = <this>.State%Int%%this%call-plus%arg-0%call-print%branch%if%fun-A
return if (tmp0 == null) {
- val tmp1 = liveLiteral("Int%%this%call-plus%arg-0%call-print%branch%if%fun-A", 3)
- <this>.Int%%this%call-plus%arg-0%call-print%branch%if%fun-A = tmp1
+ val tmp1 = liveLiteral("Int%%this%call-plus%arg-0%call-print%branch%if%fun-A", <this>.Int%%this%call-plus%arg-0%call-print%branch%if%fun-A)
+ <this>.State%Int%%this%call-plus%arg-0%call-print%branch%if%fun-A = tmp1
tmp1
} else {
tmp0
}
.value
}
- private var Int%arg-0%call-plus%arg-0%call-print%branch%if%fun-A: State<Int>?
+ private var Int%arg-0%call-plus%arg-0%call-print%branch%if%fun-A: Int = 4
+ private var State%Int%arg-0%call-plus%arg-0%call-print%branch%if%fun-A: State<Int>?
@LiveLiteralInfo(key = "Int%arg-0%call-plus%arg-0%call-print%branch%if%fun-A", offset = 108)
fun Int%arg-0%call-plus%arg-0%call-print%branch%if%fun-A(): Int {
- val tmp0 = <this>.Int%arg-0%call-plus%arg-0%call-print%branch%if%fun-A
+ val tmp0 = <this>.State%Int%arg-0%call-plus%arg-0%call-print%branch%if%fun-A
return if (tmp0 == null) {
- val tmp1 = liveLiteral("Int%arg-0%call-plus%arg-0%call-print%branch%if%fun-A", 4)
- <this>.Int%arg-0%call-plus%arg-0%call-print%branch%if%fun-A = tmp1
+ val tmp1 = liveLiteral("Int%arg-0%call-plus%arg-0%call-print%branch%if%fun-A", <this>.Int%arg-0%call-plus%arg-0%call-print%branch%if%fun-A)
+ <this>.State%Int%arg-0%call-plus%arg-0%call-print%branch%if%fun-A = tmp1
tmp1
} else {
tmp0
}
.value
}
- private var Boolean%cond%if-1%fun-A: State<Boolean>?
+ private var Boolean%cond%if-1%fun-A: Boolean = true
+ private var State%Boolean%cond%if-1%fun-A: State<Boolean>?
@LiveLiteralInfo(key = "Boolean%cond%if-1%fun-A", offset = 121)
fun Boolean%cond%if-1%fun-A(): Boolean {
- val tmp0 = <this>.Boolean%cond%if-1%fun-A
+ val tmp0 = <this>.State%Boolean%cond%if-1%fun-A
return if (tmp0 == null) {
- val tmp1 = liveLiteral("Boolean%cond%if-1%fun-A", true)
- <this>.Boolean%cond%if-1%fun-A = tmp1
+ val tmp1 = liveLiteral("Boolean%cond%if-1%fun-A", <this>.Boolean%cond%if-1%fun-A)
+ <this>.State%Boolean%cond%if-1%fun-A = tmp1
tmp1
} else {
tmp0
}
.value
}
- private var Float%arg-0%call-print%branch%if-1%fun-A: State<Float>?
+ private var Float%arg-0%call-print%branch%if-1%fun-A: Float = 1.0f
+ private var State%Float%arg-0%call-print%branch%if-1%fun-A: State<Float>?
@LiveLiteralInfo(key = "Float%arg-0%call-print%branch%if-1%fun-A", offset = 139)
fun Float%arg-0%call-print%branch%if-1%fun-A(): Float {
- val tmp0 = <this>.Float%arg-0%call-print%branch%if-1%fun-A
+ val tmp0 = <this>.State%Float%arg-0%call-print%branch%if-1%fun-A
return if (tmp0 == null) {
- val tmp1 = liveLiteral("Float%arg-0%call-print%branch%if-1%fun-A", 1.0f)
- <this>.Float%arg-0%call-print%branch%if-1%fun-A = tmp1
+ val tmp1 = liveLiteral("Float%arg-0%call-print%branch%if-1%fun-A", <this>.Float%arg-0%call-print%branch%if-1%fun-A)
+ <this>.State%Float%arg-0%call-print%branch%if-1%fun-A = tmp1
tmp1
} else {
tmp0
}
.value
}
- private var Int%arg-0%call-print-2%fun-A: State<Int>?
+ private var Int%arg-0%call-print-2%fun-A: Int = 3
+ private var State%Int%arg-0%call-print-2%fun-A: State<Int>?
@LiveLiteralInfo(key = "Int%arg-0%call-print-2%fun-A", offset = 157)
fun Int%arg-0%call-print-2%fun-A(): Int {
- val tmp0 = <this>.Int%arg-0%call-print-2%fun-A
+ val tmp0 = <this>.State%Int%arg-0%call-print-2%fun-A
return if (tmp0 == null) {
- val tmp1 = liveLiteral("Int%arg-0%call-print-2%fun-A", 3)
- <this>.Int%arg-0%call-print-2%fun-A = tmp1
+ val tmp1 = liveLiteral("Int%arg-0%call-print-2%fun-A", <this>.Int%arg-0%call-print-2%fun-A)
+ <this>.State%Int%arg-0%call-print-2%fun-A = tmp1
tmp1
} else {
tmp0
diff --git a/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/LiveLiteralTransformer.kt b/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/LiveLiteralTransformer.kt
index fe3a143..f8a4ca9 100644
--- a/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/LiveLiteralTransformer.kt
+++ b/compose/compose-compiler-hosted/src/main/java/androidx/compose/plugins/kotlin/compiler/lower/LiveLiteralTransformer.kt
@@ -76,6 +76,7 @@
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrElseBranchImpl
+import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrGetObjectValueImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrStringConcatenationImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrVarargImpl
@@ -124,11 +125,15 @@
* print(LiveLiterals$FooKt.`getString$arg-0$call-print$fun-Foo`())
* }
* object LiveLiterals$FooKt {
- * var `String$arg-0$call-print$fun-Foo`: MutableState<String>? = null
+ * var `String$arg-0$call-print$fun-Foo`: String = "Hello World"
+ * var `State$String$arg-0$call-print$fun-Foo`: MutableState<String>? = null
* fun `getString$arg-0$call-print$fun-Foo`(): String {
* val field = this.`String$arg-0$call-print$fun-Foo`
* val state = if (field == null) {
- * val tmp = liveLiteral("String$arg-0$call-print$fun-Foo", "Hello World")
+ * val tmp = liveLiteral(
+ * "String$arg-0$call-print$fun-Foo",
+ * this.`String$arg-0$call-print$fun-Foo`
+ * )
* this.`String$arg-0$call-print$fun-Foo` = tmp
* tmp
* } else field
@@ -225,8 +230,19 @@
val clazz = liveLiteralsClass!!
val stateType = stateInterface.owner.typeWith(literalType).makeNullable()
val stateGetValue = stateInterface.getPropertyGetter("value")!!
- val field = clazz.addField(
+ val defaultValueField = clazz.addField(
fieldName = key,
+ fieldType = literalType,
+ fieldVisibility = Visibilities.PRIVATE
+ ).apply {
+ initializer = IrExpressionBodyImpl(
+ literalValue.startOffset,
+ literalValue.endOffset,
+ literalValue
+ )
+ }
+ val stateField = clazz.addField(
+ fieldName = "State\$$key",
fieldType = stateType,
fieldVisibility = Visibilities.PRIVATE
)
@@ -237,25 +253,25 @@
val thisParam = fn.dispatchReceiverParameter!!
fn.annotations.add(irLiveLiteralInfoAnnotation(key, literalValue.startOffset))
fn.body = DeclarationIrBuilder(context, fn.symbol).irBlockBody {
- // val a = field
+ // val a = stateField
// val b = if (a == null) {
- // val c = liveLiteralState("key", constValue)
- // field = c
+ // val c = liveLiteralState("key", defaultValueField)
+ // stateField = c
// c
// } else a
// return b.value
- val a = irTemporary(irGetField(irGet(thisParam), field))
+ val a = irTemporary(irGetField(irGet(thisParam), stateField))
val b = irIfNull(
type = stateType,
subject = irGet(a),
thenPart = irBlock(resultType = stateType) {
val liveLiteralCall = irCall(liveLiteral).apply {
putValueArgument(0, irString(key))
- putValueArgument(1, literalValue)
+ putValueArgument(1, irGetField(irGet(thisParam), defaultValueField))
putTypeArgument(0, literalType)
}
val c = irTemporary(liveLiteralCall)
- +irSetField(irGet(thisParam), field, irGet(c))
+ +irSetField(irGet(thisParam), stateField, irGet(c))
+irGet(c)
},
elsePart = irGet(a)
diff --git a/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/RestartTests.kt b/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/RestartTests.kt
index a6d6d60..d1a2f03 100644
--- a/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/RestartTests.kt
+++ b/compose/compose-runtime/src/androidAndroidTest/kotlin/androidx/compose/test/RestartTests.kt
@@ -23,6 +23,7 @@
import androidx.compose.clearRoots
import androidx.compose.mutableStateOf
import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.FlakyTest
import androidx.test.filters.MediumTest
import junit.framework.TestCase
import org.junit.After
@@ -142,6 +143,7 @@
}
@Test
+ @FlakyTest(bugId = 160876771)
fun allocation_Test() {
allocationCounting {
compose {
diff --git a/compose/desktop/placeholder.txt b/compose/desktop/placeholder.txt
new file mode 100644
index 0000000..b8f7c1a
--- /dev/null
+++ b/compose/desktop/placeholder.txt
@@ -0,0 +1,4 @@
+This file exists to make sure the directory this is in gets created by git, so that
+settings.gradle can point to this directory and not complain about it missing.
+
+TODO: b/160233169 remove this file once the directory structure is migrated from ui/ to here.
diff --git a/contentaccess/contentaccess-compiler/src/main/kotlin/androidx/contentaccess/compiler/ContentAccessProcessor.kt b/contentaccess/contentaccess-compiler/src/main/kotlin/androidx/contentaccess/compiler/ContentAccessProcessor.kt
index 5bf61d4..cde30d1 100644
--- a/contentaccess/contentaccess-compiler/src/main/kotlin/androidx/contentaccess/compiler/ContentAccessProcessor.kt
+++ b/contentaccess/contentaccess-compiler/src/main/kotlin/androidx/contentaccess/compiler/ContentAccessProcessor.kt
@@ -26,10 +26,13 @@
import javax.lang.model.element.Element
import javax.annotation.processing.Processor
import com.google.auto.service.AutoService
+import net.ltgt.gradle.incap.IncrementalAnnotationProcessor
+import net.ltgt.gradle.incap.IncrementalAnnotationProcessorType.ISOLATING
import com.squareup.kotlinpoet.metadata.KotlinPoetMetadataPreview
@AutoService(Processor::class)
-// TODO(obenabde): Make this Gradle incremental
+@IncrementalAnnotationProcessor(ISOLATING)
+// TODO(obenabde): write incrementality tests.
class ContentAccessProcessor : BasicAnnotationProcessor() {
override fun initSteps(): MutableIterable<ProcessingStep>? {
diff --git a/datastore/datastore-preferences/build.gradle b/datastore/datastore-preferences/build.gradle
index e3d539e..fe865ae 100644
--- a/datastore/datastore-preferences/build.gradle
+++ b/datastore/datastore-preferences/build.gradle
@@ -34,13 +34,11 @@
testImplementation(JUNIT)
testImplementation(KOTLIN_COROUTINES_TEST)
- testImplementation(TRUTH)
- testImplementation(project(":internal-testutils-truth"))
+ testImplementation(KOTLIN_TEST)
androidTestImplementation(JUNIT)
androidTestImplementation(KOTLIN_COROUTINES_TEST)
- androidTestImplementation(TRUTH)
- androidTestImplementation(project(":internal-testutils-truth"))
+ androidTestImplementation(KOTLIN_TEST)
androidTestImplementation(ANDROIDX_TEST_RUNNER)
androidTestImplementation(ANDROIDX_TEST_CORE)
}
diff --git a/datastore/datastore-preferences/src/androidTest/java/androidx/datastore/preferences/SharedPreferencesToPreferencesTest.kt b/datastore/datastore-preferences/src/androidTest/java/androidx/datastore/preferences/SharedPreferencesToPreferencesTest.kt
index 2225719..10f9c23 100644
--- a/datastore/datastore-preferences/src/androidTest/java/androidx/datastore/preferences/SharedPreferencesToPreferencesTest.kt
+++ b/datastore/datastore-preferences/src/androidTest/java/androidx/datastore/preferences/SharedPreferencesToPreferencesTest.kt
@@ -22,7 +22,6 @@
import androidx.datastore.DataStore
import androidx.test.core.app.ApplicationProvider
import androidx.test.filters.MediumTest
-import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.test.TestCoroutineScope
import kotlinx.coroutines.test.runBlockingTest
@@ -31,6 +30,9 @@
import org.junit.Test
import org.junit.rules.TemporaryFolder
import java.io.File
+import kotlin.test.assertEquals
+import kotlin.test.assertFalse
+import kotlin.test.assertTrue
@kotlinx.coroutines.ExperimentalCoroutinesApi
@kotlinx.coroutines.ObsoleteCoroutinesApi
@@ -53,7 +55,7 @@
sharedPrefs = context.getSharedPreferences(sharedPrefsName, Context.MODE_PRIVATE)
datastoreFile = temporaryFolder.newFile("test_file.preferences_pb")
- assertThat(sharedPrefs.edit().clear().commit()).isTrue()
+ assertTrue { sharedPrefs.edit().clear().commit() }
}
@Test
@@ -61,7 +63,7 @@
val stringKey = "string_key"
val stringValue = "string value"
- assertThat(sharedPrefs.edit().putString(stringKey, stringValue).commit()).isTrue()
+ assertTrue { sharedPrefs.edit().putString(stringKey, stringValue).commit() }
val migration = SharedPreferencesMigration(
context = context,
@@ -72,8 +74,8 @@
val prefs = preferencesStore.data.first()
- assertThat(prefs.getString(stringKey, "default_string")).isEqualTo(stringValue)
- assertThat(prefs.getAll().size).isEqualTo(1)
+ assertEquals(stringValue, prefs.getString(stringKey, "default_string"))
+ assertEquals(prefs.getAll().size, 1)
}
@Test
@@ -81,7 +83,7 @@
val stringKey = "string_key"
val stringValue = "string value"
- assertThat(sharedPrefs.edit().putString(stringKey, stringValue).commit()).isTrue()
+ assertTrue { sharedPrefs.edit().putString(stringKey, stringValue).commit() }
val migration = SharedPreferencesMigration(
context = context,
@@ -93,7 +95,7 @@
// Get data so migration is run.
preferencesStore.data.first()
- assertThat(sharedPrefs.contains(stringKey)).isFalse()
+ assertFalse(sharedPrefs.contains(stringKey))
}
@Test
@@ -101,7 +103,7 @@
val stringKey = "string_key"
val stringValue = "string_value"
- assertThat(sharedPrefs.edit().putString(stringKey, stringValue).commit()).isTrue()
+ assertTrue { sharedPrefs.edit().putString(stringKey, stringValue).commit() }
val migration = SharedPreferencesMigration(
context = context,
@@ -110,8 +112,8 @@
val preferencesStore = getDataStoreWithMigrations(listOf(migration))
val prefs = preferencesStore.data.first()
- assertThat(prefs.getString(stringKey, "default_string")).isEqualTo(stringValue)
- assertThat(prefs.getAll().size).isEqualTo(1)
+ assertEquals(stringValue, prefs.getString(stringKey, "default_string"))
+ assertEquals(prefs.getAll().size, 1)
}
@Test
@@ -119,7 +121,7 @@
val integerKey = "integer_key"
val integerValue = 123
- assertThat(sharedPrefs.edit().putInt(integerKey, integerValue).commit()).isTrue()
+ assertTrue { sharedPrefs.edit().putInt(integerKey, integerValue).commit() }
val migration = SharedPreferencesMigration(
context = context,
@@ -128,8 +130,8 @@
val preferencesStore = getDataStoreWithMigrations(listOf(migration))
val prefs = preferencesStore.data.first()
- assertThat(prefs.getInt(integerKey, -1)).isEqualTo(integerValue)
- assertThat(prefs.getAll().size).isEqualTo(1)
+ assertEquals(integerValue, prefs.getInt(integerKey, -1))
+ assertEquals(1, prefs.getAll().size)
}
@Test
@@ -137,7 +139,7 @@
val floatKey = "float_key"
val floatValue = 123.0f
- assertThat(sharedPrefs.edit().putFloat(floatKey, floatValue).commit()).isTrue()
+ assertTrue { sharedPrefs.edit().putFloat(floatKey, floatValue).commit() }
val migration = SharedPreferencesMigration(
context = context,
@@ -146,8 +148,8 @@
val preferencesStore = getDataStoreWithMigrations(listOf(migration))
val prefs = preferencesStore.data.first()
- assertThat(prefs.getFloat(floatKey, -1.0f)).isEqualTo(floatValue)
- assertThat(prefs.getAll().size).isEqualTo(1)
+ assertEquals(floatValue, prefs.getFloat(floatKey, -1.0f))
+ assertEquals(1, prefs.getAll().size)
}
@Test
@@ -155,7 +157,7 @@
val booleanKey = "boolean_key"
val booleanValue = true
- assertThat(sharedPrefs.edit().putBoolean(booleanKey, booleanValue).commit()).isTrue()
+ assertTrue { sharedPrefs.edit().putBoolean(booleanKey, booleanValue).commit() }
val migration = SharedPreferencesMigration(
context = context,
@@ -164,8 +166,8 @@
val preferencesStore = getDataStoreWithMigrations(listOf(migration))
val prefs = preferencesStore.data.first()
- assertThat(prefs.getBoolean(booleanKey, false)).isEqualTo(booleanValue)
- assertThat(prefs.getAll().size).isEqualTo(1)
+ assertEquals(booleanValue, prefs.getBoolean(booleanKey, false))
+ assertEquals(1, prefs.getAll().size)
}
@Test
@@ -173,7 +175,7 @@
val longKey = "long_key"
val longValue = 1L shr 50
- assertThat(sharedPrefs.edit().putLong(longKey, longValue).commit()).isTrue()
+ assertTrue { sharedPrefs.edit().putLong(longKey, longValue).commit() }
val migration = SharedPreferencesMigration(
context = context,
@@ -182,8 +184,8 @@
val preferencesStore = getDataStoreWithMigrations(listOf(migration))
val prefs = preferencesStore.data.first()
- assertThat(prefs.getLong(longKey, -1)).isEqualTo(longValue)
- assertThat(prefs.getAll().size).isEqualTo(1)
+ assertEquals(longValue, prefs.getLong(longKey, -1))
+ assertEquals(1, prefs.getAll().size)
}
@Test
@@ -191,7 +193,7 @@
val stringSetKey = "stringSet_key"
val stringSetValue = setOf("a", "b", "c")
- assertThat(sharedPrefs.edit().putStringSet(stringSetKey, stringSetValue).commit()).isTrue()
+ assertTrue { sharedPrefs.edit().putStringSet(stringSetKey, stringSetValue).commit() }
val migration = SharedPreferencesMigration(
context = context,
@@ -200,8 +202,8 @@
val preferencesStore = getDataStoreWithMigrations(listOf(migration))
val prefs = preferencesStore.data.first()
- assertThat(prefs.getStringSet(stringSetKey, setOf())).isEqualTo(stringSetValue)
- assertThat(prefs.getAll().size).isEqualTo(1)
+ assertEquals(stringSetValue, prefs.getStringSet(stringSetKey, setOf()))
+ assertEquals(1, prefs.getAll().size)
}
@Test
@@ -209,9 +211,9 @@
val stringSetKey = "stringSet_key"
val stringSetValue = setOf("a", "b", "c")
- assertThat(sharedPrefs.edit().putStringSet(stringSetKey, stringSetValue).commit()).isTrue()
+ assertTrue { sharedPrefs.edit().putStringSet(stringSetKey, stringSetValue).commit() }
val sharedPrefsSet = sharedPrefs.getStringSet(stringSetKey, mutableSetOf())!!
- assertThat(sharedPrefsSet).isEqualTo(stringSetValue)
+ assertEquals(stringSetValue, sharedPrefsSet)
val migration = SharedPreferencesMigration(
context = context,
@@ -225,15 +227,15 @@
// Modify the sharedPrefs string set:
sharedPrefsSet.add("d")
- assertThat(prefs.getStringSet(stringSetKey, setOf())).isEqualTo(stringSetValue)
- assertThat(prefs.getAll().size).isEqualTo(1)
+ assertEquals(stringSetValue, prefs.getStringSet(stringSetKey, setOf<String>()))
+ assertEquals(1, prefs.getAll().size)
}
@Test
fun sharedPreferencesFileDeletedIfPrefsEmpty() = runBlockingTest {
val integerKey = "integer_key"
- assertThat(sharedPrefs.edit().putInt(integerKey, 123).commit()).isTrue()
+ assertTrue { sharedPrefs.edit().putInt(integerKey, 123).commit() }
val migration = SharedPreferencesMigration(
context = context,
@@ -245,14 +247,14 @@
val preferenceStore = getDataStoreWithMigrations(listOf(migration))
preferenceStore.data.first()
- assertThat(getSharedPrefsFile(context, sharedPrefsName).exists()).isFalse()
+ assertFalse(getSharedPrefsFile(context, sharedPrefsName).exists())
}
@Test
fun sharedPreferencesFileNotDeletedIfDisabled() = runBlockingTest {
val integerKey = "integer_key"
- assertThat(sharedPrefs.edit().putInt(integerKey, 123).commit()).isTrue()
+ assertTrue { sharedPrefs.edit().putInt(integerKey, 123).commit() }
val migration = SharedPreferencesMigration(
context = context,
@@ -264,7 +266,9 @@
val preferenceStore = getDataStoreWithMigrations(listOf(migration))
preferenceStore.data.first()
- assertThat(getSharedPrefsFile(context, sharedPrefsName).exists()).isTrue()
+ assertTrue {
+ getSharedPrefsFile(context, sharedPrefsName).exists()
+ }
}
@Test
@@ -272,8 +276,9 @@
val integerKey1 = "integer_key1"
val integerKey2 = "integer_key2"
- assertThat(sharedPrefs.edit().putInt(integerKey1, 123).putInt(integerKey2, 123).commit())
- .isTrue()
+ assertTrue {
+ sharedPrefs.edit().putInt(integerKey1, 123).putInt(integerKey2, 123).commit()
+ }
val migration = SharedPreferencesMigration(
context = context,
@@ -285,7 +290,7 @@
val preferenceStore = getDataStoreWithMigrations(listOf(migration))
preferenceStore.data.first()
- assertThat(getSharedPrefsFile(context, sharedPrefsName).exists()).isTrue()
+ assertTrue { getSharedPrefsFile(context, sharedPrefsName).exists() }
}
@Test
@@ -295,9 +300,9 @@
// Write to shared preferences then create the backup file
val sharedPrefsFile = getSharedPrefsFile(context, sharedPrefsName)
val sharedPrefsBackupFile = getSharedPrefsBackup(sharedPrefsFile)
- assertThat(sharedPrefs.edit().putInt(integerKey, 123).commit()).isTrue()
- assertThat(sharedPrefsFile.exists()).isTrue()
- assertThat(sharedPrefsFile.renameTo(sharedPrefsBackupFile)).isTrue()
+ assertTrue { sharedPrefs.edit().putInt(integerKey, 123).commit() }
+ assertTrue { sharedPrefsFile.exists() }
+ assertTrue { sharedPrefsFile.renameTo(sharedPrefsBackupFile) }
val migration = SharedPreferencesMigration(
context = context,
@@ -309,7 +314,7 @@
val preferenceStore = getDataStoreWithMigrations(listOf(migration))
preferenceStore.data.first()
- assertThat(sharedPrefsBackupFile.exists()).isFalse()
+ assertFalse(sharedPrefsBackupFile.exists())
}
@Test
@@ -322,13 +327,13 @@
val intValue = 12345
val notMigratedString = "dont migrate this string"
- assertThat(
+ assertTrue {
sharedPrefs.edit()
.putString(stringKey, stringValue)
.putInt(integerKey, intValue)
.putString(keyNotMigrated, notMigratedString)
.commit()
- ).isTrue()
+ }
val migration = SharedPreferencesMigration(
context = context,
@@ -340,13 +345,11 @@
val prefs = preferencesStore.data.first()
- assertThat(prefs.getString(stringKey, "default_string"))
- .isEqualTo(stringValue)
- assertThat(prefs.getInt(integerKey, -1))
- .isEqualTo(intValue)
+ assertEquals(stringValue, prefs.getString(stringKey, "default_string"))
+ assertEquals(intValue, prefs.getInt(integerKey, -1))
- assertThat(prefs.getAll().size).isEqualTo(2)
- assertThat(sharedPrefs.getString(keyNotMigrated, "")).isEqualTo(notMigratedString)
+ assertEquals(2, prefs.getAll().size)
+ assertEquals(notMigratedString, sharedPrefs.getString(keyNotMigrated, ""))
}
@Test
@@ -362,8 +365,8 @@
val preferencesStore = getDataStoreWithMigrations(listOf(migration))
val prefs = preferencesStore.data.first()
- assertThat(prefs.contains(missingKey)).isFalse()
- assertThat(prefs.getAll()).doesNotContainKey(missingKey)
+ assertFalse(prefs.contains(missingKey))
+ assertFalse(prefs.getAll().containsKey(missingKey))
}
@Test
@@ -373,7 +376,7 @@
val integerValue = 123
- assertThat(sharedPrefs.edit().putInt(integerKey, integerValue).commit()).isTrue()
+ assertTrue { sharedPrefs.edit().putInt(integerKey, integerValue).commit() }
val migration = SharedPreferencesMigration(
context = context,
@@ -383,8 +386,8 @@
val preferencesStore = getDataStoreWithMigrations(listOf(migration))
val prefs = preferencesStore.data.first()
- assertThat(prefs.getInt(integerKey, -1)).isEqualTo(integerValue)
- assertThat(prefs.getAll().size).isEqualTo(1)
+ assertEquals(integerValue, prefs.getInt(integerKey, -1))
+ assertEquals(1, prefs.getAll().size)
}
private fun getDataStoreWithMigrations(
diff --git a/datastore/datastore-preferences/src/test/java/androidx/datastore/preferences/PreferenceDataStoreFactoryTest.kt b/datastore/datastore-preferences/src/test/java/androidx/datastore/preferences/PreferenceDataStoreFactoryTest.kt
index 7a7e43f..e200d12 100644
--- a/datastore/datastore-preferences/src/test/java/androidx/datastore/preferences/PreferenceDataStoreFactoryTest.kt
+++ b/datastore/datastore-preferences/src/test/java/androidx/datastore/preferences/PreferenceDataStoreFactoryTest.kt
@@ -18,7 +18,6 @@
import androidx.datastore.DataMigration
import androidx.datastore.handlers.ReplaceFileCorruptionHandler
-import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.flow.first
@@ -29,6 +28,7 @@
import org.junit.Test
import org.junit.rules.TemporaryFolder
import java.io.File
+import kotlin.test.assertEquals
@ObsoleteCoroutinesApi
@kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -58,10 +58,10 @@
.setString("key", "value")
.build()
- assertThat(store.updateData {
+ assertEquals(store.updateData {
it.toBuilder().setString("key", "value").build()
- }).isEqualTo(expectedPreferences)
- assertThat(store.data.first()).isEqualTo(expectedPreferences)
+ }, expectedPreferences)
+ assertEquals(expectedPreferences, store.data.first())
}
@Test
@@ -79,7 +79,7 @@
},
scope = dataStoreScope
)
- assertThat(store.data.first()).isEqualTo(valueToReplace)
+ assertEquals(valueToReplace, store.data.first())
}
@Test
@@ -118,6 +118,6 @@
scope = dataStoreScope
)
- assertThat(store.data.first()).isEqualTo(expectedPreferences)
+ assertEquals(expectedPreferences, store.data.first())
}
}
\ No newline at end of file
diff --git a/datastore/datastore-preferences/src/test/java/androidx/datastore/preferences/PreferencesSerializerTest.kt b/datastore/datastore-preferences/src/test/java/androidx/datastore/preferences/PreferencesSerializerTest.kt
index c5bda61..836f67b 100644
--- a/datastore/datastore-preferences/src/test/java/androidx/datastore/preferences/PreferencesSerializerTest.kt
+++ b/datastore/datastore-preferences/src/test/java/androidx/datastore/preferences/PreferencesSerializerTest.kt
@@ -17,13 +17,13 @@
package androidx.datastore.preferences
import androidx.datastore.CorruptionException
-import androidx.testutils.assertThrows
-import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
import java.io.File
+import kotlin.test.assertEquals
+import kotlin.test.assertFailsWith
@kotlinx.coroutines.ExperimentalCoroutinesApi
@kotlinx.coroutines.ObsoleteCoroutinesApi
@@ -57,7 +57,7 @@
preferencesSerializer.readFrom(it)
}
- assertThat(readPrefs).isEqualTo(prefs)
+ assertEquals(prefs, readPrefs)
}
@Test
@@ -76,7 +76,7 @@
preferencesSerializer.readFrom(it)
}
- assertThat(readPrefs).isEqualTo(prefs)
+ assertEquals(prefs, readPrefs)
}
@Test
@@ -95,7 +95,7 @@
preferencesSerializer.readFrom(it)
}
- assertThat(readPrefs).isEqualTo(prefs)
+ assertEquals(prefs, readPrefs)
}
@Test
@@ -114,7 +114,7 @@
preferencesSerializer.readFrom(it)
}
- assertThat(readPrefs).isEqualTo(prefs)
+ assertEquals(prefs, readPrefs)
}
@Test
@@ -133,7 +133,7 @@
preferencesSerializer.readFrom(it)
}
- assertThat(readPrefs).isEqualTo(prefs)
+ assertEquals(prefs, readPrefs)
}
@Test
@@ -141,7 +141,7 @@
// Not a valid proto - protos cannot start with a 0 byte.
testFile.writeBytes(byteArrayOf(0, 1, 2, 3, 4))
- assertThrows<CorruptionException> {
+ assertFailsWith<CorruptionException> {
testFile.inputStream().use {
preferencesSerializer.readFrom(it)
}
diff --git a/datastore/datastore-preferences/src/test/java/androidx/datastore/preferences/PreferencesTest.kt b/datastore/datastore-preferences/src/test/java/androidx/datastore/preferences/PreferencesTest.kt
index fa4bb98..542a2ee 100644
--- a/datastore/datastore-preferences/src/test/java/androidx/datastore/preferences/PreferencesTest.kt
+++ b/datastore/datastore-preferences/src/test/java/androidx/datastore/preferences/PreferencesTest.kt
@@ -16,11 +16,14 @@
package androidx.datastore.preferences
-import androidx.testutils.assertThrows
-import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
+import kotlin.test.assertEquals
+import kotlin.test.assertFailsWith
+import kotlin.test.assertFalse
+import kotlin.test.assertNotEquals
+import kotlin.test.assertTrue
@RunWith(JUnit4::class)
class PreferencesTest {
@@ -35,14 +38,13 @@
.setBoolean(booleanKey, true)
.build()
- assertThat(prefs.contains(booleanKey)).isTrue()
- assertThat(prefs.getBoolean(booleanKey, false)).isTrue()
+ assertTrue { prefs.contains(booleanKey) }
+ assertTrue { prefs.getBoolean(booleanKey, false) }
}
@Test
fun testBooleanDefault() {
- assertThat(Preferences.empty().getBoolean("nonexistent key", false))
- .isFalse()
+ assertFalse(Preferences.empty().getBoolean("nonexistent key", false))
}
@Test
@@ -55,14 +57,13 @@
.setFloat(floatKey, 1.1f)
.build()
- assertThat(prefs.contains(floatKey)).isTrue()
- assertThat(prefs.getFloat(floatKey, 0.0f)).isEqualTo(1.1f)
+ assertTrue { prefs.contains(floatKey) }
+ assertEquals(1.1f, prefs.getFloat(floatKey, 0.0f))
}
@Test
fun testFloatDefault() {
- assertThat(Preferences.empty().getFloat("nonexistent key", 0.1f))
- .isEqualTo(0.1f)
+ assertEquals(0.1f, Preferences.empty().getFloat("nonexistent key", 0.1f))
}
@Test
@@ -75,14 +76,13 @@
.setInt(intKey, 1)
.build()
- assertThat(prefs.contains(intKey)).isTrue()
- assertThat(prefs.getInt(intKey, -1)).isEqualTo(1)
+ assertTrue { prefs.contains(intKey) }
+ assertEquals(1, prefs.getInt(intKey, -1))
}
@Test
fun testIntDefault() {
- assertThat(Preferences.empty().getInt("nonexistent key", 123))
- .isEqualTo(123)
+ assertEquals(123, Preferences.empty().getInt("nonexistent key", 123))
}
@Test
@@ -97,14 +97,13 @@
.setLong(longKey, bigLong)
.build()
- assertThat(prefs.contains(longKey)).isTrue()
- assertThat(prefs.getLong(longKey, -1)).isEqualTo(bigLong)
+ assertTrue { prefs.contains(longKey) }
+ assertEquals(bigLong, prefs.getLong(longKey, -1))
}
@Test
fun testLongDefault() {
- assertThat(Preferences.empty().getLong("nonexistent key", 123))
- .isEqualTo(123)
+ assertEquals(123, Preferences.empty().getLong("nonexistent key", 123))
}
@Test
@@ -117,15 +116,13 @@
.setString(stringKey, "string123")
.build()
- assertThat(prefs.contains(stringKey)).isTrue()
- assertThat(prefs.getString(stringKey, "default string"))
- .isEqualTo("string123")
+ assertTrue { prefs.contains(stringKey) }
+ assertEquals("string123", prefs.getString(stringKey, "default string"))
}
@Test
fun testStringDefault() {
- assertThat(Preferences.empty().getString("nonexistent key", "default val"))
- .isEqualTo("default val")
+ assertEquals("default val", Preferences.empty().getString("nonexistent key", "default val"))
}
@Test
@@ -138,23 +135,24 @@
.setStringSet(stringSetKey, setOf("string1", "string2", "string3"))
.build()
- assertThat(prefs.contains(stringSetKey)).isTrue()
- assertThat(prefs.getStringSet(stringSetKey, setOf())).isEqualTo(
+ assertTrue { prefs.contains(stringSetKey) }
+ assertEquals(
+
setOf(
"string1",
"string2",
"string3"
- )
+ ), prefs.getStringSet(stringSetKey, setOf())
)
}
@Test
fun testStringSetDefault() {
- assertThat(
- Preferences.empty().getStringSet(
+ assertEquals(
+ setOf("default set"), Preferences.empty().getStringSet(
"nonexistent key", setOf("default set")
)
- ).isEqualTo(setOf("default set"))
+ )
}
@Test
@@ -172,12 +170,13 @@
mutableReturnedSet.clear()
mutableReturnedSet.add("Original set does not contain this string")
- assertThat(prefs.getStringSet(stringSetKey, setOf())).isEqualTo(
+ assertEquals(
setOf(
"string1",
"string2",
"string3"
- )
+ ),
+ prefs.getStringSet(stringSetKey, setOf())
)
}
@@ -191,10 +190,10 @@
.setString(stringKey, "string123")
.build()
- assertThat(prefs.contains(stringKey)).isTrue()
+ assertTrue { prefs.contains(stringKey) }
// Trying to get a long where there is a string value throws a ClassCastException.
- assertThrows<ClassCastException> { prefs.getLong(stringKey, 123) }
+ assertFailsWith<ClassCastException> { prefs.getLong(stringKey, 123) }
}
@Test
@@ -210,10 +209,10 @@
.build()
val allPreferences = prefs.getAll()
- assertThat(allPreferences.size).isEqualTo(2)
+ assertEquals(2, allPreferences.size)
- assertThat(allPreferences[intKey]).isEqualTo(123)
- assertThat(allPreferences[stringSetKey]).isEqualTo(setOf("1", "2", "3"))
+ assertEquals(123, allPreferences[intKey])
+ assertEquals(setOf("1", "2", "3"), (allPreferences[stringSetKey]))
}
@Test
@@ -233,8 +232,8 @@
mutableAllPreferences[intKey] = 99999
(mutableAllPreferences[stringSetKey] as MutableSet<String>).clear()
- assertThat(prefs.getInt(intKey, -1)).isEqualTo(123)
- assertThat(prefs.getStringSet(stringSetKey, setOf())).isEqualTo(setOf("1", "2", "3"))
+ assertEquals(123, prefs.getInt(intKey, -1))
+ assertEquals(setOf("1", "2", "3"), prefs.getStringSet(stringSetKey, setOf()))
}
@Test
@@ -249,7 +248,7 @@
val emptyPrefs = prefsWithInt.toBuilder().clear().build()
- assertThat(emptyPrefs).isEqualTo(Preferences.empty())
+ assertEquals(Preferences.empty(), emptyPrefs)
}
@Test
@@ -264,14 +263,14 @@
val emptyPrefs = prefsWithInt.toBuilder().remove(intKey).build()
- assertThat(emptyPrefs).isEqualTo(Preferences.empty())
+ assertEquals(Preferences.empty(), emptyPrefs)
}
@Test
fun testBuilderPublicConstructor() {
val emptyPrefs = Preferences.Builder().build()
- assertThat(emptyPrefs).isEqualTo(Preferences.empty())
+ assertEquals(Preferences.empty(), emptyPrefs)
}
@Test
@@ -281,7 +280,7 @@
val prefs1 = Preferences.empty().toBuilder().setInt(intKey1, 123).build()
val prefs2 = Preferences.empty().toBuilder().setInt(intKey1, 123).build()
- assertThat(prefs1).isEqualTo(prefs2)
+ assertEquals(prefs1, prefs2)
}
@Test
@@ -301,7 +300,7 @@
.setInt(intKey2, 123)
.build()
- assertThat(prefs1).isNotEqualTo(prefs2)
+ assertNotEquals(prefs1, prefs2)
}
@Test
@@ -320,7 +319,7 @@
.setInt(intKey, 999)
.build()
- assertThat(prefs1).isNotEqualTo(prefs2)
+ assertNotEquals(prefs1, prefs2)
}
@Test
@@ -339,6 +338,6 @@
.setStringSet(stringSetKey, setOf("different string1", "string2"))
.build()
- assertThat(prefs1).isNotEqualTo(prefs2)
+ assertNotEquals(prefs1, prefs2)
}
}
\ No newline at end of file
diff --git a/enterprise/feedback/api/1.1.0-alpha01.txt b/enterprise/feedback/api/1.1.0-alpha01.txt
index 3d3f7d6..1cd14ea 100644
--- a/enterprise/feedback/api/1.1.0-alpha01.txt
+++ b/enterprise/feedback/api/1.1.0-alpha01.txt
@@ -5,11 +5,14 @@
method public static androidx.enterprise.feedback.KeyedAppState.KeyedAppStateBuilder builder();
method public abstract String? getData();
method public abstract String getKey();
+ method public static final int getMaxDataLength();
+ method public static final int getMaxKeyLength();
+ method public static final int getMaxMessageLength();
method public abstract String? getMessage();
method public abstract int getSeverity();
- field public static final int MAX_DATA_LENGTH = 1000; // 0x3e8
- field public static final int MAX_KEY_LENGTH = 100; // 0x64
- field public static final int MAX_MESSAGE_LENGTH = 1000; // 0x3e8
+ field @Deprecated public static final int MAX_DATA_LENGTH = 1000; // 0x3e8
+ field @Deprecated public static final int MAX_KEY_LENGTH = 100; // 0x64
+ field @Deprecated public static final int MAX_MESSAGE_LENGTH = 1000; // 0x3e8
field public static final int SEVERITY_ERROR = 2; // 0x2
field public static final int SEVERITY_INFO = 1; // 0x1
}
diff --git a/enterprise/feedback/api/current.txt b/enterprise/feedback/api/current.txt
index 3d3f7d6..1cd14ea 100644
--- a/enterprise/feedback/api/current.txt
+++ b/enterprise/feedback/api/current.txt
@@ -5,11 +5,14 @@
method public static androidx.enterprise.feedback.KeyedAppState.KeyedAppStateBuilder builder();
method public abstract String? getData();
method public abstract String getKey();
+ method public static final int getMaxDataLength();
+ method public static final int getMaxKeyLength();
+ method public static final int getMaxMessageLength();
method public abstract String? getMessage();
method public abstract int getSeverity();
- field public static final int MAX_DATA_LENGTH = 1000; // 0x3e8
- field public static final int MAX_KEY_LENGTH = 100; // 0x64
- field public static final int MAX_MESSAGE_LENGTH = 1000; // 0x3e8
+ field @Deprecated public static final int MAX_DATA_LENGTH = 1000; // 0x3e8
+ field @Deprecated public static final int MAX_KEY_LENGTH = 100; // 0x64
+ field @Deprecated public static final int MAX_MESSAGE_LENGTH = 1000; // 0x3e8
field public static final int SEVERITY_ERROR = 2; // 0x2
field public static final int SEVERITY_INFO = 1; // 0x1
}
diff --git a/enterprise/feedback/api/public_plus_experimental_1.1.0-alpha01.txt b/enterprise/feedback/api/public_plus_experimental_1.1.0-alpha01.txt
index 3d3f7d6..1cd14ea 100644
--- a/enterprise/feedback/api/public_plus_experimental_1.1.0-alpha01.txt
+++ b/enterprise/feedback/api/public_plus_experimental_1.1.0-alpha01.txt
@@ -5,11 +5,14 @@
method public static androidx.enterprise.feedback.KeyedAppState.KeyedAppStateBuilder builder();
method public abstract String? getData();
method public abstract String getKey();
+ method public static final int getMaxDataLength();
+ method public static final int getMaxKeyLength();
+ method public static final int getMaxMessageLength();
method public abstract String? getMessage();
method public abstract int getSeverity();
- field public static final int MAX_DATA_LENGTH = 1000; // 0x3e8
- field public static final int MAX_KEY_LENGTH = 100; // 0x64
- field public static final int MAX_MESSAGE_LENGTH = 1000; // 0x3e8
+ field @Deprecated public static final int MAX_DATA_LENGTH = 1000; // 0x3e8
+ field @Deprecated public static final int MAX_KEY_LENGTH = 100; // 0x64
+ field @Deprecated public static final int MAX_MESSAGE_LENGTH = 1000; // 0x3e8
field public static final int SEVERITY_ERROR = 2; // 0x2
field public static final int SEVERITY_INFO = 1; // 0x1
}
diff --git a/enterprise/feedback/api/public_plus_experimental_current.txt b/enterprise/feedback/api/public_plus_experimental_current.txt
index 3d3f7d6..1cd14ea 100644
--- a/enterprise/feedback/api/public_plus_experimental_current.txt
+++ b/enterprise/feedback/api/public_plus_experimental_current.txt
@@ -5,11 +5,14 @@
method public static androidx.enterprise.feedback.KeyedAppState.KeyedAppStateBuilder builder();
method public abstract String? getData();
method public abstract String getKey();
+ method public static final int getMaxDataLength();
+ method public static final int getMaxKeyLength();
+ method public static final int getMaxMessageLength();
method public abstract String? getMessage();
method public abstract int getSeverity();
- field public static final int MAX_DATA_LENGTH = 1000; // 0x3e8
- field public static final int MAX_KEY_LENGTH = 100; // 0x64
- field public static final int MAX_MESSAGE_LENGTH = 1000; // 0x3e8
+ field @Deprecated public static final int MAX_DATA_LENGTH = 1000; // 0x3e8
+ field @Deprecated public static final int MAX_KEY_LENGTH = 100; // 0x64
+ field @Deprecated public static final int MAX_MESSAGE_LENGTH = 1000; // 0x3e8
field public static final int SEVERITY_ERROR = 2; // 0x2
field public static final int SEVERITY_INFO = 1; // 0x1
}
diff --git a/enterprise/feedback/api/restricted_1.1.0-alpha01.txt b/enterprise/feedback/api/restricted_1.1.0-alpha01.txt
index 3d3f7d6..1cd14ea 100644
--- a/enterprise/feedback/api/restricted_1.1.0-alpha01.txt
+++ b/enterprise/feedback/api/restricted_1.1.0-alpha01.txt
@@ -5,11 +5,14 @@
method public static androidx.enterprise.feedback.KeyedAppState.KeyedAppStateBuilder builder();
method public abstract String? getData();
method public abstract String getKey();
+ method public static final int getMaxDataLength();
+ method public static final int getMaxKeyLength();
+ method public static final int getMaxMessageLength();
method public abstract String? getMessage();
method public abstract int getSeverity();
- field public static final int MAX_DATA_LENGTH = 1000; // 0x3e8
- field public static final int MAX_KEY_LENGTH = 100; // 0x64
- field public static final int MAX_MESSAGE_LENGTH = 1000; // 0x3e8
+ field @Deprecated public static final int MAX_DATA_LENGTH = 1000; // 0x3e8
+ field @Deprecated public static final int MAX_KEY_LENGTH = 100; // 0x64
+ field @Deprecated public static final int MAX_MESSAGE_LENGTH = 1000; // 0x3e8
field public static final int SEVERITY_ERROR = 2; // 0x2
field public static final int SEVERITY_INFO = 1; // 0x1
}
diff --git a/enterprise/feedback/api/restricted_current.txt b/enterprise/feedback/api/restricted_current.txt
index 3d3f7d6..1cd14ea 100644
--- a/enterprise/feedback/api/restricted_current.txt
+++ b/enterprise/feedback/api/restricted_current.txt
@@ -5,11 +5,14 @@
method public static androidx.enterprise.feedback.KeyedAppState.KeyedAppStateBuilder builder();
method public abstract String? getData();
method public abstract String getKey();
+ method public static final int getMaxDataLength();
+ method public static final int getMaxKeyLength();
+ method public static final int getMaxMessageLength();
method public abstract String? getMessage();
method public abstract int getSeverity();
- field public static final int MAX_DATA_LENGTH = 1000; // 0x3e8
- field public static final int MAX_KEY_LENGTH = 100; // 0x64
- field public static final int MAX_MESSAGE_LENGTH = 1000; // 0x3e8
+ field @Deprecated public static final int MAX_DATA_LENGTH = 1000; // 0x3e8
+ field @Deprecated public static final int MAX_KEY_LENGTH = 100; // 0x64
+ field @Deprecated public static final int MAX_MESSAGE_LENGTH = 1000; // 0x3e8
field public static final int SEVERITY_ERROR = 2; // 0x2
field public static final int SEVERITY_INFO = 1; // 0x1
}
diff --git a/enterprise/feedback/src/main/java/androidx/enterprise/feedback/KeyedAppState.java b/enterprise/feedback/src/main/java/androidx/enterprise/feedback/KeyedAppState.java
index e210ffa..d141b70 100644
--- a/enterprise/feedback/src/main/java/androidx/enterprise/feedback/KeyedAppState.java
+++ b/enterprise/feedback/src/main/java/androidx/enterprise/feedback/KeyedAppState.java
@@ -51,16 +51,40 @@
public static final int SEVERITY_INFO = 1;
public static final int SEVERITY_ERROR = 2;
- /** The maximum length of the key. */
+ /** @deprecated Use {@link #getMaxKeyLength()} */
@SuppressLint("MinMaxConstant")
+ @Deprecated
public static final int MAX_KEY_LENGTH = 100;
- /** The maximum length of the message field. */
+ /** @deprecated Use {@link #getMaxMessageLength()} */
@SuppressLint("MinMaxConstant")
+ @Deprecated
public static final int MAX_MESSAGE_LENGTH = 1000;
- /** The maximum length of the data field. */
+ /** @deprecated Use {@link #getMaxDataLength()} */
@SuppressLint("MinMaxConstant")
+ @Deprecated
public static final int MAX_DATA_LENGTH = 1000;
+ /**
+ * Get the maximum length of {@link #getKey()}.
+ */
+ public static final int getMaxKeyLength() {
+ return MAX_KEY_LENGTH;
+ }
+
+ /**
+ * Get the maximum length of {@link #getMessage()}.
+ */
+ public static final int getMaxMessageLength() {
+ return MAX_MESSAGE_LENGTH;
+ }
+
+ /**
+ * Get the maximum length of {@link #getData()}.
+ */
+ public static final int getMaxDataLength() {
+ return MAX_DATA_LENGTH;
+ }
+
/** Create a {@link KeyedAppStateBuilder}. */
@NonNull
public static KeyedAppStateBuilder builder() {
diff --git a/fragment/fragment-ktx/src/androidTest/java/androidx/fragment/app/FragmentResultOwnerTest.kt b/fragment/fragment-ktx/src/androidTest/java/androidx/fragment/app/FragmentResultOwnerTest.kt
index 1c877f0..4bdc742 100644
--- a/fragment/fragment-ktx/src/androidTest/java/androidx/fragment/app/FragmentResultOwnerTest.kt
+++ b/fragment/fragment-ktx/src/androidTest/java/androidx/fragment/app/FragmentResultOwnerTest.kt
@@ -101,8 +101,10 @@
val expectedResult = "resultGood"
val resultBundle = bundleOf("bundleKey" to expectedResult)
- fm.clearFragmentResultListener("requestKey")
- fm.setFragmentResult("requestKey", resultBundle)
+ withActivity {
+ fm.clearFragmentResultListener("requestKey")
+ fm.setFragmentResult("requestKey", resultBundle)
+ }
assertWithMessage("The listener was cleared but the result was not null")
.that(fragment1.actualResult)
diff --git a/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentArchLifecycleTest.kt b/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentArchLifecycleTest.kt
index 864eadf..d11bd14 100644
--- a/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentArchLifecycleTest.kt
+++ b/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentArchLifecycleTest.kt
@@ -46,14 +46,16 @@
val second = Fragment()
fm.beginTransaction().add(first, "first").commit()
executePendingTransactions()
- first.lifecycle.addObserver(object : LifecycleEventObserver {
- override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
- if (event == Lifecycle.Event.ON_STOP) {
- fm.beginTransaction().add(second, "second").commitNow()
- first.lifecycle.removeObserver(this)
+ onActivity {
+ first.lifecycle.addObserver(object : LifecycleEventObserver {
+ override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
+ if (event == Lifecycle.Event.ON_STOP) {
+ fm.beginTransaction().add(second, "second").commitNow()
+ first.lifecycle.removeObserver(this)
+ }
}
- }
- })
+ })
+ }
onActivity {
it.onSaveInstanceState(Bundle())
}
@@ -73,14 +75,16 @@
val second = StrictFragment()
fm.beginTransaction().add(android.R.id.content, first).commit()
executePendingTransactions()
- first.viewLifecycleOwner.lifecycle.addObserver(object : LifecycleEventObserver {
- override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
- if (event == Lifecycle.Event.ON_STOP) {
- fm.beginTransaction().add(second, "second").commitNow()
- first.viewLifecycleOwner.lifecycle.removeObserver(this)
+ onActivity {
+ first.viewLifecycleOwner.lifecycle.addObserver(object : LifecycleEventObserver {
+ override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
+ if (event == Lifecycle.Event.ON_STOP) {
+ fm.beginTransaction().add(second, "second").commitNow()
+ first.viewLifecycleOwner.lifecycle.removeObserver(this)
+ }
}
- }
- })
+ })
+ }
onActivity {
it.onSaveInstanceState(Bundle())
}
diff --git a/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentResultTest.kt b/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentResultTest.kt
index cc758d9..e51d8b2 100644
--- a/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentResultTest.kt
+++ b/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentResultTest.kt
@@ -133,8 +133,10 @@
val resultBundle = Bundle()
val expectedResult = "resultGood"
resultBundle.putString("bundleKey", expectedResult)
+ withActivity {
+ fm.clearFragmentResultListener("requestKey")
+ }
- fm.clearFragmentResultListener("requestKey")
fm.setFragmentResult("requestKey", resultBundle)
assertWithMessage("The result is incorrect")
@@ -161,12 +163,11 @@
fm.beginTransaction()
.add(R.id.fragmentContainer, fragment1)
.commitNow()
+ // lets set another listener with the same key as the original
+ fm.setFragmentResultListener("requestKey", fragment1,
+ FragmentResultListener { _, _ -> })
}
- // lets set another listener with the same key as the original
- fm.setFragmentResultListener("requestKey", fragment1,
- FragmentResultListener { _, _ -> })
-
// do a replace to force the lifecycle back below STARTED
fm.beginTransaction()
.replace(R.id.fragmentContainer, StrictFragment())
@@ -200,17 +201,19 @@
val fragment1 = StrictFragment()
- // set a listener
- fm.setFragmentResultListener("requestKey", fragment1,
- FragmentResultListener { _, _ ->
- firstListenerFired = true
- })
+ withActivity {
+ // set a listener
+ fm.setFragmentResultListener("requestKey", fragment1,
+ FragmentResultListener { _, _ ->
+ firstListenerFired = true
+ })
- // lets set another listener before the first is fired
- fm.setFragmentResultListener("requestKey", fragment1,
- FragmentResultListener { _, _ ->
- secondListenerFired = true
- })
+ // lets set another listener before the first is fired
+ fm.setFragmentResultListener("requestKey", fragment1,
+ FragmentResultListener { _, _ ->
+ secondListenerFired = true
+ })
+ }
// set a result while no listener is available so it is stored in the fragment manager
fm.setFragmentResult("requestKey", Bundle())
@@ -283,8 +286,10 @@
fm.setFragmentResult("requestKey", resultBundle)
- fm.setFragmentResultListener("requestKey", fragment1, FragmentResultListener
- { _, bundle -> actualResult = bundle.getString("bundleKey") })
+ withActivity {
+ fm.setFragmentResultListener("requestKey", fragment1, FragmentResultListener
+ { _, bundle -> actualResult = bundle.getString("bundleKey") })
+ }
assertWithMessage("The result is incorrect")
.that(actualResult)
diff --git a/fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java b/fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
index 7c66375..e92bede 100644
--- a/fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
+++ b/fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
@@ -548,19 +548,6 @@
private void initLifecycle() {
mLifecycleRegistry = new LifecycleRegistry(this);
mSavedStateRegistryController = SavedStateRegistryController.create(this);
- if (Build.VERSION.SDK_INT >= 19) {
- mLifecycleRegistry.addObserver(new LifecycleEventObserver() {
- @Override
- public void onStateChanged(@NonNull LifecycleOwner source,
- @NonNull Lifecycle.Event event) {
- if (event == Lifecycle.Event.ON_STOP) {
- if (mView != null) {
- mView.cancelPendingInputEvents();
- }
- }
- }
- });
- }
}
/**
@@ -2880,6 +2867,19 @@
mChildFragmentManager.noteStateNotSaved();
mState = CREATED;
mCalled = false;
+ if (Build.VERSION.SDK_INT >= 19) {
+ mLifecycleRegistry.addObserver(new LifecycleEventObserver() {
+ @Override
+ public void onStateChanged(@NonNull LifecycleOwner source,
+ @NonNull Lifecycle.Event event) {
+ if (event == Lifecycle.Event.ON_STOP) {
+ if (mView != null) {
+ mView.cancelPendingInputEvents();
+ }
+ }
+ }
+ });
+ }
mSavedStateRegistryController.performRestore(savedInstanceState);
onCreate(savedInstanceState);
mIsCreated = true;
diff --git a/lifecycle/integration-tests/testapp/build.gradle b/lifecycle/integration-tests/testapp/build.gradle
index 84bd02a..902df7e 100644
--- a/lifecycle/integration-tests/testapp/build.gradle
+++ b/lifecycle/integration-tests/testapp/build.gradle
@@ -22,7 +22,7 @@
}
dependencies {
- implementation("androidx.fragment:fragment:1.1.0")
+ implementation(project(":fragment:fragment"))
implementation(project(":lifecycle:lifecycle-process"))
implementation(project(":lifecycle:lifecycle-common"))
annotationProcessor(project(":lifecycle:lifecycle-compiler"))
diff --git a/lifecycle/integration-tests/testapp/src/androidTest/java/androidx/lifecycle/SimpleAppFullLifecycleTest.java b/lifecycle/integration-tests/testapp/src/androidTest/java/androidx/lifecycle/SimpleAppFullLifecycleTest.java
index 5cd2100..bf8a409 100644
--- a/lifecycle/integration-tests/testapp/src/androidTest/java/androidx/lifecycle/SimpleAppFullLifecycleTest.java
+++ b/lifecycle/integration-tests/testapp/src/androidTest/java/androidx/lifecycle/SimpleAppFullLifecycleTest.java
@@ -72,19 +72,22 @@
new ActivityTestRule<>(SimpleAppLifecycleTestActivity.class, false, false);
@Before
- public void setup() {
+ public void setup() throws Throwable {
// cool down period, so application state will become DESTROYED
try {
Thread.sleep(ProcessLifecycleOwner.TIMEOUT_MS * 2);
} catch (InterruptedException e) {
e.printStackTrace();
}
- SimpleAppLifecycleTestActivity.startProcessObserver();
+ activityTestRule.runOnUiThread(
+ SimpleAppLifecycleTestActivity::startProcessObserver);
}
@After
- public void tearDown() {
- SimpleAppLifecycleTestActivity.stopProcessObserver();
+ public void tearDown() throws Throwable {
+ activityTestRule.runOnUiThread(
+ SimpleAppLifecycleTestActivity::stopProcessObserver
+ );
}
@Test
diff --git a/lifecycle/lifecycle-runtime-ktx/src/androidTest/java/androidx/lifecycle/FakeLifecycleOwner.kt b/lifecycle/lifecycle-runtime-ktx/src/androidTest/java/androidx/lifecycle/FakeLifecycleOwner.kt
index 136bcff..bbf9774 100644
--- a/lifecycle/lifecycle-runtime-ktx/src/androidTest/java/androidx/lifecycle/FakeLifecycleOwner.kt
+++ b/lifecycle/lifecycle-runtime-ktx/src/androidTest/java/androidx/lifecycle/FakeLifecycleOwner.kt
@@ -21,7 +21,7 @@
import kotlinx.coroutines.withContext
class FakeLifecycleOwner(initialState: Lifecycle.State? = null) : LifecycleOwner {
- private val registry: LifecycleRegistry = LifecycleRegistry(this)
+ private val registry: LifecycleRegistry = LifecycleRegistry.createUnsafe(this)
init {
initialState?.let {
diff --git a/lifecycle/lifecycle-runtime-testing/src/main/java/androidx/lifecycle/testing/TestLifecycleOwner.kt b/lifecycle/lifecycle-runtime-testing/src/main/java/androidx/lifecycle/testing/TestLifecycleOwner.kt
index c2007b3..633d4ec 100644
--- a/lifecycle/lifecycle-runtime-testing/src/main/java/androidx/lifecycle/testing/TestLifecycleOwner.kt
+++ b/lifecycle/lifecycle-runtime-testing/src/main/java/androidx/lifecycle/testing/TestLifecycleOwner.kt
@@ -16,6 +16,7 @@
package androidx.lifecycle.testing
+import android.annotation.SuppressLint
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
@@ -39,7 +40,9 @@
initialState: Lifecycle.State = Lifecycle.State.STARTED,
private val coroutineDispatcher: CoroutineDispatcher = Dispatchers.Main.immediate
) : LifecycleOwner {
- private val lifecycleRegistry = LifecycleRegistry(this).apply {
+ // it is in test artifact
+ @SuppressLint("VisibleForTests")
+ private val lifecycleRegistry = LifecycleRegistry.createUnsafe(this).apply {
currentState = initialState
}
override fun getLifecycle() = lifecycleRegistry
diff --git a/lifecycle/lifecycle-runtime/api/2.3.0-alpha06.txt b/lifecycle/lifecycle-runtime/api/2.3.0-alpha06.txt
index af2571b..3d9ab48 100644
--- a/lifecycle/lifecycle-runtime/api/2.3.0-alpha06.txt
+++ b/lifecycle/lifecycle-runtime/api/2.3.0-alpha06.txt
@@ -4,6 +4,7 @@
public class LifecycleRegistry extends androidx.lifecycle.Lifecycle {
ctor public LifecycleRegistry(androidx.lifecycle.LifecycleOwner);
method public void addObserver(androidx.lifecycle.LifecycleObserver);
+ method @VisibleForTesting public static androidx.lifecycle.LifecycleRegistry createUnsafe(androidx.lifecycle.LifecycleOwner);
method public androidx.lifecycle.Lifecycle.State getCurrentState();
method public int getObserverCount();
method public void handleLifecycleEvent(androidx.lifecycle.Lifecycle.Event);
diff --git a/lifecycle/lifecycle-runtime/api/current.txt b/lifecycle/lifecycle-runtime/api/current.txt
index af2571b..3d9ab48 100644
--- a/lifecycle/lifecycle-runtime/api/current.txt
+++ b/lifecycle/lifecycle-runtime/api/current.txt
@@ -4,6 +4,7 @@
public class LifecycleRegistry extends androidx.lifecycle.Lifecycle {
ctor public LifecycleRegistry(androidx.lifecycle.LifecycleOwner);
method public void addObserver(androidx.lifecycle.LifecycleObserver);
+ method @VisibleForTesting public static androidx.lifecycle.LifecycleRegistry createUnsafe(androidx.lifecycle.LifecycleOwner);
method public androidx.lifecycle.Lifecycle.State getCurrentState();
method public int getObserverCount();
method public void handleLifecycleEvent(androidx.lifecycle.Lifecycle.Event);
diff --git a/lifecycle/lifecycle-runtime/api/public_plus_experimental_2.3.0-alpha06.txt b/lifecycle/lifecycle-runtime/api/public_plus_experimental_2.3.0-alpha06.txt
index af2571b..3d9ab48 100644
--- a/lifecycle/lifecycle-runtime/api/public_plus_experimental_2.3.0-alpha06.txt
+++ b/lifecycle/lifecycle-runtime/api/public_plus_experimental_2.3.0-alpha06.txt
@@ -4,6 +4,7 @@
public class LifecycleRegistry extends androidx.lifecycle.Lifecycle {
ctor public LifecycleRegistry(androidx.lifecycle.LifecycleOwner);
method public void addObserver(androidx.lifecycle.LifecycleObserver);
+ method @VisibleForTesting public static androidx.lifecycle.LifecycleRegistry createUnsafe(androidx.lifecycle.LifecycleOwner);
method public androidx.lifecycle.Lifecycle.State getCurrentState();
method public int getObserverCount();
method public void handleLifecycleEvent(androidx.lifecycle.Lifecycle.Event);
diff --git a/lifecycle/lifecycle-runtime/api/public_plus_experimental_current.txt b/lifecycle/lifecycle-runtime/api/public_plus_experimental_current.txt
index af2571b..3d9ab48 100644
--- a/lifecycle/lifecycle-runtime/api/public_plus_experimental_current.txt
+++ b/lifecycle/lifecycle-runtime/api/public_plus_experimental_current.txt
@@ -4,6 +4,7 @@
public class LifecycleRegistry extends androidx.lifecycle.Lifecycle {
ctor public LifecycleRegistry(androidx.lifecycle.LifecycleOwner);
method public void addObserver(androidx.lifecycle.LifecycleObserver);
+ method @VisibleForTesting public static androidx.lifecycle.LifecycleRegistry createUnsafe(androidx.lifecycle.LifecycleOwner);
method public androidx.lifecycle.Lifecycle.State getCurrentState();
method public int getObserverCount();
method public void handleLifecycleEvent(androidx.lifecycle.Lifecycle.Event);
diff --git a/lifecycle/lifecycle-runtime/api/restricted_2.3.0-alpha06.txt b/lifecycle/lifecycle-runtime/api/restricted_2.3.0-alpha06.txt
index 36010e4..0037314 100644
--- a/lifecycle/lifecycle-runtime/api/restricted_2.3.0-alpha06.txt
+++ b/lifecycle/lifecycle-runtime/api/restricted_2.3.0-alpha06.txt
@@ -4,6 +4,7 @@
public class LifecycleRegistry extends androidx.lifecycle.Lifecycle {
ctor public LifecycleRegistry(androidx.lifecycle.LifecycleOwner);
method public void addObserver(androidx.lifecycle.LifecycleObserver);
+ method @VisibleForTesting public static androidx.lifecycle.LifecycleRegistry createUnsafe(androidx.lifecycle.LifecycleOwner);
method public androidx.lifecycle.Lifecycle.State getCurrentState();
method public int getObserverCount();
method public void handleLifecycleEvent(androidx.lifecycle.Lifecycle.Event);
diff --git a/lifecycle/lifecycle-runtime/api/restricted_current.txt b/lifecycle/lifecycle-runtime/api/restricted_current.txt
index 36010e4..0037314 100644
--- a/lifecycle/lifecycle-runtime/api/restricted_current.txt
+++ b/lifecycle/lifecycle-runtime/api/restricted_current.txt
@@ -4,6 +4,7 @@
public class LifecycleRegistry extends androidx.lifecycle.Lifecycle {
ctor public LifecycleRegistry(androidx.lifecycle.LifecycleOwner);
method public void addObserver(androidx.lifecycle.LifecycleObserver);
+ method @VisibleForTesting public static androidx.lifecycle.LifecycleRegistry createUnsafe(androidx.lifecycle.LifecycleOwner);
method public androidx.lifecycle.Lifecycle.State getCurrentState();
method public int getObserverCount();
method public void handleLifecycleEvent(androidx.lifecycle.Lifecycle.Event);
diff --git a/lifecycle/lifecycle-runtime/build.gradle b/lifecycle/lifecycle-runtime/build.gradle
index f49db0d..0586015 100644
--- a/lifecycle/lifecycle-runtime/build.gradle
+++ b/lifecycle/lifecycle-runtime/build.gradle
@@ -24,6 +24,7 @@
api("androidx.arch.core:core-common:2.1.0")
// necessary for IJ to resolve dependencies.
api("androidx.annotation:annotation:1.1.0")
+ implementation("androidx.arch.core:core-runtime:2.1.0")
testImplementation(JUNIT)
testImplementation(MOCKITO_CORE)
diff --git a/lifecycle/lifecycle-runtime/src/main/java/androidx/lifecycle/LifecycleRegistry.java b/lifecycle/lifecycle-runtime/src/main/java/androidx/lifecycle/LifecycleRegistry.java
index 6a29743..50111e8 100644
--- a/lifecycle/lifecycle-runtime/src/main/java/androidx/lifecycle/LifecycleRegistry.java
+++ b/lifecycle/lifecycle-runtime/src/main/java/androidx/lifecycle/LifecycleRegistry.java
@@ -19,9 +19,13 @@
import static androidx.lifecycle.Lifecycle.State.DESTROYED;
import static androidx.lifecycle.Lifecycle.State.INITIALIZED;
+import android.annotation.SuppressLint;
+
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.annotation.VisibleForTesting;
+import androidx.arch.core.executor.ArchTaskExecutor;
import androidx.arch.core.internal.FastSafeIterableMap;
import java.lang.ref.WeakReference;
@@ -73,6 +77,7 @@
// this onStart method. our invariant with mObserverMap doesn't help, because parent observer
// is no longer in the map.
private ArrayList<State> mParentStates = new ArrayList<>();
+ private final boolean mEnforceMainThread;
/**
* Creates a new LifecycleRegistry for the given provider.
@@ -83,8 +88,13 @@
* @param provider The owner LifecycleOwner
*/
public LifecycleRegistry(@NonNull LifecycleOwner provider) {
+ this(provider, true);
+ }
+
+ private LifecycleRegistry(@NonNull LifecycleOwner provider, boolean enforceMainThread) {
mLifecycleOwner = new WeakReference<>(provider);
mState = INITIALIZED;
+ mEnforceMainThread = enforceMainThread;
}
/**
@@ -96,6 +106,7 @@
@Deprecated
@MainThread
public void markState(@NonNull State state) {
+ enforceMainThreadIfNeeded("markState");
setCurrentState(state);
}
@@ -106,6 +117,7 @@
*/
@MainThread
public void setCurrentState(@NonNull State state) {
+ enforceMainThreadIfNeeded("setCurrentState");
moveToState(state);
}
@@ -118,6 +130,7 @@
* @param event The event that was received
*/
public void handleLifecycleEvent(@NonNull Lifecycle.Event event) {
+ enforceMainThreadIfNeeded("handleLifecycleEvent");
moveToState(event.getTargetState());
}
@@ -156,6 +169,7 @@
@Override
public void addObserver(@NonNull LifecycleObserver observer) {
+ enforceMainThreadIfNeeded("addObserver");
State initialState = mState == DESTROYED ? DESTROYED : INITIALIZED;
ObserverWithState statefulObserver = new ObserverWithState(observer, initialState);
ObserverWithState previous = mObserverMap.putIfAbsent(observer, statefulObserver);
@@ -202,6 +216,7 @@
@Override
public void removeObserver(@NonNull LifecycleObserver observer) {
+ enforceMainThreadIfNeeded("removeObserver");
// we consciously decided not to send destruction events here in opposition to addObserver.
// Our reasons for that:
// 1. These events haven't yet happened at all. In contrast to events in addObservers, that
@@ -224,6 +239,7 @@
*/
@SuppressWarnings("WeakerAccess")
public int getObserverCount() {
+ enforceMainThreadIfNeeded("getObserverCount");
return mObserverMap.size();
}
@@ -294,6 +310,31 @@
mNewEventOccurred = false;
}
+ @SuppressLint("RestrictedApi")
+ private void enforceMainThreadIfNeeded(String methodName) {
+ if (mEnforceMainThread) {
+ if (!ArchTaskExecutor.getInstance().isMainThread()) {
+ throw new IllegalStateException("Method " + methodName + " must be called on the "
+ + "main thread");
+ }
+ }
+ }
+
+ /**
+ * Creates a new LifecycleRegistry for the given provider, that doesn't check
+ * that its methods are called on the threads other than main.
+ * <p>
+ * LifecycleRegistry is not synchronized: if multiple threads access this {@code
+ * LifecycleRegistry}, it must be synchronized externally.
+ * <p>
+ * Another possible use-case for this method is JVM testing, when main thread is not present.
+ */
+ @VisibleForTesting
+ @NonNull
+ public static LifecycleRegistry createUnsafe(@NonNull LifecycleOwner owner) {
+ return new LifecycleRegistry(owner, false);
+ }
+
static State min(@NonNull State state1, @Nullable State state2) {
return state2 != null && state2.compareTo(state1) < 0 ? state2 : state1;
}
diff --git a/lifecycle/lifecycle-runtime/src/test/java/NoPackageTest.java b/lifecycle/lifecycle-runtime/src/test/java/NoPackageTest.java
index e84e87d..77ba93b 100644
--- a/lifecycle/lifecycle-runtime/src/test/java/NoPackageTest.java
+++ b/lifecycle/lifecycle-runtime/src/test/java/NoPackageTest.java
@@ -41,7 +41,7 @@
mLifecycleOwner = mock(LifecycleOwner.class);
mLifecycle = mock(Lifecycle.class);
when(mLifecycleOwner.getLifecycle()).thenReturn(mLifecycle);
- mRegistry = new LifecycleRegistry(mLifecycleOwner);
+ mRegistry = LifecycleRegistry.createUnsafe(mLifecycleOwner);
}
@Test
diff --git a/lifecycle/lifecycle-runtime/src/test/java/androidx/lifecycle/LifecycleRegistryTest.java b/lifecycle/lifecycle-runtime/src/test/java/androidx/lifecycle/LifecycleRegistryTest.java
index 6f1f317..7d82ca0 100644
--- a/lifecycle/lifecycle-runtime/src/test/java/androidx/lifecycle/LifecycleRegistryTest.java
+++ b/lifecycle/lifecycle-runtime/src/test/java/androidx/lifecycle/LifecycleRegistryTest.java
@@ -51,7 +51,7 @@
mLifecycleOwner = mock(LifecycleOwner.class);
mLifecycle = mock(Lifecycle.class);
when(mLifecycleOwner.getLifecycle()).thenReturn(mLifecycle);
- mRegistry = new LifecycleRegistry(mLifecycleOwner);
+ mRegistry = LifecycleRegistry.createUnsafe(mLifecycleOwner);
}
@Test
diff --git a/lifecycle/lifecycle-viewmodel-savedstate/src/androidTest/java/androidx/lifecycle/viewmodel/savedstate/SavedStateFactoryTest.kt b/lifecycle/lifecycle-viewmodel-savedstate/src/androidTest/java/androidx/lifecycle/viewmodel/savedstate/SavedStateFactoryTest.kt
index 52d629b..a0532f4 100644
--- a/lifecycle/lifecycle-viewmodel-savedstate/src/androidTest/java/androidx/lifecycle/viewmodel/savedstate/SavedStateFactoryTest.kt
+++ b/lifecycle/lifecycle-viewmodel-savedstate/src/androidTest/java/androidx/lifecycle/viewmodel/savedstate/SavedStateFactoryTest.kt
@@ -25,6 +25,7 @@
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelStore
+import androidx.test.annotation.UiThreadTest
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.google.common.truth.Truth.assertThat
@@ -41,6 +42,7 @@
@get:Rule
var activityRule = androidx.test.rule.ActivityTestRule(MyActivity::class.java)
+ @UiThreadTest
@Test
fun testCreateAndroidVM() {
val savedStateVMFactory = SavedStateViewModelFactory(
@@ -51,6 +53,7 @@
assertThat(vm.get(MyViewModel::class.java).handle).isNotNull()
}
+ @UiThreadTest
@Test
fun testCreateFailAndroidVM() {
val savedStateVMFactory = SavedStateViewModelFactory(
@@ -67,6 +70,7 @@
assertThat(vm.get(MyViewModel::class.java).handle).isNotNull()
}
+ @UiThreadTest
@Test
fun testCreateAndroidAbstractVM() {
val activity = activityRule.activity
diff --git a/navigation/navigation-fragment-ktx/src/androidTest/java/androidx/navigation/fragment/NavGraphViewModelLazyTest.kt b/navigation/navigation-fragment-ktx/src/androidTest/java/androidx/navigation/fragment/NavGraphViewModelLazyTest.kt
index 758e0eb..805a0da 100644
--- a/navigation/navigation-fragment-ktx/src/androidTest/java/androidx/navigation/fragment/NavGraphViewModelLazyTest.kt
+++ b/navigation/navigation-fragment-ktx/src/androidTest/java/androidx/navigation/fragment/NavGraphViewModelLazyTest.kt
@@ -24,6 +24,7 @@
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.testing.launchFragmentInContainer
+import androidx.fragment.app.testing.withFragment
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelStore
@@ -68,7 +69,9 @@
) {
test(R.id.start_destination)
}
- navController.setGraph(navGraph, null)
+ scenario.withFragment {
+ navController.setGraph(navGraph, null)
+ }
scenario.onFragment { fragment ->
assertThat(fragment.viewModel).isNotNull()
@@ -85,8 +88,8 @@
.findFragmentById(R.id.nav_host_fragment)!!
navHostFragment.childFragmentManager.primaryNavigationFragment as TestVMFragment
}
- val viewModel = firstFragment.viewModel
- val savedStateViewModel = firstFragment.savedStateViewModel
+ val viewModel = withActivity { firstFragment.viewModel }
+ val savedStateViewModel = withActivity { firstFragment.savedStateViewModel }
assertThat(viewModel).isNotNull()
assertThat(savedStateViewModel).isNotNull()
@@ -100,7 +103,9 @@
// Navigate to the second destination and ensure it
// gets the same ViewModels and data
- navController.navigate(R.id.second_destination)
+ withActivity {
+ navController.navigate(R.id.second_destination)
+ }
val secondFragment: TestVMFragment = withActivity {
val navHostFragment = supportFragmentManager
.findFragmentById(R.id.nav_host_fragment)!!
diff --git a/navigation/navigation-runtime/api/2.4.0-alpha01.txt b/navigation/navigation-runtime/api/2.4.0-alpha01.txt
index c84c6c6..7cd1b49 100644
--- a/navigation/navigation-runtime/api/2.4.0-alpha01.txt
+++ b/navigation/navigation-runtime/api/2.4.0-alpha01.txt
@@ -94,12 +94,14 @@
public final class NavDeepLinkBuilder {
ctor public NavDeepLinkBuilder(android.content.Context);
method public androidx.navigation.NavDeepLinkBuilder addDestination(@IdRes int);
+ method public androidx.navigation.NavDeepLinkBuilder addDestination(@IdRes int, android.os.Bundle?);
method public android.app.PendingIntent createPendingIntent();
method public androidx.core.app.TaskStackBuilder createTaskStackBuilder();
method public androidx.navigation.NavDeepLinkBuilder setArguments(android.os.Bundle?);
method public androidx.navigation.NavDeepLinkBuilder setComponentName(Class<? extends android.app.Activity>);
method public androidx.navigation.NavDeepLinkBuilder setComponentName(android.content.ComponentName);
method public androidx.navigation.NavDeepLinkBuilder setDestination(@IdRes int);
+ method public androidx.navigation.NavDeepLinkBuilder setDestination(@IdRes int, android.os.Bundle?);
method public androidx.navigation.NavDeepLinkBuilder setGraph(@NavigationRes int);
method public androidx.navigation.NavDeepLinkBuilder setGraph(androidx.navigation.NavGraph);
}
diff --git a/navigation/navigation-runtime/api/current.txt b/navigation/navigation-runtime/api/current.txt
index c84c6c6..7cd1b49 100644
--- a/navigation/navigation-runtime/api/current.txt
+++ b/navigation/navigation-runtime/api/current.txt
@@ -94,12 +94,14 @@
public final class NavDeepLinkBuilder {
ctor public NavDeepLinkBuilder(android.content.Context);
method public androidx.navigation.NavDeepLinkBuilder addDestination(@IdRes int);
+ method public androidx.navigation.NavDeepLinkBuilder addDestination(@IdRes int, android.os.Bundle?);
method public android.app.PendingIntent createPendingIntent();
method public androidx.core.app.TaskStackBuilder createTaskStackBuilder();
method public androidx.navigation.NavDeepLinkBuilder setArguments(android.os.Bundle?);
method public androidx.navigation.NavDeepLinkBuilder setComponentName(Class<? extends android.app.Activity>);
method public androidx.navigation.NavDeepLinkBuilder setComponentName(android.content.ComponentName);
method public androidx.navigation.NavDeepLinkBuilder setDestination(@IdRes int);
+ method public androidx.navigation.NavDeepLinkBuilder setDestination(@IdRes int, android.os.Bundle?);
method public androidx.navigation.NavDeepLinkBuilder setGraph(@NavigationRes int);
method public androidx.navigation.NavDeepLinkBuilder setGraph(androidx.navigation.NavGraph);
}
diff --git a/navigation/navigation-runtime/api/public_plus_experimental_2.4.0-alpha01.txt b/navigation/navigation-runtime/api/public_plus_experimental_2.4.0-alpha01.txt
index c84c6c6..7cd1b49 100644
--- a/navigation/navigation-runtime/api/public_plus_experimental_2.4.0-alpha01.txt
+++ b/navigation/navigation-runtime/api/public_plus_experimental_2.4.0-alpha01.txt
@@ -94,12 +94,14 @@
public final class NavDeepLinkBuilder {
ctor public NavDeepLinkBuilder(android.content.Context);
method public androidx.navigation.NavDeepLinkBuilder addDestination(@IdRes int);
+ method public androidx.navigation.NavDeepLinkBuilder addDestination(@IdRes int, android.os.Bundle?);
method public android.app.PendingIntent createPendingIntent();
method public androidx.core.app.TaskStackBuilder createTaskStackBuilder();
method public androidx.navigation.NavDeepLinkBuilder setArguments(android.os.Bundle?);
method public androidx.navigation.NavDeepLinkBuilder setComponentName(Class<? extends android.app.Activity>);
method public androidx.navigation.NavDeepLinkBuilder setComponentName(android.content.ComponentName);
method public androidx.navigation.NavDeepLinkBuilder setDestination(@IdRes int);
+ method public androidx.navigation.NavDeepLinkBuilder setDestination(@IdRes int, android.os.Bundle?);
method public androidx.navigation.NavDeepLinkBuilder setGraph(@NavigationRes int);
method public androidx.navigation.NavDeepLinkBuilder setGraph(androidx.navigation.NavGraph);
}
diff --git a/navigation/navigation-runtime/api/public_plus_experimental_current.txt b/navigation/navigation-runtime/api/public_plus_experimental_current.txt
index c84c6c6..7cd1b49 100644
--- a/navigation/navigation-runtime/api/public_plus_experimental_current.txt
+++ b/navigation/navigation-runtime/api/public_plus_experimental_current.txt
@@ -94,12 +94,14 @@
public final class NavDeepLinkBuilder {
ctor public NavDeepLinkBuilder(android.content.Context);
method public androidx.navigation.NavDeepLinkBuilder addDestination(@IdRes int);
+ method public androidx.navigation.NavDeepLinkBuilder addDestination(@IdRes int, android.os.Bundle?);
method public android.app.PendingIntent createPendingIntent();
method public androidx.core.app.TaskStackBuilder createTaskStackBuilder();
method public androidx.navigation.NavDeepLinkBuilder setArguments(android.os.Bundle?);
method public androidx.navigation.NavDeepLinkBuilder setComponentName(Class<? extends android.app.Activity>);
method public androidx.navigation.NavDeepLinkBuilder setComponentName(android.content.ComponentName);
method public androidx.navigation.NavDeepLinkBuilder setDestination(@IdRes int);
+ method public androidx.navigation.NavDeepLinkBuilder setDestination(@IdRes int, android.os.Bundle?);
method public androidx.navigation.NavDeepLinkBuilder setGraph(@NavigationRes int);
method public androidx.navigation.NavDeepLinkBuilder setGraph(androidx.navigation.NavGraph);
}
diff --git a/navigation/navigation-runtime/api/restricted_2.4.0-alpha01.txt b/navigation/navigation-runtime/api/restricted_2.4.0-alpha01.txt
index c84c6c6..7cd1b49 100644
--- a/navigation/navigation-runtime/api/restricted_2.4.0-alpha01.txt
+++ b/navigation/navigation-runtime/api/restricted_2.4.0-alpha01.txt
@@ -94,12 +94,14 @@
public final class NavDeepLinkBuilder {
ctor public NavDeepLinkBuilder(android.content.Context);
method public androidx.navigation.NavDeepLinkBuilder addDestination(@IdRes int);
+ method public androidx.navigation.NavDeepLinkBuilder addDestination(@IdRes int, android.os.Bundle?);
method public android.app.PendingIntent createPendingIntent();
method public androidx.core.app.TaskStackBuilder createTaskStackBuilder();
method public androidx.navigation.NavDeepLinkBuilder setArguments(android.os.Bundle?);
method public androidx.navigation.NavDeepLinkBuilder setComponentName(Class<? extends android.app.Activity>);
method public androidx.navigation.NavDeepLinkBuilder setComponentName(android.content.ComponentName);
method public androidx.navigation.NavDeepLinkBuilder setDestination(@IdRes int);
+ method public androidx.navigation.NavDeepLinkBuilder setDestination(@IdRes int, android.os.Bundle?);
method public androidx.navigation.NavDeepLinkBuilder setGraph(@NavigationRes int);
method public androidx.navigation.NavDeepLinkBuilder setGraph(androidx.navigation.NavGraph);
}
diff --git a/navigation/navigation-runtime/api/restricted_current.txt b/navigation/navigation-runtime/api/restricted_current.txt
index c84c6c6..7cd1b49 100644
--- a/navigation/navigation-runtime/api/restricted_current.txt
+++ b/navigation/navigation-runtime/api/restricted_current.txt
@@ -94,12 +94,14 @@
public final class NavDeepLinkBuilder {
ctor public NavDeepLinkBuilder(android.content.Context);
method public androidx.navigation.NavDeepLinkBuilder addDestination(@IdRes int);
+ method public androidx.navigation.NavDeepLinkBuilder addDestination(@IdRes int, android.os.Bundle?);
method public android.app.PendingIntent createPendingIntent();
method public androidx.core.app.TaskStackBuilder createTaskStackBuilder();
method public androidx.navigation.NavDeepLinkBuilder setArguments(android.os.Bundle?);
method public androidx.navigation.NavDeepLinkBuilder setComponentName(Class<? extends android.app.Activity>);
method public androidx.navigation.NavDeepLinkBuilder setComponentName(android.content.ComponentName);
method public androidx.navigation.NavDeepLinkBuilder setDestination(@IdRes int);
+ method public androidx.navigation.NavDeepLinkBuilder setDestination(@IdRes int, android.os.Bundle?);
method public androidx.navigation.NavDeepLinkBuilder setGraph(@NavigationRes int);
method public androidx.navigation.NavDeepLinkBuilder setGraph(androidx.navigation.NavGraph);
}
diff --git a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/FloatingWindowTest.kt b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/FloatingWindowTest.kt
index 341322b..ccbf1c1 100644
--- a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/FloatingWindowTest.kt
+++ b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/FloatingWindowTest.kt
@@ -18,6 +18,7 @@
import androidx.navigation.test.FloatingTestNavigator
import androidx.navigation.test.R
+import androidx.test.annotation.UiThreadTest
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
@@ -30,6 +31,7 @@
@RunWith(AndroidJUnit4::class)
class FloatingWindowTest {
+ @UiThreadTest
@Test
fun testNavigateFloatingToNotFloating() {
val navController = createNavController()
@@ -53,6 +55,7 @@
.isEqualTo(1)
}
+ @UiThreadTest
@Test
fun testNavigateFloatingToFloating() {
val navController = createNavController()
@@ -73,6 +76,7 @@
.isEqualTo(2)
}
+ @UiThreadTest
@Test
fun testNavigateFloating2xToNotFloating() {
val navController = createNavController()
diff --git a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryLifecycleTest.kt b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryLifecycleTest.kt
index ba2eb51..40ef402 100644
--- a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryLifecycleTest.kt
+++ b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryLifecycleTest.kt
@@ -24,6 +24,7 @@
import androidx.navigation.test.FloatingTestNavigator
import androidx.navigation.test.R
import androidx.navigation.test.dialog
+import androidx.test.annotation.UiThreadTest
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
@@ -42,6 +43,7 @@
/**
* Test that navigating between siblings correctly stops the previous sibling.
*/
+ @UiThreadTest
@Test
fun testLifecycle() {
val navController = createNavController()
@@ -103,6 +105,7 @@
* Test that navigating from a sibling to a FloatingWindow sibling leaves the previous
* destination started.
*/
+ @UiThreadTest
@Test
fun testLifecycleWithDialog() {
val navController = createNavController()
@@ -164,6 +167,7 @@
* Test that navigating from within a nested navigation graph to one of the graph's
* siblings correctly stops both the previous destination and its graph.
*/
+ @UiThreadTest
@Test
fun testLifecycleNested() {
val navController = createNavController()
@@ -228,6 +232,7 @@
* FloatingWindow siblings correctly moves both the previous destination and its graph to
* started.
*/
+ @UiThreadTest
@Test
fun testLifecycleNestedWithDialog() {
val navController = createNavController()
@@ -292,6 +297,7 @@
* Test that navigating from within a nested navigation graph to one of the graph's
* siblings correctly stops both the previous destination and its graph.
*/
+ @UiThreadTest
@Test
fun testLifecycleNestedOrdering() {
val navController = createNavController()
@@ -369,6 +375,7 @@
* FloatingWindow siblings correctly moves both the previous destination and its graph to
* started.
*/
+ @UiThreadTest
@Test
fun testLifecycleNestedOrderingWithDialog() {
val navController = createNavController()
@@ -437,6 +444,7 @@
* Test that navigating to a new instance of a graph leaves the previous instance in its
* current state.
*/
+ @UiThreadTest
@Test
fun testLifecycleNestedRepeated() {
val navController = createNavController()
@@ -509,6 +517,7 @@
* Test that navigating to a new instance of a graph via a deep link to a FloatingWindow
* destination leaves the previous instance in its current state.
*/
+ @UiThreadTest
@Test
fun testLifecycleNestedRepeatedWithDialog() {
val navController = createNavController()
diff --git a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryTest.kt b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryTest.kt
index aa30fbf..dab5766 100644
--- a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryTest.kt
+++ b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryTest.kt
@@ -23,6 +23,7 @@
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelStore
import androidx.navigation.test.R
+import androidx.test.annotation.UiThreadTest
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
@@ -38,6 +39,7 @@
@RunWith(AndroidJUnit4::class)
class NavBackStackEntryTest {
+ @UiThreadTest
@Test
fun testGetViewModelStoreOwner() {
val navController = createNavController()
@@ -56,6 +58,7 @@
assertThat(store).isNotNull()
}
+ @UiThreadTest
@Test
fun testGetViewModelStoreOwnerAndroidViewModel() {
val navController = createNavController()
@@ -75,6 +78,7 @@
assertThat(viewModel).isNotNull()
}
+ @UiThreadTest
@Test
fun testGetViewModelStoreOwnerSavedStateViewModel() {
val hostStore = ViewModelStore()
@@ -108,6 +112,7 @@
assertThat(restoredState).isEqualTo("test")
}
+ @UiThreadTest
@Test
fun testSaveRestoreGetViewModelStoreOwner() {
val hostStore = ViewModelStore()
@@ -135,6 +140,7 @@
.isSameInstanceAs(store)
}
+ @UiThreadTest
@Test
fun testGetViewModelStoreOwnerNoGraph() {
val navController = createNavController()
@@ -155,6 +161,7 @@
}
}
+ @UiThreadTest
@Test
fun testGetViewModelStoreOwnerSameGraph() {
val navController = createNavController()
@@ -177,6 +184,7 @@
assertThat(sameGraphOwner.viewModelStore).isSameInstanceAs(viewStore)
}
+ @UiThreadTest
@Test
fun testGetSavedStateHandleRestored() {
val hostStore = ViewModelStore()
@@ -206,6 +214,7 @@
.that(restoredResult).isEqualTo(result)
}
+ @UiThreadTest
@Test
fun testGetSavedStateHandle() {
val entry = NavBackStackEntry(ApplicationProvider.getApplicationContext(),
@@ -214,6 +223,7 @@
assertThat(entry.savedStateHandle).isNotNull()
}
+ @UiThreadTest
@Test
fun testGetSavedStateHandleNoViewModelSet() {
val entry = NavBackStackEntry(ApplicationProvider.getApplicationContext(),
diff --git a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerActivityTest.kt b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerActivityTest.kt
index a954ce9..85529e3 100644
--- a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerActivityTest.kt
+++ b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerActivityTest.kt
@@ -20,6 +20,7 @@
import android.content.Intent
import android.net.Uri
import androidx.navigation.test.R
+import androidx.test.annotation.UiThreadTest
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.testutils.TestNavigator
@@ -49,6 +50,7 @@
TargetActivity.instances = spy(ArrayList())
}
+ @UiThreadTest
@Test
fun testNavigateUpPop() {
navController.setGraph(R.navigation.nav_simple)
@@ -66,6 +68,7 @@
.isEqualTo(1)
}
+ @UiThreadTest
@Test
fun testNavigateUp() {
val activity = activityRule.activity
@@ -86,6 +89,7 @@
.isTrue()
}
+ @UiThreadTest
@Test
fun testActivityDeepLinkHandledOnce() {
val activity = activityRule.activity
diff --git a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt
index ebd9d05..309e049 100644
--- a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt
+++ b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt
@@ -27,6 +27,7 @@
import androidx.activity.ComponentActivity
import androidx.lifecycle.Lifecycle
import androidx.navigation.test.R
+import androidx.test.annotation.UiThreadTest
import androidx.test.core.app.ActivityScenario
import androidx.test.core.app.ApplicationProvider
import androidx.test.espresso.intent.Intents
@@ -57,6 +58,7 @@
import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers.any
import org.mockito.ArgumentMatchers.anyString
+import org.mockito.ArgumentMatchers.argThat
import org.mockito.ArgumentMatchers.eq
import org.mockito.Mockito.mock
import org.mockito.Mockito.times
@@ -77,6 +79,7 @@
private const val TEST_OVERRIDDEN_VALUE_ARG_VALUE = "override"
}
+ @UiThreadTest
@Test
fun testGetCurrentBackStackEntry() {
val navController = createNavController()
@@ -84,12 +87,14 @@
assertEquals(R.id.start_test, navController.currentBackStackEntry?.destination?.id ?: 0)
}
+ @UiThreadTest
@Test
fun testGetCurrentBackStackEntryEmptyBackStack() {
val navController = createNavController()
assertThat(navController.currentBackStackEntry).isNull()
}
+ @UiThreadTest
@Test
fun testGetPreviousBackStackEntry() {
val navController = createNavController()
@@ -98,6 +103,7 @@
assertEquals(R.id.start_test, navController.previousBackStackEntry?.destination?.id ?: 0)
}
+ @UiThreadTest
@Test
fun testGetPreviousBackStackEntryEmptyBackStack() {
val navController = createNavController()
@@ -105,6 +111,7 @@
assertThat(navController.previousBackStackEntry).isNull()
}
+ @UiThreadTest
@Test
fun testStartDestination() {
val navController = createNavController()
@@ -112,6 +119,7 @@
assertEquals(R.id.start_test, navController.currentDestination?.id ?: 0)
}
+ @UiThreadTest
@Test
fun testSetGraphTwice() {
val navController = createNavController()
@@ -130,6 +138,7 @@
.isEqualTo(1)
}
+ @UiThreadTest
@Test
fun testStartDestinationWithArgs() {
val navController = createNavController()
@@ -145,6 +154,7 @@
assertEquals(TEST_ARG_VALUE, foundArgs?.getString(TEST_ARG))
}
+ @UiThreadTest
@Test(expected = IllegalArgumentException::class)
fun testStartDestinationWithWrongArgs() {
val navController = createNavController()
@@ -154,6 +164,7 @@
navController.setGraph(R.navigation.nav_start_destination, args)
}
+ @UiThreadTest
@Test
fun testStartDestinationWithArgsProgrammatic() {
val navController = createNavController()
@@ -175,18 +186,21 @@
assertEquals(TEST_ARG_VALUE, foundArgs?.getString(TEST_ARG))
}
+ @UiThreadTest
@Test(expected = IllegalStateException::class)
fun testMissingStartDestination() {
val navController = createNavController()
navController.setGraph(R.navigation.nav_missing_start_destination)
}
+ @UiThreadTest
@Test(expected = IllegalArgumentException::class)
fun testInvalidStartDestination() {
val navController = createNavController()
navController.setGraph(R.navigation.nav_invalid_start_destination)
}
+ @UiThreadTest
@Test
fun testNestedStartDestination() {
val navController = createNavController()
@@ -194,6 +208,7 @@
assertEquals(R.id.nested_test, navController.currentDestination?.id ?: 0)
}
+ @UiThreadTest
@Test
fun testSetGraph() {
val navController = createNavController()
@@ -203,6 +218,7 @@
assertEquals(R.id.start_test, navController.currentDestination?.id ?: 0)
}
+ @UiThreadTest
@Test
fun testGetGraphIllegalStateException() {
val navController = createNavController()
@@ -213,6 +229,7 @@
}
}
+ @UiThreadTest
@Test
fun testNavigate() {
val navController = createNavController()
@@ -226,6 +243,7 @@
assertEquals(2, navigator.backStack.size)
}
+ @UiThreadTest
@Test
fun testInvalidNavigateViaDeepLink() {
val navController = createNavController()
@@ -245,6 +263,7 @@
}
}
+ @UiThreadTest
@Test
fun testNavigateViaDeepLink() {
val navController = createNavController()
@@ -257,6 +276,7 @@
assertThat(navigator.backStack.size).isEqualTo(2)
}
+ @UiThreadTest
@Test
fun testNavigateViaDeepLinkAction() {
val navController = createNavController()
@@ -269,6 +289,7 @@
assertThat(navigator.backStack.size).isEqualTo(2)
}
+ @UiThreadTest
@Test
fun testNavigateViaDeepLinkActionDifferentURI() {
val navController = createNavController()
@@ -281,6 +302,7 @@
assertThat(navigator.backStack.size).isEqualTo(2)
}
+ @UiThreadTest
@Test
fun testNavigateViaDeepLinkMimeTypeDifferentUri() {
val navController = createNavController()
@@ -293,6 +315,7 @@
assertThat(navigator.backStack.size).isEqualTo(2)
}
+ @UiThreadTest
@Test
fun testNavigateViaDeepLinkMimeType() {
val navController = createNavController()
@@ -305,6 +328,7 @@
assertThat(navigator.backStack.size).isEqualTo(2)
}
+ @UiThreadTest
@Test
fun testNavigateViaDeepLinkMimeTypeWildCard() {
val navController = createNavController()
@@ -317,6 +341,7 @@
assertThat(navigator.backStack.size).isEqualTo(2)
}
+ @UiThreadTest
@Test
fun testNavigateViaDeepLinkMimeTypeWildCardSubtype() {
val navController = createNavController()
@@ -329,6 +354,7 @@
assertThat(navigator.backStack.size).isEqualTo(2)
}
+ @UiThreadTest
@Test
fun testNavigateViaDeepLinkMimeTypeWildCardType() {
val navController = createNavController()
@@ -341,6 +367,7 @@
assertThat(navigator.backStack.size).isEqualTo(2)
}
+ @UiThreadTest
@Test
fun testNavigationViaDeepLinkPopUpTo() {
val navController = createNavController()
@@ -355,6 +382,7 @@
assertThat(navigator.backStack.size).isEqualTo(1)
}
+ @UiThreadTest
@Test
fun testNavigateToDifferentGraphViaDeepLink() {
val navController = createNavController()
@@ -380,6 +408,7 @@
assertThat(navigator.backStack.size).isEqualTo(1)
}
+ @UiThreadTest
@Test
fun testNavigateToDifferentGraphViaDeepLink3x() {
val navController = createNavController()
@@ -415,6 +444,7 @@
assertThat(navigator.backStack.size).isEqualTo(1)
}
+ @UiThreadTest
@Test
fun testNavigateToDifferentGraphViaDeepLinkToGrandchild3x() {
val navController = createNavController()
@@ -515,6 +545,7 @@
Intents.release()
}
+ @UiThreadTest
@Test
fun testSaveRestoreStateXml() {
val context = ApplicationProvider.getApplicationContext() as Context
@@ -540,6 +571,7 @@
assertEquals(1, navigator.saveStateCount)
}
+ @UiThreadTest
@Test
fun testSaveRestoreStateDestinationChanged() {
val context = ApplicationProvider.getApplicationContext() as Context
@@ -571,6 +603,7 @@
assertThat(destinationChangedCount).isEqualTo(1)
}
+ @UiThreadTest
@Test
fun testSaveRestoreStateProgrammatic() {
val context = ApplicationProvider.getApplicationContext() as Context
@@ -596,6 +629,7 @@
assertEquals(2, navigator.backStack.size)
}
+ @UiThreadTest
@Test
fun testSaveRestoreStateBundleParceled() {
val context = ApplicationProvider.getApplicationContext() as Context
@@ -624,6 +658,7 @@
assertThat(navigator.customParcel?.name).isEqualTo(TEST_ARG_VALUE)
}
+ @UiThreadTest
@Test
fun testSaveRestoreAfterNavigateToDifferentNavGraph() {
val context = ApplicationProvider.getApplicationContext() as Context
@@ -664,6 +699,7 @@
assertThat(navigator.saveStateCount).isEqualTo(1)
}
+ @UiThreadTest
@Test
fun testBackstackArgsBundleParceled() {
val context = ApplicationProvider.getApplicationContext() as Context
@@ -696,6 +732,7 @@
}
}
+ @UiThreadTest
@Test
fun testNavigateArgs() {
val navController = createNavController()
@@ -714,6 +751,7 @@
}
}
+ @UiThreadTest
@Test
fun testNavigateWithNoDefaultValue() {
val returnedArgs = navigateWithArgs(null)
@@ -722,6 +760,7 @@
assertFalse(returnedArgs.containsKey("test_no_default_value"))
}
+ @UiThreadTest
@Test
fun testNavigateWithDefaultArgs() {
val returnedArgs = navigateWithArgs(null)
@@ -730,6 +769,7 @@
assertEquals("default", returnedArgs.getString("test_default_value"))
}
+ @UiThreadTest
@Test
fun testNavigateWithArgs() {
val args = Bundle()
@@ -740,6 +780,7 @@
assertEquals(TEST_ARG_VALUE, returnedArgs.getString(TEST_ARG))
}
+ @UiThreadTest
@Test
fun testNavigateWithOverriddenDefaultArgs() {
val args = Bundle()
@@ -764,6 +805,7 @@
return returnedArgs!!
}
+ @UiThreadTest
@Test
fun testPopRoot() {
val navController = createNavController()
@@ -780,6 +822,7 @@
assertEquals(0, navigator.backStack.size)
}
+ @UiThreadTest
@Test
fun testPopOnEmptyStack() {
val navController = createNavController()
@@ -802,6 +845,7 @@
.isFalse()
}
+ @UiThreadTest
@Test
fun testNavigateThenPop() {
val navController = createNavController()
@@ -822,6 +866,7 @@
assertEquals(1, navigator.backStack.size)
}
+ @UiThreadTest
@Test
fun testNavigateThenPopToUnknownDestination() {
val navController = createNavController()
@@ -842,6 +887,7 @@
assertEquals(2, navigator.backStack.size)
}
+ @UiThreadTest
@Test
fun testNavigateThenNavigateWithPop() {
val navController = createNavController()
@@ -857,6 +903,7 @@
assertEquals(1, navigator.backStack.size)
}
+ @UiThreadTest
@Test
fun testNavigateThenNavigateWithPopRoot() {
val navController = createNavController()
@@ -872,6 +919,7 @@
assertEquals(1, navigator.backStack.size)
}
+ @UiThreadTest
@Test
fun testNavigateThenNavigateUp() {
val navController = createNavController()
@@ -892,6 +940,7 @@
assertEquals(1, navigator.backStack.size)
}
+ @UiThreadTest
@Test
fun testNavigateViaAction() {
val navController = createNavController()
@@ -905,6 +954,7 @@
assertEquals(2, navigator.backStack.size)
}
+ @UiThreadTest
@Test
fun testNavigateOptionSingleTop() {
val navController = createNavController()
@@ -919,6 +969,7 @@
assertEquals(2, navigator.backStack.size)
}
+ @UiThreadTest
@Test
fun testNavigateOptionSingleTopNewArgs() {
val navController = createNavController()
@@ -951,6 +1002,7 @@
assertThat(destinationListenerExecuted).isTrue()
}
+ @UiThreadTest
@Test
fun testNavigateOptionSingleTopReplaceNullArgs() {
val navController = createNavController()
@@ -985,6 +1037,7 @@
assertThat(destinationListenerExecuted).isTrue()
}
+ @UiThreadTest
@Test
fun testNavigateOptionSingleTopNewArgsIgnore() {
val navController = createNavController()
@@ -1017,6 +1070,7 @@
assertThat(destinationListenerExecuted).isTrue()
}
+ @UiThreadTest
@Test
fun testNavigateOptionPopUpToInAction() {
val navController = createNavController()
@@ -1031,6 +1085,7 @@
assertEquals(1, navigator.backStack.size)
}
+ @UiThreadTest
@Test
fun testNavigateWithPopUpOptionsOnly() {
val navController = createNavController()
@@ -1050,6 +1105,7 @@
assertEquals(1, navigator.backStack.size)
}
+ @UiThreadTest
@Test
fun testNoDestinationNoPopUpTo() {
val navController = createNavController()
@@ -1063,6 +1119,7 @@
}
}
+ @UiThreadTest
@Test
fun testNavigateOptionPopSelf() {
val navController = createNavController()
@@ -1077,6 +1134,7 @@
assertEquals(1, navigator.backStack.size)
}
+ @UiThreadTest
@Test
fun testNavigateViaActionWithArgs() {
val navController = createNavController()
@@ -1106,6 +1164,7 @@
returnedArgs.getString(TEST_ACTION_OVERRIDDEN_VALUE_ARG))
}
+ @UiThreadTest
@Test
fun testDeepLinkFromNavGraph() {
val navController = createNavController()
@@ -1118,6 +1177,7 @@
assertEquals(1, taskStackBuilder.intentCount)
}
+ @UiThreadTest
@Test
fun testDeepLinkIntent() {
val navController = createNavController()
@@ -1139,6 +1199,7 @@
intent!!.writeToParcel(p, 0)
}
+ @UiThreadTest
@Test
fun testHandleDeepLinkValid() {
val navController = createNavController()
@@ -1173,6 +1234,7 @@
verifyNoMoreInteractions(onDestinationChangedListener)
}
+ @UiThreadTest
@Test
fun testHandleDeepLinkNestedStartDestination() {
val navController = createNavController()
@@ -1208,6 +1270,7 @@
verifyNoMoreInteractions(onDestinationChangedListener)
}
+ @UiThreadTest
@Test
fun testHandleDeepLinkMultipleDestinations() {
val navController = createNavController()
@@ -1255,6 +1318,78 @@
verifyNoMoreInteractions(onDestinationChangedListener)
}
+ @UiThreadTest
+ @Test
+ fun testHandleDeepLinkMultipleDestinationsWithArgs() {
+ val navController = createNavController()
+ navController.setGraph(R.navigation.nav_multiple_navigation)
+ val onDestinationChangedListener =
+ mock(NavController.OnDestinationChangedListener::class.java)
+ navController.addOnDestinationChangedListener(onDestinationChangedListener)
+ val startDestination = navController.findDestination(R.id.simple_child_start_test)
+ verify(onDestinationChangedListener).onDestinationChanged(
+ eq(navController),
+ eq(startDestination),
+ any())
+ val childDestination = navController.findDestination(R.id.simple_child_second_test)
+
+ val globalBundle = Bundle().apply {
+ putString("global", "global")
+ }
+ val firstBundle = Bundle().apply {
+ putString("test", "first")
+ }
+ val secondBundle = Bundle().apply {
+ putString("global", "overridden")
+ putString("test", "second")
+ }
+ val taskStackBuilder = navController.createDeepLink()
+ .setDestination(R.id.simple_child_second_test, firstBundle)
+ .addDestination(R.id.deep_link_child_second_test, secondBundle)
+ .setArguments(globalBundle)
+ .createTaskStackBuilder()
+
+ val intent = taskStackBuilder.editIntentAt(0)
+ assertNotNull(intent)
+ assertWithMessage("NavController should handle deep links to its own graph")
+ .that(navController.handleDeepLink(intent))
+ .isTrue()
+
+ // Verify that we navigated down to the deep link
+ // First to the destination added via setDestination()
+ verify(onDestinationChangedListener).onDestinationChanged(
+ eq(navController),
+ eq(startDestination),
+ argThat { args ->
+ args?.getString("global").equals("global") &&
+ args?.getString("test").equals("first")
+ })
+ verify(onDestinationChangedListener).onDestinationChanged(
+ eq(navController),
+ eq(childDestination),
+ argThat { args ->
+ args?.getString("global").equals("global") &&
+ args?.getString("test").equals("first")
+ })
+ // Then to the second destination added via addDestination()
+ verify(onDestinationChangedListener).onDestinationChanged(
+ eq(navController),
+ eq(navController.findDestination(R.id.deep_link_child_start_test)),
+ argThat { args ->
+ args?.getString("global").equals("overridden") &&
+ args?.getString("test").equals("second")
+ })
+ verify(onDestinationChangedListener).onDestinationChanged(
+ eq(navController),
+ eq(navController.findDestination(R.id.deep_link_child_second_test)),
+ argThat { args ->
+ args?.getString("global").equals("overridden") &&
+ args?.getString("test").equals("second")
+ })
+ verifyNoMoreInteractions(onDestinationChangedListener)
+ }
+
+ @UiThreadTest
@Test
fun testHandleDeepLinkInvalid() {
val navController = createNavController()
@@ -1281,6 +1416,7 @@
verifyNoMoreInteractions(onDestinationChangedListener)
}
+ @UiThreadTest
@Test
fun testHandleDeepLinkToRootInvalid() {
val navController = createNavController()
diff --git a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavDeepLinkBuilderTest.kt b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavDeepLinkBuilderTest.kt
index 773a100..190604c 100644
--- a/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavDeepLinkBuilderTest.kt
+++ b/navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavDeepLinkBuilderTest.kt
@@ -19,6 +19,7 @@
import androidx.navigation.test.R
import android.content.Context
import android.os.Bundle
+import androidx.test.annotation.UiThreadTest
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
@@ -78,6 +79,7 @@
assertEquals("Expected one Intent", 1, taskStackBuilder.intentCount)
}
+ @UiThreadTest
@Test
fun fromNavController() {
val navController = NavController(targetContext).apply {
@@ -149,4 +151,24 @@
.that(firstPendingIntent)
.isNotEqualTo(secondPendingIntent)
}
+
+ @Test
+ fun pendingIntentNotEqualsWithDifferentDestinationArgs() {
+ val deepLinkBuilder = NavDeepLinkBuilder(targetContext)
+
+ deepLinkBuilder.setGraph(R.navigation.nav_simple)
+ val args = Bundle().apply {
+ putString("test", "test")
+ }
+ deepLinkBuilder.setDestination(R.id.second_test, args)
+ val firstPendingIntent = deepLinkBuilder.createPendingIntent()
+
+ // Change the args but not the destination
+ args.putString("test", "test2")
+ val secondPendingIntent = deepLinkBuilder.createPendingIntent()
+ assertWithMessage(
+ "PendingIntents with different destination arguments should be different")
+ .that(firstPendingIntent)
+ .isNotEqualTo(secondPendingIntent)
+ }
}
diff --git a/navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.java b/navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.java
index d82b4e8..6ffbc0a 100644
--- a/navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.java
+++ b/navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.java
@@ -71,6 +71,8 @@
private static final String KEY_BACK_STACK =
"android-support-nav:controller:backStack";
static final String KEY_DEEP_LINK_IDS = "android-support-nav:controller:deepLinkIds";
+ static final String KEY_DEEP_LINK_ARGS =
+ "android-support-nav:controller:deepLinkArgs";
static final String KEY_DEEP_LINK_EXTRAS =
"android-support-nav:controller:deepLinkExtras";
static final String KEY_DEEP_LINK_HANDLED =
@@ -664,17 +666,21 @@
}
Bundle extras = intent.getExtras();
int[] deepLink = extras != null ? extras.getIntArray(KEY_DEEP_LINK_IDS) : null;
- Bundle bundle = new Bundle();
+ ArrayList<Bundle> deepLinkArgs = extras != null
+ ? extras.getParcelableArrayList(KEY_DEEP_LINK_ARGS)
+ : null;
+ Bundle globalArgs = new Bundle();
Bundle deepLinkExtras = extras != null ? extras.getBundle(KEY_DEEP_LINK_EXTRAS) : null;
if (deepLinkExtras != null) {
- bundle.putAll(deepLinkExtras);
+ globalArgs.putAll(deepLinkExtras);
}
if ((deepLink == null || deepLink.length == 0) && intent.getData() != null) {
NavDestination.DeepLinkMatch matchingDeepLink =
mGraph.matchDeepLink(new NavDeepLinkRequest(intent));
if (matchingDeepLink != null) {
deepLink = matchingDeepLink.getDestination().buildDeepLinkIds();
- bundle.putAll(matchingDeepLink.getMatchingArgs());
+ deepLinkArgs = null;
+ globalArgs.putAll(matchingDeepLink.getMatchingArgs());
}
}
if (deepLink == null || deepLink.length == 0) {
@@ -687,7 +693,19 @@
+ " in the navigation graph, ignoring the deep link from " + intent);
return false;
}
- bundle.putParcelable(KEY_DEEP_LINK_INTENT, intent);
+ globalArgs.putParcelable(KEY_DEEP_LINK_INTENT, intent);
+ Bundle[] args = new Bundle[deepLink.length];
+ for (int index = 0; index < args.length; index++) {
+ Bundle arguments = new Bundle();
+ arguments.putAll(globalArgs);
+ if (deepLinkArgs != null) {
+ Bundle deepLinkArguments = deepLinkArgs.get(index);
+ if (deepLinkArguments != null) {
+ arguments.putAll(deepLinkArguments);
+ }
+ }
+ args[index] = arguments;
+ }
int flags = intent.getFlags();
if ((flags & Intent.FLAG_ACTIVITY_NEW_TASK) != 0
&& (flags & Intent.FLAG_ACTIVITY_CLEAR_TASK) == 0) {
@@ -713,7 +731,8 @@
}
int index = 0;
while (index < deepLink.length) {
- int destinationId = deepLink[index++];
+ int destinationId = deepLink[index];
+ Bundle arguments = args[index++];
NavDestination node = findDestination(destinationId);
if (node == null) {
final String dest = NavDestination.getDisplayName(mContext, destinationId);
@@ -722,7 +741,7 @@
+ " cannot be found from the current destination "
+ getCurrentDestination());
}
- navigate(node, bundle,
+ navigate(node, arguments,
new NavOptions.Builder().setEnterAnim(0).setExitAnim(0).build(), null);
}
return true;
@@ -731,6 +750,7 @@
NavGraph graph = mGraph;
for (int i = 0; i < deepLink.length; i++) {
int destinationId = deepLink[i];
+ Bundle arguments = args[i];
NavDestination node = i == 0 ? mGraph : graph.findNode(destinationId);
if (node == null) {
final String dest = NavDestination.getDisplayName(mContext, destinationId);
@@ -750,7 +770,7 @@
}
} else {
// Navigate to the last NavDestination, clearing any existing destinations
- navigate(node, node.addInDefaultArgs(bundle), new NavOptions.Builder()
+ navigate(node, arguments, new NavOptions.Builder()
.setPopUpTo(mGraph.getId(), true)
.setEnterAnim(0).setExitAnim(0).build(), null);
}
diff --git a/navigation/navigation-runtime/src/main/java/androidx/navigation/NavDeepLinkBuilder.java b/navigation/navigation-runtime/src/main/java/androidx/navigation/NavDeepLinkBuilder.java
index 62161e9..36f1bbe 100644
--- a/navigation/navigation-runtime/src/main/java/androidx/navigation/NavDeepLinkBuilder.java
+++ b/navigation/navigation-runtime/src/main/java/androidx/navigation/NavDeepLinkBuilder.java
@@ -52,12 +52,32 @@
* using an existing {@link NavController} via {@link NavController#createDeepLink()}.
*/
public final class NavDeepLinkBuilder {
+ private static class DeepLinkDestination {
+ private final int mDestinationId;
+ @Nullable
+ private final Bundle mArguments;
+
+ DeepLinkDestination(int destinationId, @Nullable Bundle arguments) {
+ mDestinationId = destinationId;
+ mArguments = arguments;
+ }
+
+ public int getDestinationId() {
+ return mDestinationId;
+ }
+
+ @Nullable
+ public Bundle getArguments() {
+ return mArguments;
+ }
+ }
+
private final Context mContext;
private final Intent mIntent;
private NavGraph mGraph;
- private ArrayList<Integer> mDestIds = new ArrayList<>();
- private Bundle mArgs;
+ private ArrayList<DeepLinkDestination> mDestinations = new ArrayList<>();
+ private Bundle mGlobalArgs;
/**
* Construct a new NavDeepLinkBuilder.
@@ -155,8 +175,23 @@
*/
@NonNull
public NavDeepLinkBuilder setDestination(@IdRes int destId) {
- mDestIds.clear();
- mDestIds.add(destId);
+ return setDestination(destId, null);
+ }
+
+ /**
+ * Sets the destination id to deep link to. Any destinations previous added via
+ * {@link #addDestination(int)} are cleared, effectively resetting this object
+ * back to only this single destination.
+ *
+ * @param destId destination ID to deep link to.
+ * @param args Arguments to pass to this destination and any synthetic back stack created
+ * due to this destination being added.
+ * @return this object for chaining
+ */
+ @NonNull
+ public NavDeepLinkBuilder setDestination(@IdRes int destId, @Nullable Bundle args) {
+ mDestinations.clear();
+ mDestinations.add(new DeepLinkDestination(destId, args));
if (mGraph != null) {
verifyAllDestinations();
}
@@ -174,7 +209,23 @@
*/
@NonNull
public NavDeepLinkBuilder addDestination(@IdRes int destId) {
- mDestIds.add(destId);
+ return addDestination(destId, null);
+ }
+
+ /**
+ * Add a new destination id to deep link to. This builds off any previous calls to this method
+ * or calls to {@link #setDestination(int)}, building the minimal synthetic back stack of
+ * start destinations between the previous deep link destination and the newly added
+ * deep link destination.
+ *
+ * @param destId destination ID to deep link to.
+ * @param args Arguments to pass to this destination and any synthetic back stack created
+ * due to this destination being added.
+ * @return this object for chaining
+ */
+ @NonNull
+ public NavDeepLinkBuilder addDestination(@IdRes int destId, @Nullable Bundle args) {
+ mDestinations.add(new DeepLinkDestination(destId, args));
if (mGraph != null) {
verifyAllDestinations();
}
@@ -199,7 +250,8 @@
}
private void verifyAllDestinations() {
- for (Integer destId : mDestIds) {
+ for (DeepLinkDestination destination : mDestinations) {
+ int destId = destination.getDestinationId();
NavDestination node = findDestination(destId);
if (node == null) {
final String dest = NavDestination.getDisplayName(mContext, destId);
@@ -211,8 +263,11 @@
private void fillInIntent() {
ArrayList<Integer> deepLinkIds = new ArrayList<>();
+ ArrayList<Bundle> deepLinkArgs = new ArrayList<>();
NavDestination previousDestination = null;
- for (Integer destId : mDestIds) {
+ for (DeepLinkDestination destination : mDestinations) {
+ int destId = destination.getDestinationId();
+ Bundle arguments = destination.getArguments();
NavDestination node = findDestination(destId);
if (node == null) {
final String dest = NavDestination.getDisplayName(mContext, destId);
@@ -221,6 +276,7 @@
}
for (int id : node.buildDeepLinkIds(previousDestination)) {
deepLinkIds.add(id);
+ deepLinkArgs.add(arguments);
}
previousDestination = node;
}
@@ -231,6 +287,7 @@
idArray[index++] = id;
}
mIntent.putExtra(NavController.KEY_DEEP_LINK_IDS, idArray);
+ mIntent.putParcelableArrayListExtra(NavController.KEY_DEEP_LINK_ARGS, deepLinkArgs);
}
/**
@@ -240,7 +297,7 @@
*/
@NonNull
public NavDeepLinkBuilder setArguments(@Nullable Bundle args) {
- mArgs = args;
+ mGlobalArgs = args;
mIntent.putExtra(NavController.KEY_DEEP_LINK_EXTRAS, args);
return this;
}
@@ -263,7 +320,7 @@
if (mGraph == null) {
throw new IllegalStateException("You must call setGraph() "
+ "before constructing the deep link");
- } else if (mDestIds.isEmpty()) {
+ } else if (mDestinations.isEmpty()) {
throw new IllegalStateException("You must call setDestination() or addDestination() "
+ "before constructing the deep link");
}
@@ -298,14 +355,22 @@
@NonNull
public PendingIntent createPendingIntent() {
int requestCode = 0;
- if (mArgs != null) {
- for (String key: mArgs.keySet()) {
- Object value = mArgs.get(key);
+ if (mGlobalArgs != null) {
+ for (String key: mGlobalArgs.keySet()) {
+ Object value = mGlobalArgs.get(key);
requestCode = 31 * requestCode + (value != null ? value.hashCode() : 0);
}
}
- for (Integer destId : mDestIds) {
+ for (DeepLinkDestination destination : mDestinations) {
+ int destId = destination.getDestinationId();
requestCode = 31 * requestCode + destId;
+ Bundle arguments = destination.getArguments();
+ if (arguments != null) {
+ for (String key: arguments.keySet()) {
+ Object value = arguments.get(key);
+ requestCode = 31 * requestCode + (value != null ? value.hashCode() : 0);
+ }
+ }
}
return createTaskStackBuilder()
.getPendingIntent(requestCode, PendingIntent.FLAG_UPDATE_CURRENT);
diff --git a/paging/common/api/3.0.0-alpha03.txt b/paging/common/api/3.0.0-alpha03.txt
index e07b2b5..3515c9c 100644
--- a/paging/common/api/3.0.0-alpha03.txt
+++ b/paging/common/api/3.0.0-alpha03.txt
@@ -29,9 +29,7 @@
method @AnyThread public void invalidate();
method @WorkerThread public boolean isInvalid();
method public <ToValue> androidx.paging.DataSource<Key,ToValue> map(androidx.arch.core.util.Function<Value,ToValue> function);
- method public <ToValue> androidx.paging.DataSource<Key,ToValue> map(kotlin.jvm.functions.Function1<? super Value,? extends ToValue> function);
method public <ToValue> androidx.paging.DataSource<Key,ToValue> mapByPage(androidx.arch.core.util.Function<java.util.List<Value>,java.util.List<ToValue>> function);
- method public <ToValue> androidx.paging.DataSource<Key,ToValue> mapByPage(kotlin.jvm.functions.Function1<? super java.util.List<? extends Value>,? extends java.util.List<? extends ToValue>> function);
method @AnyThread public void removeInvalidatedCallback(androidx.paging.DataSource.InvalidatedCallback onInvalidatedCallback);
method @AnyThread public final void removeInvalidatedCallback(kotlin.jvm.functions.Function0<kotlin.Unit> onInvalidatedCallback);
property @WorkerThread public boolean isInvalid;
@@ -43,9 +41,7 @@
method public final kotlin.jvm.functions.Function0<androidx.paging.PagingSource<Key,Value>> asPagingSourceFactory();
method public abstract androidx.paging.DataSource<Key,Value> create();
method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> map(androidx.arch.core.util.Function<Value,ToValue> function);
- method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> map(kotlin.jvm.functions.Function1<? super Value,? extends ToValue> function);
method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> mapByPage(androidx.arch.core.util.Function<java.util.List<Value>,java.util.List<ToValue>> function);
- method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> mapByPage(kotlin.jvm.functions.Function1<? super java.util.List<? extends Value>,? extends java.util.List<? extends ToValue>> function);
}
public static interface DataSource.InvalidatedCallback {
diff --git a/paging/common/api/current.txt b/paging/common/api/current.txt
index e07b2b5..3515c9c 100644
--- a/paging/common/api/current.txt
+++ b/paging/common/api/current.txt
@@ -29,9 +29,7 @@
method @AnyThread public void invalidate();
method @WorkerThread public boolean isInvalid();
method public <ToValue> androidx.paging.DataSource<Key,ToValue> map(androidx.arch.core.util.Function<Value,ToValue> function);
- method public <ToValue> androidx.paging.DataSource<Key,ToValue> map(kotlin.jvm.functions.Function1<? super Value,? extends ToValue> function);
method public <ToValue> androidx.paging.DataSource<Key,ToValue> mapByPage(androidx.arch.core.util.Function<java.util.List<Value>,java.util.List<ToValue>> function);
- method public <ToValue> androidx.paging.DataSource<Key,ToValue> mapByPage(kotlin.jvm.functions.Function1<? super java.util.List<? extends Value>,? extends java.util.List<? extends ToValue>> function);
method @AnyThread public void removeInvalidatedCallback(androidx.paging.DataSource.InvalidatedCallback onInvalidatedCallback);
method @AnyThread public final void removeInvalidatedCallback(kotlin.jvm.functions.Function0<kotlin.Unit> onInvalidatedCallback);
property @WorkerThread public boolean isInvalid;
@@ -43,9 +41,7 @@
method public final kotlin.jvm.functions.Function0<androidx.paging.PagingSource<Key,Value>> asPagingSourceFactory();
method public abstract androidx.paging.DataSource<Key,Value> create();
method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> map(androidx.arch.core.util.Function<Value,ToValue> function);
- method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> map(kotlin.jvm.functions.Function1<? super Value,? extends ToValue> function);
method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> mapByPage(androidx.arch.core.util.Function<java.util.List<Value>,java.util.List<ToValue>> function);
- method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> mapByPage(kotlin.jvm.functions.Function1<? super java.util.List<? extends Value>,? extends java.util.List<? extends ToValue>> function);
}
public static interface DataSource.InvalidatedCallback {
diff --git a/paging/common/api/public_plus_experimental_3.0.0-alpha03.txt b/paging/common/api/public_plus_experimental_3.0.0-alpha03.txt
index 394b810..f7e5ad7 100644
--- a/paging/common/api/public_plus_experimental_3.0.0-alpha03.txt
+++ b/paging/common/api/public_plus_experimental_3.0.0-alpha03.txt
@@ -30,9 +30,7 @@
method @AnyThread public void invalidate();
method @WorkerThread public boolean isInvalid();
method public <ToValue> androidx.paging.DataSource<Key,ToValue> map(androidx.arch.core.util.Function<Value,ToValue> function);
- method public <ToValue> androidx.paging.DataSource<Key,ToValue> map(kotlin.jvm.functions.Function1<? super Value,? extends ToValue> function);
method public <ToValue> androidx.paging.DataSource<Key,ToValue> mapByPage(androidx.arch.core.util.Function<java.util.List<Value>,java.util.List<ToValue>> function);
- method public <ToValue> androidx.paging.DataSource<Key,ToValue> mapByPage(kotlin.jvm.functions.Function1<? super java.util.List<? extends Value>,? extends java.util.List<? extends ToValue>> function);
method @AnyThread public void removeInvalidatedCallback(androidx.paging.DataSource.InvalidatedCallback onInvalidatedCallback);
method @AnyThread public final void removeInvalidatedCallback(kotlin.jvm.functions.Function0<kotlin.Unit> onInvalidatedCallback);
property @WorkerThread public boolean isInvalid;
@@ -44,9 +42,7 @@
method public final kotlin.jvm.functions.Function0<androidx.paging.PagingSource<Key,Value>> asPagingSourceFactory();
method public abstract androidx.paging.DataSource<Key,Value> create();
method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> map(androidx.arch.core.util.Function<Value,ToValue> function);
- method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> map(kotlin.jvm.functions.Function1<? super Value,? extends ToValue> function);
method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> mapByPage(androidx.arch.core.util.Function<java.util.List<Value>,java.util.List<ToValue>> function);
- method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> mapByPage(kotlin.jvm.functions.Function1<? super java.util.List<? extends Value>,? extends java.util.List<? extends ToValue>> function);
}
public static interface DataSource.InvalidatedCallback {
diff --git a/paging/common/api/public_plus_experimental_current.txt b/paging/common/api/public_plus_experimental_current.txt
index 394b810..f7e5ad7 100644
--- a/paging/common/api/public_plus_experimental_current.txt
+++ b/paging/common/api/public_plus_experimental_current.txt
@@ -30,9 +30,7 @@
method @AnyThread public void invalidate();
method @WorkerThread public boolean isInvalid();
method public <ToValue> androidx.paging.DataSource<Key,ToValue> map(androidx.arch.core.util.Function<Value,ToValue> function);
- method public <ToValue> androidx.paging.DataSource<Key,ToValue> map(kotlin.jvm.functions.Function1<? super Value,? extends ToValue> function);
method public <ToValue> androidx.paging.DataSource<Key,ToValue> mapByPage(androidx.arch.core.util.Function<java.util.List<Value>,java.util.List<ToValue>> function);
- method public <ToValue> androidx.paging.DataSource<Key,ToValue> mapByPage(kotlin.jvm.functions.Function1<? super java.util.List<? extends Value>,? extends java.util.List<? extends ToValue>> function);
method @AnyThread public void removeInvalidatedCallback(androidx.paging.DataSource.InvalidatedCallback onInvalidatedCallback);
method @AnyThread public final void removeInvalidatedCallback(kotlin.jvm.functions.Function0<kotlin.Unit> onInvalidatedCallback);
property @WorkerThread public boolean isInvalid;
@@ -44,9 +42,7 @@
method public final kotlin.jvm.functions.Function0<androidx.paging.PagingSource<Key,Value>> asPagingSourceFactory();
method public abstract androidx.paging.DataSource<Key,Value> create();
method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> map(androidx.arch.core.util.Function<Value,ToValue> function);
- method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> map(kotlin.jvm.functions.Function1<? super Value,? extends ToValue> function);
method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> mapByPage(androidx.arch.core.util.Function<java.util.List<Value>,java.util.List<ToValue>> function);
- method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> mapByPage(kotlin.jvm.functions.Function1<? super java.util.List<? extends Value>,? extends java.util.List<? extends ToValue>> function);
}
public static interface DataSource.InvalidatedCallback {
diff --git a/paging/common/api/restricted_3.0.0-alpha03.txt b/paging/common/api/restricted_3.0.0-alpha03.txt
index e07b2b5..3515c9c 100644
--- a/paging/common/api/restricted_3.0.0-alpha03.txt
+++ b/paging/common/api/restricted_3.0.0-alpha03.txt
@@ -29,9 +29,7 @@
method @AnyThread public void invalidate();
method @WorkerThread public boolean isInvalid();
method public <ToValue> androidx.paging.DataSource<Key,ToValue> map(androidx.arch.core.util.Function<Value,ToValue> function);
- method public <ToValue> androidx.paging.DataSource<Key,ToValue> map(kotlin.jvm.functions.Function1<? super Value,? extends ToValue> function);
method public <ToValue> androidx.paging.DataSource<Key,ToValue> mapByPage(androidx.arch.core.util.Function<java.util.List<Value>,java.util.List<ToValue>> function);
- method public <ToValue> androidx.paging.DataSource<Key,ToValue> mapByPage(kotlin.jvm.functions.Function1<? super java.util.List<? extends Value>,? extends java.util.List<? extends ToValue>> function);
method @AnyThread public void removeInvalidatedCallback(androidx.paging.DataSource.InvalidatedCallback onInvalidatedCallback);
method @AnyThread public final void removeInvalidatedCallback(kotlin.jvm.functions.Function0<kotlin.Unit> onInvalidatedCallback);
property @WorkerThread public boolean isInvalid;
@@ -43,9 +41,7 @@
method public final kotlin.jvm.functions.Function0<androidx.paging.PagingSource<Key,Value>> asPagingSourceFactory();
method public abstract androidx.paging.DataSource<Key,Value> create();
method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> map(androidx.arch.core.util.Function<Value,ToValue> function);
- method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> map(kotlin.jvm.functions.Function1<? super Value,? extends ToValue> function);
method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> mapByPage(androidx.arch.core.util.Function<java.util.List<Value>,java.util.List<ToValue>> function);
- method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> mapByPage(kotlin.jvm.functions.Function1<? super java.util.List<? extends Value>,? extends java.util.List<? extends ToValue>> function);
}
public static interface DataSource.InvalidatedCallback {
diff --git a/paging/common/api/restricted_current.txt b/paging/common/api/restricted_current.txt
index e07b2b5..3515c9c 100644
--- a/paging/common/api/restricted_current.txt
+++ b/paging/common/api/restricted_current.txt
@@ -29,9 +29,7 @@
method @AnyThread public void invalidate();
method @WorkerThread public boolean isInvalid();
method public <ToValue> androidx.paging.DataSource<Key,ToValue> map(androidx.arch.core.util.Function<Value,ToValue> function);
- method public <ToValue> androidx.paging.DataSource<Key,ToValue> map(kotlin.jvm.functions.Function1<? super Value,? extends ToValue> function);
method public <ToValue> androidx.paging.DataSource<Key,ToValue> mapByPage(androidx.arch.core.util.Function<java.util.List<Value>,java.util.List<ToValue>> function);
- method public <ToValue> androidx.paging.DataSource<Key,ToValue> mapByPage(kotlin.jvm.functions.Function1<? super java.util.List<? extends Value>,? extends java.util.List<? extends ToValue>> function);
method @AnyThread public void removeInvalidatedCallback(androidx.paging.DataSource.InvalidatedCallback onInvalidatedCallback);
method @AnyThread public final void removeInvalidatedCallback(kotlin.jvm.functions.Function0<kotlin.Unit> onInvalidatedCallback);
property @WorkerThread public boolean isInvalid;
@@ -43,9 +41,7 @@
method public final kotlin.jvm.functions.Function0<androidx.paging.PagingSource<Key,Value>> asPagingSourceFactory();
method public abstract androidx.paging.DataSource<Key,Value> create();
method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> map(androidx.arch.core.util.Function<Value,ToValue> function);
- method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> map(kotlin.jvm.functions.Function1<? super Value,? extends ToValue> function);
method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> mapByPage(androidx.arch.core.util.Function<java.util.List<Value>,java.util.List<ToValue>> function);
- method public <ToValue> androidx.paging.DataSource.Factory<Key,ToValue> mapByPage(kotlin.jvm.functions.Function1<? super java.util.List<? extends Value>,? extends java.util.List<? extends ToValue>> function);
}
public static interface DataSource.InvalidatedCallback {
diff --git a/paging/common/src/main/kotlin/androidx/paging/DataSource.kt b/paging/common/src/main/kotlin/androidx/paging/DataSource.kt
index 2556218..1ad5e07 100644
--- a/paging/common/src/main/kotlin/androidx/paging/DataSource.kt
+++ b/paging/common/src/main/kotlin/androidx/paging/DataSource.kt
@@ -184,6 +184,7 @@
* @see DataSource.map
* @see DataSource.mapByPage
*/
+ @JvmSynthetic // hidden to preserve Java source compat with arch.core.util.Function variant
open fun <ToValue : Any> map(function: (Value) -> ToValue): Factory<Key, ToValue> =
mapByPage(Function { list -> list.map(function) })
@@ -224,6 +225,7 @@
* @see DataSource.map
* @see DataSource.mapByPage
*/
+ @JvmSynthetic // hidden to preserve Java source compat with arch.core.util.Function variant
open fun <ToValue : Any> mapByPage(
function: (List<Value>) -> List<ToValue>
): Factory<Key, ToValue> = mapByPage(Function { function(it) })
@@ -270,6 +272,7 @@
* @see DataSource.Factory.map
* @see DataSource.Factory.mapByPage
*/
+ @JvmSynthetic // hidden to preserve Java source compat with arch.core.util.Function variant
open fun <ToValue : Any> mapByPage(
function: (List<Value>) -> List<ToValue>
): DataSource<Key, ToValue> = mapByPage(Function { function(it) })
@@ -307,6 +310,7 @@
* @see DataSource.Factory.map
*
*/
+ @JvmSynthetic // hidden to preserve Java source compat with arch.core.util.Function variant
open fun <ToValue : Any> map(
function: (Value) -> ToValue
): DataSource<Key, ToValue> = map(Function { function(it) })
diff --git a/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/StaggeredGridLayoutManagerTest.java b/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/StaggeredGridLayoutManagerTest.java
index d9b678b..783307e 100644
--- a/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/StaggeredGridLayoutManagerTest.java
+++ b/recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/StaggeredGridLayoutManagerTest.java
@@ -1046,6 +1046,36 @@
}
@Test
+ public void testBatchInsertionsBetweenTailFullSpanItems() throws Throwable {
+ // Magic numbers here aren't super specific to repro, but were the example test case that
+ // led to the isolation of this bug.
+ setupByConfig(new Config().spanCount(2).itemCount(22));
+
+ // Last few items are full spans. Create a variable to reference later, even though it's
+ // basically just a few repeated calls.
+ mAdapter.mFullSpanItems.add(18);
+ mAdapter.mFullSpanItems.add(19);
+ mAdapter.mFullSpanItems.add(20);
+ mAdapter.mFullSpanItems.add(21);
+
+ waitFirstLayout();
+
+ // Scroll to the end to populate full span items.
+ smoothScrollToPosition(mAdapter.mItems.size() - 1);
+
+ // Incrementally add a handful of items, mimicking some adapter usages.
+ final int numberOfItemsToAdd = 12;
+ final int fullSpanItemIndexToInsertFrom = 18 + 1;
+ for (int i = 0; i < numberOfItemsToAdd; i++) {
+ final int insertAt = fullSpanItemIndexToInsertFrom + i;
+ mAdapter.addAndNotify(insertAt, 1);
+ }
+
+ requestLayoutOnUIThread(mRecyclerView);
+ mLayoutManager.waitForLayout(3);
+ }
+
+ @Test
public void temporaryGapHandling() throws Throwable {
int fullSpanIndex = 100;
setupByConfig(new Config()
diff --git a/recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/StaggeredGridLayoutManager.java b/recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/StaggeredGridLayoutManager.java
index c78a39a..0387e96 100644
--- a/recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/StaggeredGridLayoutManager.java
+++ b/recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/StaggeredGridLayoutManager.java
@@ -2846,9 +2846,11 @@
Arrays.fill(mData, position, mData.length, LayoutParams.INVALID_SPAN_ID);
return mData.length;
} else {
- // just invalidate items in between
- Arrays.fill(mData, position, endPosition + 1, LayoutParams.INVALID_SPAN_ID);
- return endPosition + 1;
+ // Just invalidate items in between `position` and the next full span item, or the
+ // end of the tracked spans in mData if it's not been lengthened yet.
+ final int invalidateToIndex = Math.min(endPosition + 1, mData.length);
+ Arrays.fill(mData, position, invalidateToIndex, LayoutParams.INVALID_SPAN_ID);
+ return invalidateToIndex;
}
}
diff --git a/room/compiler/src/main/kotlin/androidx/room/ext/element_ext.kt b/room/compiler/src/main/kotlin/androidx/room/ext/element_ext.kt
index d793f0c..806079c 100644
--- a/room/compiler/src/main/kotlin/androidx/room/ext/element_ext.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/ext/element_ext.kt
@@ -405,7 +405,7 @@
it.isType() && it.simpleName.contentEquals(DEFAULT_IMPLS_CLASS_NAME)
} as? TypeElement ?: return null
return innerClass.getDeclaredMethods().find {
- it.simpleName == this.simpleName && paramsMatch(this.parameters, it.parameters)
+ it.name == this.name && paramsMatch(this.parameters, it.parameters)
}
}
@@ -524,4 +524,7 @@
get() = MoreTypes.asDeclared(asType())
val ExecutableElement.executableType: ExecutableType
- get() = MoreTypes.asExecutable(asType())
\ No newline at end of file
+ get() = MoreTypes.asExecutable(asType())
+
+val Element.name: String
+ get() = simpleName.toString()
\ No newline at end of file
diff --git a/room/compiler/src/main/kotlin/androidx/room/ext/type_mirror_ext.kt b/room/compiler/src/main/kotlin/androidx/room/ext/type_mirror_ext.kt
index f349a00..a28f674 100644
--- a/room/compiler/src/main/kotlin/androidx/room/ext/type_mirror_ext.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/ext/type_mirror_ext.kt
@@ -56,6 +56,8 @@
fun TypeMirror.isPrimitiveInt() = kind == TypeKind.INT
+fun TypeMirror.isPrimitive() = kind.isPrimitive
+
fun TypeMirror.isBoxedInt() =
MoreTypes.isType(this) && MoreTypes.isTypeOf(java.lang.Integer::class.java, this)
@@ -127,4 +129,4 @@
fun TypeMirror.isSameType(utils: Types, other: TypeMirror) = utils.isSameType(this, other)
-fun TypeMirror.erasure(utils: Types) = utils.erasure(this)
\ No newline at end of file
+fun TypeMirror.erasure(utils: Types) = utils.erasure(this)
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/DatabaseProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/DatabaseProcessor.kt
index e74899c..562c8a3 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/DatabaseProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/DatabaseProcessor.kt
@@ -26,6 +26,7 @@
import androidx.room.ext.hasAnnotation
import androidx.room.ext.isAbstract
import androidx.room.ext.isType
+import androidx.room.ext.name
import androidx.room.ext.requireTypeMirror
import androidx.room.ext.toAnnotationBox
import androidx.room.ext.type
@@ -107,7 +108,7 @@
val daoType = executable.returnType.asTypeElement()
val dao = DaoProcessor(context, daoType, declaredType, dbVerifier)
.process()
- DaoMethod(executable, executable.simpleName.toString(), dao)
+ DaoMethod(executable, executable.name, dao)
}
validateUniqueDaoClasses(element, daoMethods, entities)
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/DatabaseViewProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/DatabaseViewProcessor.kt
index f87f10d..9fbc3c9 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/DatabaseViewProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/DatabaseViewProcessor.kt
@@ -16,18 +16,18 @@
package androidx.room.processor
+import androidx.room.ext.name
import androidx.room.ext.toAnnotationBox
import androidx.room.parser.ParsedQuery
import androidx.room.parser.QueryType
import androidx.room.parser.SqlParser
import androidx.room.vo.DatabaseView
-import javax.lang.model.element.Name
import javax.lang.model.element.TypeElement
class DatabaseViewProcessor(
baseContext: Context,
val element: TypeElement,
- private val referenceStack: LinkedHashSet<Name> = LinkedHashSet()
+ private val referenceStack: LinkedHashSet<String> = LinkedHashSet()
) : EntityOrViewProcessor {
val context = baseContext.fork(element)
@@ -40,7 +40,7 @@
val viewName: String = if (annotationBox != null) {
extractViewName(element, annotationBox.value)
} else {
- element.simpleName.toString()
+ element.name
}
val query: ParsedQuery = if (annotationBox != null) {
SqlParser.parse(annotationBox.value.value).also {
@@ -83,7 +83,7 @@
annotation: androidx.room.DatabaseView
): String {
return if (annotation.viewName == "") {
- element.simpleName.toString()
+ element.name
} else {
annotation.viewName
}
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/DeletionMethodProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/DeletionMethodProcessor.kt
index a8512c9..89968fa 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/DeletionMethodProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/DeletionMethodProcessor.kt
@@ -16,6 +16,7 @@
package androidx.room.processor
import androidx.room.Delete
+import androidx.room.ext.name
import androidx.room.vo.DeletionMethod
import javax.lang.model.element.ExecutableElement
import javax.lang.model.type.DeclaredType
@@ -50,7 +51,7 @@
return DeletionMethod(
element = delegate.executableElement,
- name = delegate.executableElement.simpleName.toString(),
+ name = delegate.executableElement.name,
entities = entities,
parameters = params,
methodBinder = methodBinder
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/EntityOrViewProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/EntityOrViewProcessor.kt
index f2326e1..189281b 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/EntityOrViewProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/EntityOrViewProcessor.kt
@@ -24,7 +24,6 @@
import androidx.room.vo.EntityOrView
import androidx.room.vo.Fields
import com.squareup.javapoet.TypeName
-import javax.lang.model.element.Name
import javax.lang.model.element.TypeElement
interface EntityOrViewProcessor {
@@ -38,7 +37,7 @@
private class NonEntityOrViewProcessor(
val context: Context,
val element: TypeElement,
- private val referenceStack: LinkedHashSet<Name>
+ private val referenceStack: LinkedHashSet<String>
) : EntityOrViewProcessor {
override fun process(): EntityOrView {
@@ -64,7 +63,7 @@
fun EntityOrViewProcessor(
context: Context,
element: TypeElement,
- referenceStack: LinkedHashSet<Name> = LinkedHashSet()
+ referenceStack: LinkedHashSet<String> = LinkedHashSet()
): EntityOrViewProcessor {
return when {
element.hasAnnotation(Entity::class) ->
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/EntityProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/EntityProcessor.kt
index 5b7b809..390e29b 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/EntityProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/EntityProcessor.kt
@@ -22,9 +22,9 @@
import androidx.room.Fts4
import androidx.room.ext.AnnotationBox
import androidx.room.ext.hasAnyOf
+import androidx.room.ext.name
import androidx.room.vo.ForeignKeyAction
import androidx.room.vo.Index
-import javax.lang.model.element.Name
import javax.lang.model.element.TypeElement
import javax.lang.model.type.TypeMirror
@@ -34,7 +34,7 @@
companion object {
fun extractTableName(element: TypeElement, annotation: Entity): String {
return if (annotation.tableName == "") {
- element.simpleName.toString()
+ element.name
} else {
annotation.tableName
}
@@ -98,7 +98,7 @@
fun EntityProcessor(
context: Context,
element: TypeElement,
- referenceStack: LinkedHashSet<Name> = LinkedHashSet()
+ referenceStack: LinkedHashSet<String> = LinkedHashSet()
): EntityProcessor {
return if (element.hasAnyOf(Fts3::class, Fts4::class)) {
FtsTableEntityProcessor(context, element, referenceStack)
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/FieldProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/FieldProcessor.kt
index a81bc0d..e13dcd5 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/FieldProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/FieldProcessor.kt
@@ -18,6 +18,7 @@
import androidx.room.ColumnInfo
import androidx.room.ext.asMemberOf
+import androidx.room.ext.name
import androidx.room.ext.toAnnotationBox
import androidx.room.ext.typeName
import androidx.room.parser.Collate
@@ -44,7 +45,7 @@
)
val type = member.typeName()
val columnInfo = element.toAnnotationBox(ColumnInfo::class)?.value
- val name = element.simpleName.toString()
+ val name = element.name
val rawCName = if (columnInfo != null && columnInfo.name != ColumnInfo.INHERIT_FIELD_NAME) {
columnInfo.name
} else {
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/FtsTableEntityProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/FtsTableEntityProcessor.kt
index c17a6bd..ed4b492 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/FtsTableEntityProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/FtsTableEntityProcessor.kt
@@ -22,6 +22,7 @@
import androidx.room.FtsOptions.Order
import androidx.room.ext.AnnotationBox
import androidx.room.ext.hasAnnotation
+import androidx.room.ext.name
import androidx.room.ext.requireTypeMirror
import androidx.room.ext.toAnnotationBox
import androidx.room.parser.FtsVersion
@@ -40,14 +41,13 @@
import androidx.room.vo.columnNames
import asTypeElement
import isSameType
-import javax.lang.model.element.Name
import javax.lang.model.element.TypeElement
import javax.lang.model.type.TypeMirror
class FtsTableEntityProcessor internal constructor(
baseContext: Context,
val element: TypeElement,
- private val referenceStack: LinkedHashSet<Name> = LinkedHashSet()
+ private val referenceStack: LinkedHashSet<String> = LinkedHashSet()
) : EntityProcessor {
val context = baseContext.fork(element)
@@ -70,7 +70,7 @@
context.checker.check(extractForeignKeys(entityAnnotation).isEmpty(),
element, ProcessorErrors.FOREIGN_KEYS_IN_FTS_ENTITY)
} else {
- tableName = element.simpleName.toString()
+ tableName = element.name
}
val pojo = PojoProcessor.createFor(
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/InsertionMethodProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/InsertionMethodProcessor.kt
index b4583c4..802d158 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/InsertionMethodProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/InsertionMethodProcessor.kt
@@ -21,6 +21,7 @@
import androidx.room.Insert
import androidx.room.OnConflictStrategy.IGNORE
import androidx.room.OnConflictStrategy.REPLACE
+import androidx.room.ext.name
import androidx.room.ext.typeName
import androidx.room.vo.InsertionMethod
import androidx.room.vo.findFieldByColumnName
@@ -88,7 +89,7 @@
return InsertionMethod(
element = executableElement,
- name = executableElement.simpleName.toString(),
+ name = executableElement.name,
returnType = returnType,
entities = entities,
parameters = params,
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/MethodProcessorDelegate.kt b/room/compiler/src/main/kotlin/androidx/room/processor/MethodProcessorDelegate.kt
index 6046232..c1daa46 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/MethodProcessorDelegate.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/MethodProcessorDelegate.kt
@@ -24,6 +24,7 @@
import androidx.room.ext.asMemberOf
import androidx.room.ext.findTypeElement
import androidx.room.ext.getSuspendFunctionReturnType
+import androidx.room.ext.name
import androidx.room.ext.requireTypeMirror
import androidx.room.ext.type
import androidx.room.kotlin.KotlinMetadataElement
@@ -164,7 +165,7 @@
override fun findTransactionMethodBinder(callType: TransactionMethod.CallType) =
InstantTransactionMethodBinder(
- TransactionMethodAdapter(executableElement.simpleName.toString(), callType))
+ TransactionMethodAdapter(executableElement.name, callType))
}
/**
@@ -201,7 +202,7 @@
CoroutineResultBinder(
typeArg = returnType,
adapter = context.typeAdapterStore.findQueryResultAdapter(returnType, query),
- continuationParamName = continuationParam.simpleName.toString()
+ continuationParamName = continuationParam.name
)
override fun findPreparedResultBinder(
@@ -217,7 +218,7 @@
dbField,
"true", // inTransaction
callableImpl,
- continuationParam.simpleName.toString()
+ continuationParam.name
)
}
@@ -234,7 +235,7 @@
dbField,
"true", // inTransaction
callableImpl,
- continuationParam.simpleName.toString()
+ continuationParam.name
)
}
@@ -249,13 +250,13 @@
dbField,
"true", // inTransaction
callableImpl,
- continuationParam.simpleName.toString()
+ continuationParam.name
)
}
override fun findTransactionMethodBinder(callType: TransactionMethod.CallType) =
CoroutineTransactionMethodBinder(
- adapter = TransactionMethodAdapter(executableElement.simpleName.toString(), callType),
- continuationParamName = continuationParam.simpleName.toString()
+ adapter = TransactionMethodAdapter(executableElement.name, callType),
+ continuationParamName = continuationParam.name
)
}
\ No newline at end of file
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/PojoMethodProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/PojoMethodProcessor.kt
index 3478f55..e2b5db7 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/PojoMethodProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/PojoMethodProcessor.kt
@@ -17,6 +17,7 @@
package androidx.room.processor
import androidx.room.ext.asMemberOf
+import androidx.room.ext.name
import androidx.room.vo.PojoMethod
import javax.lang.model.element.ExecutableElement
import javax.lang.model.type.DeclaredType
@@ -34,11 +35,10 @@
context.processingEnv.typeUtils,
owner
)
- val name = element.simpleName.toString()
return PojoMethod(
element = element,
resolvedType = asMember,
- name = name
+ name = element.name
)
}
}
\ No newline at end of file
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/PojoProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/PojoProcessor.kt
index 642e321..768d4e2 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/PojoProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/PojoProcessor.kt
@@ -40,6 +40,7 @@
import androidx.room.ext.isStatic
import androidx.room.ext.isTransient
import androidx.room.ext.kindName
+import androidx.room.ext.name
import androidx.room.ext.toAnnotationBox
import androidx.room.ext.type
import androidx.room.ext.typeName
@@ -72,7 +73,6 @@
import isTypeOf
import isVoid
import javax.lang.model.element.ExecutableElement
-import javax.lang.model.element.Name
import javax.lang.model.element.TypeElement
import javax.lang.model.element.VariableElement
import javax.lang.model.type.DeclaredType
@@ -86,7 +86,7 @@
val element: TypeElement,
val bindingScope: FieldProcessor.BindingScope,
val parent: EmbeddedField?,
- val referenceStack: LinkedHashSet<Name> = LinkedHashSet(),
+ val referenceStack: LinkedHashSet<String> = LinkedHashSet(),
private val delegate: Delegate
) {
val context = baseContext.fork(element)
@@ -104,7 +104,7 @@
element: TypeElement,
bindingScope: FieldProcessor.BindingScope,
parent: EmbeddedField?,
- referenceStack: LinkedHashSet<Name> = LinkedHashSet()
+ referenceStack: LinkedHashSet<String> = LinkedHashSet()
): PojoProcessor {
val (pojoElement, delegate) = if (element.hasAnnotation(AutoValue::class)) {
val processingEnv = context.processingEnv
@@ -129,11 +129,11 @@
fun process(): Pojo {
return context.cache.pojos.get(Cache.PojoKey(element, bindingScope, parent)) {
- referenceStack.add(element.qualifiedName)
+ referenceStack.add(element.qualifiedName.toString())
try {
doProcess()
} finally {
- referenceStack.remove(element.qualifiedName)
+ referenceStack.remove(element.qualifiedName.toString())
}
}
}
@@ -283,7 +283,7 @@
* better than not supporting these until JB provides a proper API.
*/
private fun getParamNames(method: ExecutableElement): List<String> {
- val paramNames = method.parameters.map { it.simpleName.toString() }
+ val paramNames = method.parameters.map { it.name }
if (paramNames.isEmpty()) {
return emptyList()
}
@@ -430,7 +430,7 @@
val inheritedPrefix = parent?.prefix ?: ""
val embeddedField = Field(
variableElement,
- variableElement.simpleName.toString(),
+ variableElement.name,
type = asMemberType,
affinity = null,
parent = parent)
@@ -590,7 +590,7 @@
val field = Field(
element = relationElement,
- name = relationElement.simpleName.toString(),
+ name = relationElement.name,
type = relationElement.asMemberOf(
context.processingEnv.typeUtils,
container
@@ -668,7 +668,7 @@
}
private fun detectReferenceRecursion(typeElement: TypeElement): Boolean {
- if (referenceStack.contains(typeElement.qualifiedName)) {
+ if (referenceStack.contains(typeElement.qualifiedName.toString())) {
context.logger.e(
typeElement,
ProcessorErrors
@@ -680,9 +680,9 @@
}
private fun computeReferenceRecursionString(typeElement: TypeElement): String {
- val recursiveTailTypeName = typeElement.qualifiedName
+ val recursiveTailTypeName = typeElement.qualifiedName.toString()
- val referenceRecursionList = mutableListOf<Name>()
+ val referenceRecursionList = mutableListOf<String>()
with(referenceRecursionList) {
add(recursiveTailTypeName)
addAll(referenceStack.toList().takeLastWhile { it != recursiveTailTypeName })
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
index 2d7fe25..b0f0a08 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
@@ -20,6 +20,7 @@
import androidx.room.SkipQueryVerification
import androidx.room.Transaction
import androidx.room.ext.hasAnnotation
+import androidx.room.ext.name
import androidx.room.ext.toAnnotationBox
import androidx.room.ext.typeName
import androidx.room.parser.ParsedQuery
@@ -193,7 +194,7 @@
return WriteQueryMethod(
element = executableElement,
query = query,
- name = executableElement.simpleName.toString(),
+ name = executableElement.name,
returnType = returnType,
parameters = parameters,
preparedQueryResultBinder = resultBinder
@@ -229,7 +230,7 @@
return ReadQueryMethod(
element = executableElement,
query = query,
- name = executableElement.simpleName.toString(),
+ name = executableElement.name,
returnType = returnType,
parameters = parameters,
inTransaction = inTransaction,
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/QueryParameterProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/QueryParameterProcessor.kt
index 8631f25..279aac3 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/QueryParameterProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/QueryParameterProcessor.kt
@@ -17,6 +17,7 @@
package androidx.room.processor
import androidx.room.ext.asMemberOf
+import androidx.room.ext.name
import androidx.room.vo.QueryParameter
import javax.lang.model.element.VariableElement
import javax.lang.model.type.DeclaredType
@@ -37,7 +38,7 @@
context.checker.check(parameterAdapter != null, element,
ProcessorErrors.CANNOT_BIND_QUERY_PARAMETER_INTO_STMT)
- val name = element.simpleName.toString()
+ val name = element.name
context.checker.check(!name.startsWith("_"), element,
ProcessorErrors.QUERY_PARAMETERS_CANNOT_START_WITH_UNDERSCORE)
return QueryParameter(
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/RawQueryMethodProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/RawQueryMethodProcessor.kt
index 832af1e..6b81e0d 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/RawQueryMethodProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/RawQueryMethodProcessor.kt
@@ -22,6 +22,7 @@
import androidx.room.ext.asMemberOf
import androidx.room.ext.hasAnnotation
import androidx.room.ext.isEntityElement
+import androidx.room.ext.name
import androidx.room.ext.requireTypeMirror
import androidx.room.ext.toAnnotationBox
import androidx.room.ext.type
@@ -60,7 +61,7 @@
val inTransaction = executableElement.hasAnnotation(Transaction::class)
val rawQueryMethod = RawQueryMethod(
element = executableElement,
- name = executableElement.simpleName.toString(),
+ name = executableElement.name,
observedTableNames = observedTableNames,
returnType = returnType,
runtimeQueryParam = runtimeQueryParam,
@@ -115,7 +116,7 @@
val isSupportSql = supportQueryType.isAssignableFrom(types, param)
if (isSupportSql) {
return RawQueryMethod.RuntimeQueryParameter(
- paramName = extractParams[0].simpleName.toString(),
+ paramName = extractParams[0].name,
type = supportQueryType.typeName())
}
val stringType = processingEnv.requireTypeMirror("java.lang.String")
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/ShortcutParameterProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/ShortcutParameterProcessor.kt
index 68b011d..fd6b658 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/ShortcutParameterProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/ShortcutParameterProcessor.kt
@@ -19,6 +19,7 @@
import androidx.room.ext.asMemberOf
import androidx.room.ext.extendsBound
import androidx.room.ext.getAllNonPrivateInstanceMethods
+import androidx.room.ext.name
import androidx.room.ext.requireTypeMirror
import androidx.room.vo.ShortcutQueryParameter
import asDeclaredType
@@ -45,7 +46,7 @@
context.processingEnv.typeUtils,
containing
)
- val name = element.simpleName.toString()
+ val name = element.name
context.checker.check(!name.startsWith("_"), element,
ProcessorErrors.QUERY_PARAMETERS_CANNOT_START_WITH_UNDERSCORE)
@@ -78,7 +79,7 @@
fun extractPojoTypeFromIterator(iterableType: DeclaredType): TypeMirror {
iterableType.asTypeElement().getAllNonPrivateInstanceMethods(processingEnv).forEach {
- if (it.simpleName.toString() == "iterator") {
+ if (it.name == "iterator") {
return it.asMemberOf(typeUtils, iterableType)
.returnType
.asDeclaredType()
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/TableEntityProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/TableEntityProcessor.kt
index ff0412e..d28e888 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/TableEntityProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/TableEntityProcessor.kt
@@ -16,6 +16,7 @@
package androidx.room.processor
+import androidx.room.ext.name
import androidx.room.ext.toAnnotationBox
import androidx.room.parser.SQLTypeAffinity
import androidx.room.parser.SqlParser
@@ -40,14 +41,13 @@
import asTypeElement
import isNone
import isNotNone
-import javax.lang.model.element.Name
import javax.lang.model.element.TypeElement
import javax.lang.model.type.TypeMirror
class TableEntityProcessor internal constructor(
baseContext: Context,
val element: TypeElement,
- private val referenceStack: LinkedHashSet<Name> = LinkedHashSet()
+ private val referenceStack: LinkedHashSet<String> = LinkedHashSet()
) : EntityProcessor {
val context = baseContext.fork(element)
@@ -71,7 +71,7 @@
inheritSuperIndices = annotationBox.value.inheritSuperIndices
foreignKeyInputs = extractForeignKeys(annotationBox)
} else {
- tableName = element.simpleName.toString()
+ tableName = element.name
foreignKeyInputs = emptyList()
entityIndices = emptyList()
inheritSuperIndices = false
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/TransactionMethodProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/TransactionMethodProcessor.kt
index 48b287e..f5808d2 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/TransactionMethodProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/TransactionMethodProcessor.kt
@@ -25,6 +25,7 @@
import androidx.room.ext.isAbstract
import androidx.room.ext.isJavaDefault
import androidx.room.ext.isOverrideableIgnoringContainer
+import androidx.room.ext.name
import androidx.room.vo.TransactionMethod
import erasure
import isAssignableFrom
@@ -74,7 +75,7 @@
return TransactionMethod(
element = executableElement,
returnType = returnType,
- parameterNames = delegate.extractParams().map { it.simpleName.toString() },
+ parameterNames = delegate.extractParams().map { it.name },
callType = callType,
methodBinder = delegate.findTransactionMethodBinder(callType))
}
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/UpdateMethodProcessor.kt b/room/compiler/src/main/kotlin/androidx/room/processor/UpdateMethodProcessor.kt
index d6d3d9c..10a9e93 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/UpdateMethodProcessor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/UpdateMethodProcessor.kt
@@ -19,6 +19,7 @@
import androidx.room.OnConflictStrategy.IGNORE
import androidx.room.OnConflictStrategy.REPLACE
import androidx.room.Update
+import androidx.room.ext.name
import androidx.room.vo.UpdateMethod
import androidx.room.vo.findFieldByColumnName
import javax.lang.model.element.ExecutableElement
@@ -66,7 +67,7 @@
return UpdateMethod(
element = delegate.executableElement,
- name = delegate.executableElement.simpleName.toString(),
+ name = delegate.executableElement.name,
entities = entities,
onConflictStrategy = onConflict,
methodBinder = methodBinder,
diff --git a/room/compiler/src/main/kotlin/androidx/room/processor/autovalue/AutoValuePojoProcessorDelegate.kt b/room/compiler/src/main/kotlin/androidx/room/processor/autovalue/AutoValuePojoProcessorDelegate.kt
index e065db7..c6d1ba1 100644
--- a/room/compiler/src/main/kotlin/androidx/room/processor/autovalue/AutoValuePojoProcessorDelegate.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/processor/autovalue/AutoValuePojoProcessorDelegate.kt
@@ -29,6 +29,7 @@
import androidx.room.ext.isStatic
import androidx.room.ext.isType
import androidx.room.ext.kindName
+import androidx.room.ext.name
import androidx.room.ext.type
import androidx.room.ext.typeName
import androidx.room.processor.Context
@@ -120,10 +121,10 @@
*/
fun getGeneratedClassName(element: TypeElement): String {
var type = element
- var name = type.simpleName.toString()
+ var name = type.name
while (type.enclosingElement.isType()) {
type = type.enclosingElement.asTypeElement()
- name = "${type.simpleName}_$name"
+ name = "${type.name}_$name"
}
val pkg = type.getPackage()
return "$pkg${if (pkg.isEmpty()) "" else "."}AutoValue_$name"
diff --git a/room/compiler/src/main/kotlin/androidx/room/vo/Constructor.kt b/room/compiler/src/main/kotlin/androidx/room/vo/Constructor.kt
index 45b2fde..eee8a6a 100644
--- a/room/compiler/src/main/kotlin/androidx/room/vo/Constructor.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/vo/Constructor.kt
@@ -22,6 +22,7 @@
import androidx.room.ext.isConstructor
import androidx.room.ext.isMethod
import androidx.room.ext.kindName
+import androidx.room.ext.name
import androidx.room.ext.typeName
import com.squareup.javapoet.CodeBlock
import javax.lang.model.element.ExecutableElement
@@ -52,7 +53,7 @@
element.isMethod() -> {
builder.addStatement("$L = $T.$L($L)", outVar,
element.enclosingElement.asDeclaredType().typeName(),
- element.simpleName.toString(), args)
+ element.name, args)
}
else -> throw IllegalStateException("Invalid constructor kind ${element.kindName()}")
}
diff --git a/room/compiler/src/main/kotlin/androidx/room/vo/CustomTypeConverter.kt b/room/compiler/src/main/kotlin/androidx/room/vo/CustomTypeConverter.kt
index a190c4f..986fa79 100644
--- a/room/compiler/src/main/kotlin/androidx/room/vo/CustomTypeConverter.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/vo/CustomTypeConverter.kt
@@ -17,6 +17,7 @@
package androidx.room.vo
import androidx.room.ext.isStatic
+import androidx.room.ext.name
import androidx.room.ext.typeName
import com.squareup.javapoet.TypeName
import javax.lang.model.element.ExecutableElement
@@ -35,6 +36,6 @@
val typeName: TypeName by lazy { enclosingClass.typeName() }
val fromTypeName: TypeName by lazy { from.typeName() }
val toTypeName: TypeName by lazy { to.typeName() }
- val methodName by lazy { method.simpleName.toString() }
+ val methodName by lazy { method.name }
val isStatic by lazy { method.isStatic() }
}
diff --git a/room/compiler/src/main/kotlin/androidx/room/vo/DaoMethod.kt b/room/compiler/src/main/kotlin/androidx/room/vo/DaoMethod.kt
index 9266294..9c52209b 100644
--- a/room/compiler/src/main/kotlin/androidx/room/vo/DaoMethod.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/vo/DaoMethod.kt
@@ -16,9 +16,9 @@
package androidx.room.vo
-import javax.lang.model.element.Element
+import javax.lang.model.element.ExecutableElement
/**
* References a method that returns a dao in a Database
*/
-data class DaoMethod(val element: Element, val name: String, val dao: Dao)
+data class DaoMethod(val element: ExecutableElement, val name: String, val dao: Dao)
diff --git a/room/compiler/src/main/kotlin/androidx/room/writer/DaoWriter.kt b/room/compiler/src/main/kotlin/androidx/room/writer/DaoWriter.kt
index 367dfbc..0955ff1 100644
--- a/room/compiler/src/main/kotlin/androidx/room/writer/DaoWriter.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/writer/DaoWriter.kt
@@ -23,6 +23,7 @@
import androidx.room.ext.T
import androidx.room.ext.asDeclaredType
import androidx.room.ext.isInterface
+import androidx.room.ext.name
import androidx.room.processor.OnConflictProcessor
import androidx.room.solver.CodeGenScope
import androidx.room.solver.KotlinDefaultMethodDelegateBinder
@@ -439,9 +440,9 @@
KotlinDefaultMethodDelegateBinder.executeAndReturn(
daoName = dao.typeName,
daoImplName = dao.implTypeName,
- methodName = method.delegateElement.simpleName.toString(),
+ methodName = method.delegateElement.name,
returnType = method.element.returnType,
- parameterNames = method.element.parameters.map { it.simpleName.toString() },
+ parameterNames = method.element.parameters.map { it.name },
scope = scope)
addCode(scope.builder().build())
}.build()
diff --git a/room/compiler/src/main/kotlin/androidx/room/writer/EntityInsertionAdapterWriter.kt b/room/compiler/src/main/kotlin/androidx/room/writer/EntityInsertionAdapterWriter.kt
index dd1ff92..f2163b5 100644
--- a/room/compiler/src/main/kotlin/androidx/room/writer/EntityInsertionAdapterWriter.kt
+++ b/room/compiler/src/main/kotlin/androidx/room/writer/EntityInsertionAdapterWriter.kt
@@ -31,6 +31,7 @@
import com.squareup.javapoet.ParameterizedTypeName
import com.squareup.javapoet.TypeName
import com.squareup.javapoet.TypeSpec
+import isPrimitive
import javax.lang.model.element.Modifier.PUBLIC
class EntityInsertionAdapterWriter private constructor(
@@ -46,7 +47,7 @@
val primitiveAutoGenerateField = if (entity.primaryKey.autoGenerateId) {
entity.primaryKey.fields.firstOrNull()?.let { field ->
field.statementBinder?.typeMirror()?.let { binderType ->
- if (binderType.kind.isPrimitive) {
+ if (binderType.isPrimitive()) {
field
} else {
null
diff --git a/room/compiler/src/test/kotlin/androidx/room/ext/ElementExtTest.kt b/room/compiler/src/test/kotlin/androidx/room/ext/ElementExtTest.kt
index f5a04c4..0f5c55d 100644
--- a/room/compiler/src/test/kotlin/androidx/room/ext/ElementExtTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/ext/ElementExtTest.kt
@@ -66,7 +66,7 @@
val child = it.processingEnv.requireTypeElement("foo.bar.Child")
val objectMethods = it.processingEnv.requireTypeElement("java.lang.Object")
.getAllMethods(it.processingEnv).map {
- it.simpleName.toString()
+ it.name
} - "registerNatives"
val parentMethods = listOf(
"parentPrivate", "parentPublic", "parentStaticPrivate",
@@ -141,7 +141,7 @@
val child = it.processingEnv.requireTypeElement("foo.bar.Child")
val objectMethods = it.processingEnv.requireTypeElement("java.lang.Object")
.getAllMethods(it.processingEnv).map {
- it.simpleName.toString()
+ it.name
} - listOf("registerNatives", "clone", "finalize")
val parentMethods = listOf(
"parentPublic", "parentStaticPrivate", "parentStaticPublic", "overridden"
@@ -193,11 +193,11 @@
val element = it.processingEnv.requireTypeElement("foo.bar.Baz")
val field = element.getAllFieldsIncludingPrivateSupers(it.processingEnv)
.first {
- it.simpleName.toString() == "field"
+ it.name == "field"
}
val method = element.getDeclaredMethods()
.first {
- it.simpleName.toString() == "method"
+ it.name == "method"
}
assertThat(field.type.typeName()).isEqualTo(TypeName.INT)
assertThat(method.returnType.typeName()).isEqualTo(TypeName.INT)
@@ -232,6 +232,6 @@
}
private fun assertThat(executables: Iterable<ExecutableElement>) = assertThat(
- executables.map { it.simpleName.toString() }
+ executables.map { it.name }
)
}
\ No newline at end of file
diff --git a/room/compiler/src/test/kotlin/androidx/room/kotlin/KotlinMetadataElementTest.kt b/room/compiler/src/test/kotlin/androidx/room/kotlin/KotlinMetadataElementTest.kt
index c99a86d..66d1152 100644
--- a/room/compiler/src/test/kotlin/androidx/room/kotlin/KotlinMetadataElementTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/kotlin/KotlinMetadataElementTest.kt
@@ -19,6 +19,7 @@
import androidx.room.ext.asExecutableElement
import androidx.room.ext.getConstructors
import androidx.room.ext.getDeclaredMethods
+import androidx.room.ext.name
import androidx.room.ext.requireTypeElement
import androidx.room.processor.Context
import androidx.room.testing.TestInvocation
@@ -40,7 +41,7 @@
TestData::class
)
assertThat(testClassElement.getDeclaredMethods()
- .first { it.simpleName.toString() == "functionWithParams" }
+ .first { it.name == "functionWithParams" }
.let { metadataElement.getParameterNames(it.asExecutableElement()) }
).isEqualTo(
listOf("param1", "yesOrNo", "number")
@@ -76,7 +77,7 @@
)
assertThat(testClassElement.getDeclaredMethods().map {
val executableElement = it.asExecutableElement()
- executableElement.simpleName.toString() to metadataElement.isSuspendFunction(
+ executableElement.name to metadataElement.isSuspendFunction(
executableElement
)
}).containsExactly(
diff --git a/room/compiler/src/test/kotlin/androidx/room/processor/TransactionMethodProcessorTest.kt b/room/compiler/src/test/kotlin/androidx/room/processor/TransactionMethodProcessorTest.kt
index 1e46eb3..1bdcf39 100644
--- a/room/compiler/src/test/kotlin/androidx/room/processor/TransactionMethodProcessorTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/processor/TransactionMethodProcessorTest.kt
@@ -24,6 +24,7 @@
import androidx.room.ext.asTypeElement
import androidx.room.ext.getAllMethods
import androidx.room.ext.hasAnnotation
+import androidx.room.ext.name
import androidx.room.testing.TestInvocation
import androidx.room.testing.TestProcessor
import androidx.room.vo.TransactionMethod
@@ -222,7 +223,7 @@
}
private val TransactionMethod.name: String
- get() = element.simpleName.toString()
+ get() = element.name
private fun singleTransactionMethod(
vararg input: String,
diff --git a/room/compiler/src/test/kotlin/androidx/room/solver/TypeAssignmentTest.kt b/room/compiler/src/test/kotlin/androidx/room/solver/TypeAssignmentTest.kt
index 00f55d1..c85dd25 100644
--- a/room/compiler/src/test/kotlin/androidx/room/solver/TypeAssignmentTest.kt
+++ b/room/compiler/src/test/kotlin/androidx/room/solver/TypeAssignmentTest.kt
@@ -18,6 +18,7 @@
import androidx.room.ext.getAllFieldsIncludingPrivateSupers
import androidx.room.ext.isAssignableFromWithoutVariance
+import androidx.room.ext.name
import androidx.room.ext.requireTypeElement
import androidx.room.ext.type
import androidx.room.testing.TestInvocation
@@ -106,7 +107,7 @@
name: String
): VariableElement {
return getAllFieldsIncludingPrivateSupers(env).first {
- it.simpleName.toString() == name
+ it.name == name
}
}
diff --git a/ui/integration-tests/benchmark/build.gradle b/ui/integration-tests/benchmark/build.gradle
index 3166750..069444f 100644
--- a/ui/integration-tests/benchmark/build.gradle
+++ b/ui/integration-tests/benchmark/build.gradle
@@ -34,7 +34,7 @@
implementation project(":benchmark:benchmark-junit4")
implementation project(":compose:runtime:runtime")
- implementation project(":ui:integration-tests")
+ implementation project(":compose:integration-tests")
implementation project(":compose:test:test-core")
implementation project(":compose:foundation:foundation-layout")
implementation(KOTLIN_STDLIB)
@@ -54,11 +54,10 @@
}
androidx {
- name = "UI Benchmarks"
+ name = "Compose Benchmarks"
publish = Publish.NONE
- mavenGroup = LibraryGroups.UI
inceptionYear = "2019"
- description = "UI Benchmarks"
+ description = "Compose Benchmarks"
}
android.defaultConfig.minSdkVersion 21
diff --git a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/LayoutNodeModifierBenchmark.kt b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/LayoutNodeModifierBenchmark.kt
index 073e41f..065bace 100644
--- a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/LayoutNodeModifierBenchmark.kt
+++ b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/LayoutNodeModifierBenchmark.kt
@@ -78,7 +78,7 @@
Modifier.drawBehind { },
Modifier.drawLayer(),
Modifier.keyInputFilter { _ -> true },
- Modifier.semantics(),
+ Modifier.semantics { },
Modifier.pressIndicatorGestureFilter(),
Modifier.layoutId("Hello"),
Modifier.padding(10.dp),
diff --git a/ui/integration-tests/build.gradle b/ui/integration-tests/build.gradle
index 917e793..dfffac1 100644
--- a/ui/integration-tests/build.gradle
+++ b/ui/integration-tests/build.gradle
@@ -47,11 +47,10 @@
}
androidx {
- name = "UI Integration Tests"
+ name = "Compose Integration Tests"
publish = Publish.NONE
- mavenGroup = LibraryGroups.UI
inceptionYear = "2019"
- description = "UI Integration Tests"
+ description = "Compose Integration Tests"
}
android.defaultConfig.minSdkVersion 21
diff --git a/ui/integration-tests/demos/build.gradle b/ui/integration-tests/demos/build.gradle
index a0ea15b..b40f472 100644
--- a/ui/integration-tests/demos/build.gradle
+++ b/ui/integration-tests/demos/build.gradle
@@ -12,7 +12,7 @@
dependencies {
kotlinPlugin project(path: ":compose:compose-compiler")
- implementation project(":ui:ui-android-view:integration-tests:ui-android-view-demos")
+ implementation project(":compose:android-view:android-view:integration-tests:android-view-demos")
implementation project(":compose:animation:animation:integration-tests:animation-demos")
implementation project(":compose:foundation:foundation:integration-tests:foundation-demos")
implementation project(":compose:core:core:integration-tests:core-demos")
@@ -25,20 +25,20 @@
implementation(KOTLIN_STDLIB)
implementation project(":compose:runtime:runtime")
- implementation project(":ui:ui-android-view")
+ implementation project(":compose:android-view:android-view")
implementation project(":compose:core:core")
implementation project(":compose:foundation:foundation-layout")
implementation project(":compose:foundation:foundation-text")
implementation project(":compose:foundation:foundation")
implementation project(":compose:material:material")
- implementation project(":ui:integration-tests:demos:common")
+ implementation project(":compose:integration-tests:demos:common")
implementation "androidx.preference:preference-ktx:1.1.0"
androidTestImplementation project(":compose:test:test-core")
// TODO: presumably shouldn't need to specify these again? figure out why this is needed.
- androidTestImplementation project(":ui:ui-android-view:integration-tests:ui-android-view-demos")
+ androidTestImplementation project(":compose:android-view:android-view:integration-tests:android-view-demos")
androidTestImplementation project(":compose:animation:animation:integration-tests:animation-demos")
androidTestImplementation project(":compose:foundation:foundation:integration-tests:foundation-demos")
androidTestImplementation project(":compose:core:core:integration-tests:core-demos")
diff --git a/ui/integration-tests/demos/src/androidTest/java/androidx/ui/demos/test/DemoTest.kt b/ui/integration-tests/demos/src/androidTest/java/androidx/ui/demos/test/DemoTest.kt
index dcfa88c..def3e38 100644
--- a/ui/integration-tests/demos/src/androidTest/java/androidx/ui/demos/test/DemoTest.kt
+++ b/ui/integration-tests/demos/src/androidTest/java/androidx/ui/demos/test/DemoTest.kt
@@ -30,12 +30,12 @@
import androidx.ui.test.SemanticsNodeInteractionCollection
import androidx.ui.test.android.AndroidComposeTestRule
import androidx.ui.test.assertTextEquals
-import androidx.ui.test.doClick
-import androidx.ui.test.doScrollTo
-import androidx.ui.test.find
-import androidx.ui.test.findAll
-import androidx.ui.test.findByTag
-import androidx.ui.test.findByText
+import androidx.ui.test.performClick
+import androidx.ui.test.performScrollTo
+import androidx.ui.test.onNode
+import androidx.ui.test.onAllNodes
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onNodeWithText
import androidx.ui.test.hasClickAction
import androidx.ui.test.hasText
import androidx.ui.test.isDialog
@@ -60,7 +60,7 @@
fun testFiltering() {
assertIsOnRootScreen()
// Enter filtering mode
- findByTag(Tags.FilterButton).doClick()
+ onNodeWithTag(Tags.FilterButton).performClick()
waitForIdle()
composeTestRule.clockTestRule.advanceClock(5000)
@@ -73,7 +73,7 @@
.first()
// Click on the first demo
val demoTitle = testDemo.title
- findByText(demoTitle).doScrollTo().doClick()
+ onNodeWithText(demoTitle).performScrollTo().performClick()
waitForIdle()
assertAppBarHasTitle(demoTitle)
@@ -156,10 +156,10 @@
path.drop(1).joinToString(" > ")
}
- find(hasText(title) and hasClickAction())
+ onNode(hasText(title) and hasClickAction())
.assertExists("Couldn't find \"$title\" in \"$navigationTitle\"")
- .doScrollTo()
- .doClick()
+ .performScrollTo()
+ .performClick()
waitForIdle()
composeTestRule.clockTestRule.advanceClock(5000)
@@ -174,7 +174,7 @@
// Don't `findAll` in WebComponentActivity, it doesn't have an AndroidOwner
if (title != "WebComponent") {
- while (findAll(isDialog()).isNotEmpty()) {
+ while (onAllNodes(isDialog()).isNotEmpty()) {
waitForIdle()
Espresso.pressBack()
}
@@ -199,7 +199,7 @@
* Asserts that the app bar title matches the given [title].
*/
private fun assertAppBarHasTitle(title: String) =
- findByTag(Tags.AppBarTitle).assertTextEquals(title)
+ onNodeWithTag(Tags.AppBarTitle).assertTextEquals(title)
private fun SemanticsNodeInteractionCollection.isNotEmpty(): Boolean {
return fetchSemanticsNodes().isNotEmpty()
diff --git a/ui/integration-tests/src/androidTest/java/androidx/ui/integration/test/VectorAssetTest.kt b/ui/integration-tests/src/androidTest/java/androidx/ui/integration/test/VectorAssetTest.kt
index db585d6..f770f26 100644
--- a/ui/integration-tests/src/androidTest/java/androidx/ui/integration/test/VectorAssetTest.kt
+++ b/ui/integration-tests/src/androidTest/java/androidx/ui/integration/test/VectorAssetTest.kt
@@ -24,7 +24,7 @@
import androidx.ui.integration.test.framework.ProgrammaticVectorTestCase
import androidx.ui.integration.test.framework.XmlVectorTestCase
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Rule
@@ -55,8 +55,8 @@
}
}
- val xmlBitmap = findByTag(xmlTestCase.testTag).captureToBitmap()
- val programmaticBitmap = findByTag(programmaticTestCase.testTag).captureToBitmap()
+ val xmlBitmap = onNodeWithTag(xmlTestCase.testTag).captureToBitmap()
+ val programmaticBitmap = onNodeWithTag(programmaticTestCase.testTag).captureToBitmap()
assertEquals(xmlBitmap.width, programmaticBitmap.width)
assertEquals(xmlBitmap.height, programmaticBitmap.height)
diff --git a/ui/settings.gradle b/ui/settings.gradle
index f425f05..2bb1deb 100644
--- a/ui/settings.gradle
+++ b/ui/settings.gradle
@@ -55,35 +55,36 @@
includeProject(":tracing", "../tracing")
includeProject(":tracing:tracing", "../tracing/tracing")
includeProject(":tracing:tracing-ktx", "../tracing/tracing-ktx")
-includeProject(":ui", "ui")
-includeProject(":ui:integration-tests:benchmark", "integration-tests/benchmark")
-includeProject(":ui:integration-tests:demos", "integration-tests/demos")
-includeProject(":ui:integration-tests:demos:common", "integration-tests/demos/common")
-includeProject(":ui:integration-tests", "integration-tests")
+includeProject(":compose:integration-tests:benchmark", "integration-tests/benchmark")
+includeProject(":compose:integration-tests:demos", "integration-tests/demos")
+includeProject(":compose:integration-tests:demos:common", "integration-tests/demos/common")
+includeProject(":compose:integration-tests", "integration-tests")
includeProject(":compose:core:core-text-android", "ui-text-android")
-includeProject(":ui:ui-android-view", "ui-android-view")
-includeProject(":ui:ui-android-view:integration-tests:ui-android-view-demos", "ui-android-view/integration-tests/android-view-demos")
-includeProject(":ui:ui-android-view:samples", "ui-android-view/samples")
+includeProject(":compose:android-view", "../compose/android-view")
+includeProject(":compose:android-view:android-view", "ui-android-view")
+includeProject(":compose:android-view:android-view:integration-tests:android-view-demos", "ui-android-view/integration-tests/android-view-demos")
+includeProject(":compose:android-view:android-view:samples", "ui-android-view/samples")
includeProject(":compose:animation", "../compose/animation")
includeProject(":compose:animation:animation", "ui-animation")
includeProject(":compose:animation:animation-core", "ui-animation-core")
includeProject(":compose:animation:animation-core:samples", "ui-animation-core/samples")
includeProject(":compose:animation:animation:integration-tests:animation-demos", "ui-animation/integration-tests/animation-demos")
includeProject(":compose:animation:animation:samples", "ui-animation/samples")
-includeProject(":ui:ui-animation-tooling-internal", "ui-animation-tooling-internal")
+includeProject(":compose:tooling:tooling-animation-internal", "ui-animation-tooling-internal")
includeProject(":compose:core:core", "ui-core")
includeProject(":compose:core:core:integration-tests:core-demos", "ui-core/integration-tests/ui-core-demos")
includeProject(":compose:core:core:samples", "ui-core/samples")
if (!startParameter.projectProperties.containsKey('compose.desktop.disable')) {
- includeProject(":ui:ui-desktop", "ui-desktop")
- includeProject(":ui:ui-desktop:android-emu", "ui-desktop/android-emu")
- includeProject(":ui:ui-desktop:samples", "ui-desktop/samples")
+ includeProject(":compose:desktop", "../compose/desktop")
+ includeProject(":compose:desktop:desktop", "ui-desktop")
+ includeProject(":compose:desktop:desktop:android-emu", "ui-desktop/android-emu")
+ includeProject(":compose:desktop:desktop:samples", "ui-desktop/samples")
}
includeProject(":compose:foundation", "../compose/foundation")
includeProject(":compose:foundation:foundation", "ui-foundation")
includeProject(":compose:foundation:foundation:integration-tests:foundation-demos", "ui-foundation/integration-tests/foundation-demos")
includeProject(":compose:foundation:foundation:samples", "ui-foundation/samples")
-includeProject(":ui:ui-internal-lint-checks", "ui-internal-lint-checks")
+includeProject(":compose:internal-lint-checks", "ui-internal-lint-checks")
includeProject(":compose:core", "../compose/core")
includeProject(":compose:core:core-geometry", "ui-geometry")
includeProject(":compose:core:core-graphics", "ui-graphics")
@@ -102,7 +103,7 @@
includeProject(":compose:material:material:icons:generator", "ui-material/icons/generator")
includeProject(":compose:test", "../compose/test")
includeProject(":compose:test:test-core", "ui-test")
-includeProject(":ui:ui-test-font", "ui-test-font")
+includeProject(":compose:core:core-test-font", "ui-test-font")
includeProject(":compose:foundation:foundation-text", "ui-text")
includeProject(":compose:foundation:foundation-text:integration-tests:foundation-text-demos", "ui-text/integration-tests/ui-text-compose-demos")
includeProject(":compose:foundation:foundation-text:samples", "ui-text/samples")
diff --git a/ui/ui-android-view/build.gradle b/ui/ui-android-view/build.gradle
index 4ffdab2..98011d1 100644
--- a/ui/ui-android-view/build.gradle
+++ b/ui/ui-android-view/build.gradle
@@ -61,10 +61,8 @@
}
androidx {
- name = "AndroidX UI View components"
+ name = "Compose View Wrappers"
publish = Publish.NONE
- mavenVersion = LibraryVersions.UI
- mavenGroup = LibraryGroups.UI
inceptionYear = "2019"
- description = "AndroidX UI View wrappers."
+ description = "Compose View Wrappers."
}
diff --git a/ui/ui-android-view/integration-tests/android-view-demos/build.gradle b/ui/ui-android-view/integration-tests/android-view-demos/build.gradle
index a9ad7fe..b39a389 100644
--- a/ui/ui-android-view/integration-tests/android-view-demos/build.gradle
+++ b/ui/ui-android-view/integration-tests/android-view-demos/build.gradle
@@ -31,8 +31,8 @@
implementation(KOTLIN_STDLIB)
implementation project(":compose:runtime:runtime")
- implementation project(":ui:integration-tests:demos:common")
- implementation project(":ui:ui-android-view")
+ implementation project(":compose:integration-tests:demos:common")
+ implementation project(":compose:android-view:android-view")
implementation project(":compose:core:core")
implementation project(":compose:foundation:foundation-layout")
implementation project(":compose:material:material")
diff --git a/ui/ui-android-view/samples/build.gradle b/ui/ui-android-view/samples/build.gradle
index 387c352..3f920f0 100644
--- a/ui/ui-android-view/samples/build.gradle
+++ b/ui/ui-android-view/samples/build.gradle
@@ -36,7 +36,7 @@
implementation project(":compose:foundation:foundation-layout")
implementation project(":compose:foundation:foundation")
implementation project(":compose:core:core-text")
- implementation project(":ui:ui-android-view")
+ implementation project(":compose:android-view:android-view")
}
android {
diff --git a/ui/ui-animation-tooling-internal/build.gradle b/ui/ui-animation-tooling-internal/build.gradle
index 4be1456..10b5114 100644
--- a/ui/ui-animation-tooling-internal/build.gradle
+++ b/ui/ui-animation-tooling-internal/build.gradle
@@ -34,6 +34,6 @@
description = "Compose Animation APIs for tooling support. Internal use only."
publish = Publish.SNAPSHOT_ONLY
mavenVersion = LibraryVersions.UI
- mavenGroup = LibraryGroups.UI
+ mavenGroup = LibraryGroups.Compose.TOOLING
generateDocs = false
}
diff --git a/ui/ui-animation/api/0.1.0-dev15.txt b/ui/ui-animation/api/0.1.0-dev15.txt
index ac3955d52..efbecd3 100644
--- a/ui/ui-animation/api/0.1.0-dev15.txt
+++ b/ui/ui-animation/api/0.1.0-dev15.txt
@@ -115,7 +115,6 @@
return <init>(IntSize(1, 1))
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.IntSize,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static <T extends androidx.animation.AnimationVector> T animate(T target, androidx.animation.AnimationSpec<T> animSpec = remember({
- android.util.Log.w("LTD", "visibility threshold: " + visibilityThreshold)
return <init>(visibilityThreshold)
}), T? visibilityThreshold = null, kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static <T, V extends androidx.animation.AnimationVector> T! animate(T? target, androidx.animation.TwoWayConverter<T,V> converter, androidx.animation.AnimationSpec<T> animSpec = remember({
@@ -133,6 +132,7 @@
}
public final class TransitionKt {
+ method @Deprecated @androidx.compose.Composable public static <T> void Transition(androidx.animation.TransitionDefinition<T> definition, T? toState, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current, T? initState = toState, kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? onStateChangeFinished = null, kotlin.jvm.functions.Function1<? super androidx.animation.TransitionState,kotlin.Unit> children);
method public static boolean getTransitionsEnabled();
method public static void setTransitionsEnabled(boolean p);
method @androidx.compose.Composable public static <T> androidx.animation.TransitionState transition(androidx.animation.TransitionDefinition<T> definition, T? toState, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current, T? initState = toState, kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? onStateChangeFinished = null);
diff --git a/ui/ui-animation/api/current.txt b/ui/ui-animation/api/current.txt
index ac3955d52..efbecd3 100644
--- a/ui/ui-animation/api/current.txt
+++ b/ui/ui-animation/api/current.txt
@@ -115,7 +115,6 @@
return <init>(IntSize(1, 1))
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.IntSize,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static <T extends androidx.animation.AnimationVector> T animate(T target, androidx.animation.AnimationSpec<T> animSpec = remember({
- android.util.Log.w("LTD", "visibility threshold: " + visibilityThreshold)
return <init>(visibilityThreshold)
}), T? visibilityThreshold = null, kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static <T, V extends androidx.animation.AnimationVector> T! animate(T? target, androidx.animation.TwoWayConverter<T,V> converter, androidx.animation.AnimationSpec<T> animSpec = remember({
@@ -133,6 +132,7 @@
}
public final class TransitionKt {
+ method @Deprecated @androidx.compose.Composable public static <T> void Transition(androidx.animation.TransitionDefinition<T> definition, T? toState, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current, T? initState = toState, kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? onStateChangeFinished = null, kotlin.jvm.functions.Function1<? super androidx.animation.TransitionState,kotlin.Unit> children);
method public static boolean getTransitionsEnabled();
method public static void setTransitionsEnabled(boolean p);
method @androidx.compose.Composable public static <T> androidx.animation.TransitionState transition(androidx.animation.TransitionDefinition<T> definition, T? toState, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current, T? initState = toState, kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? onStateChangeFinished = null);
diff --git a/ui/ui-animation/api/public_plus_experimental_0.1.0-dev15.txt b/ui/ui-animation/api/public_plus_experimental_0.1.0-dev15.txt
index ac3955d52..efbecd3 100644
--- a/ui/ui-animation/api/public_plus_experimental_0.1.0-dev15.txt
+++ b/ui/ui-animation/api/public_plus_experimental_0.1.0-dev15.txt
@@ -115,7 +115,6 @@
return <init>(IntSize(1, 1))
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.IntSize,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static <T extends androidx.animation.AnimationVector> T animate(T target, androidx.animation.AnimationSpec<T> animSpec = remember({
- android.util.Log.w("LTD", "visibility threshold: " + visibilityThreshold)
return <init>(visibilityThreshold)
}), T? visibilityThreshold = null, kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static <T, V extends androidx.animation.AnimationVector> T! animate(T? target, androidx.animation.TwoWayConverter<T,V> converter, androidx.animation.AnimationSpec<T> animSpec = remember({
@@ -133,6 +132,7 @@
}
public final class TransitionKt {
+ method @Deprecated @androidx.compose.Composable public static <T> void Transition(androidx.animation.TransitionDefinition<T> definition, T? toState, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current, T? initState = toState, kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? onStateChangeFinished = null, kotlin.jvm.functions.Function1<? super androidx.animation.TransitionState,kotlin.Unit> children);
method public static boolean getTransitionsEnabled();
method public static void setTransitionsEnabled(boolean p);
method @androidx.compose.Composable public static <T> androidx.animation.TransitionState transition(androidx.animation.TransitionDefinition<T> definition, T? toState, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current, T? initState = toState, kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? onStateChangeFinished = null);
diff --git a/ui/ui-animation/api/public_plus_experimental_current.txt b/ui/ui-animation/api/public_plus_experimental_current.txt
index ac3955d52..efbecd3 100644
--- a/ui/ui-animation/api/public_plus_experimental_current.txt
+++ b/ui/ui-animation/api/public_plus_experimental_current.txt
@@ -115,7 +115,6 @@
return <init>(IntSize(1, 1))
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.IntSize,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static <T extends androidx.animation.AnimationVector> T animate(T target, androidx.animation.AnimationSpec<T> animSpec = remember({
- android.util.Log.w("LTD", "visibility threshold: " + visibilityThreshold)
return <init>(visibilityThreshold)
}), T? visibilityThreshold = null, kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static <T, V extends androidx.animation.AnimationVector> T! animate(T? target, androidx.animation.TwoWayConverter<T,V> converter, androidx.animation.AnimationSpec<T> animSpec = remember({
@@ -133,6 +132,7 @@
}
public final class TransitionKt {
+ method @Deprecated @androidx.compose.Composable public static <T> void Transition(androidx.animation.TransitionDefinition<T> definition, T? toState, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current, T? initState = toState, kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? onStateChangeFinished = null, kotlin.jvm.functions.Function1<? super androidx.animation.TransitionState,kotlin.Unit> children);
method public static boolean getTransitionsEnabled();
method public static void setTransitionsEnabled(boolean p);
method @androidx.compose.Composable public static <T> androidx.animation.TransitionState transition(androidx.animation.TransitionDefinition<T> definition, T? toState, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current, T? initState = toState, kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? onStateChangeFinished = null);
diff --git a/ui/ui-animation/api/restricted_0.1.0-dev15.txt b/ui/ui-animation/api/restricted_0.1.0-dev15.txt
index ac3955d52..efbecd3 100644
--- a/ui/ui-animation/api/restricted_0.1.0-dev15.txt
+++ b/ui/ui-animation/api/restricted_0.1.0-dev15.txt
@@ -115,7 +115,6 @@
return <init>(IntSize(1, 1))
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.IntSize,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static <T extends androidx.animation.AnimationVector> T animate(T target, androidx.animation.AnimationSpec<T> animSpec = remember({
- android.util.Log.w("LTD", "visibility threshold: " + visibilityThreshold)
return <init>(visibilityThreshold)
}), T? visibilityThreshold = null, kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static <T, V extends androidx.animation.AnimationVector> T! animate(T? target, androidx.animation.TwoWayConverter<T,V> converter, androidx.animation.AnimationSpec<T> animSpec = remember({
@@ -133,6 +132,7 @@
}
public final class TransitionKt {
+ method @Deprecated @androidx.compose.Composable public static <T> void Transition(androidx.animation.TransitionDefinition<T> definition, T? toState, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current, T? initState = toState, kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? onStateChangeFinished = null, kotlin.jvm.functions.Function1<? super androidx.animation.TransitionState,kotlin.Unit> children);
method public static boolean getTransitionsEnabled();
method public static void setTransitionsEnabled(boolean p);
method @androidx.compose.Composable public static <T> androidx.animation.TransitionState transition(androidx.animation.TransitionDefinition<T> definition, T? toState, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current, T? initState = toState, kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? onStateChangeFinished = null);
diff --git a/ui/ui-animation/api/restricted_current.txt b/ui/ui-animation/api/restricted_current.txt
index ac3955d52..efbecd3 100644
--- a/ui/ui-animation/api/restricted_current.txt
+++ b/ui/ui-animation/api/restricted_current.txt
@@ -115,7 +115,6 @@
return <init>(IntSize(1, 1))
}), kotlin.jvm.functions.Function1<? super androidx.ui.unit.IntSize,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static <T extends androidx.animation.AnimationVector> T animate(T target, androidx.animation.AnimationSpec<T> animSpec = remember({
- android.util.Log.w("LTD", "visibility threshold: " + visibilityThreshold)
return <init>(visibilityThreshold)
}), T? visibilityThreshold = null, kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? endListener = null);
method @androidx.compose.Composable public static <T, V extends androidx.animation.AnimationVector> T! animate(T? target, androidx.animation.TwoWayConverter<T,V> converter, androidx.animation.AnimationSpec<T> animSpec = remember({
@@ -133,6 +132,7 @@
}
public final class TransitionKt {
+ method @Deprecated @androidx.compose.Composable public static <T> void Transition(androidx.animation.TransitionDefinition<T> definition, T? toState, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current, T? initState = toState, kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? onStateChangeFinished = null, kotlin.jvm.functions.Function1<? super androidx.animation.TransitionState,kotlin.Unit> children);
method public static boolean getTransitionsEnabled();
method public static void setTransitionsEnabled(boolean p);
method @androidx.compose.Composable public static <T> androidx.animation.TransitionState transition(androidx.animation.TransitionDefinition<T> definition, T? toState, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current, T? initState = toState, kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? onStateChangeFinished = null);
diff --git a/ui/ui-animation/build.gradle b/ui/ui-animation/build.gradle
index 39c90eb..491a6e3 100644
--- a/ui/ui-animation/build.gradle
+++ b/ui/ui-animation/build.gradle
@@ -25,34 +25,44 @@
id("AndroidXPlugin")
id("com.android.library")
id("AndroidXUiPlugin")
- id("org.jetbrains.kotlin.android")
+ id("kotlin-multiplatform")
}
dependencies {
kotlinPlugin project(path: ":compose:compose-compiler")
+}
- implementation(KOTLIN_STDLIB)
- implementation "org.jetbrains.kotlinx:kotlinx-collections-immutable-jvm:0.3"
+kotlin {
+ android()
+ sourceSets {
+ commonMain.dependencies {
+ implementation(KOTLIN_STDLIB_COMMON)
+ api project(":compose:animation:animation-core")
+ api project(":compose:runtime:runtime")
+ implementation project(":compose:core:core-util")
+ api project(":compose:core:core")
+ api project(":compose:foundation:foundation-layout")
+ api project(":compose:core:core-geometry")
+ }
- api "androidx.annotation:annotation:1.1.0"
+ androidMain.dependencies {
+ api "androidx.annotation:annotation:1.1.0"
+ }
- api project(":compose:animation:animation-core")
+ androidTest.dependencies {
+ implementation(ANDROIDX_TEST_RULES)
+ implementation(ANDROIDX_TEST_RUNNER)
+ implementation(JUNIT)
+ }
- api project(":compose:runtime:runtime")
- implementation project(":compose:core:core-util")
- api project(":compose:core:core")
- api project(":compose:foundation:foundation-layout")
- api project(":compose:core:core-geometry")
-
- testImplementation(ANDROIDX_TEST_RULES)
- testImplementation(ANDROIDX_TEST_RUNNER)
- testImplementation(JUNIT)
-
- androidTestImplementation(ANDROIDX_TEST_RULES)
- androidTestImplementation(ANDROIDX_TEST_RUNNER)
- androidTestImplementation(JUNIT)
- androidTestImplementation project(":compose:foundation:foundation")
- androidTestImplementation project(":compose:test:test-core")
+ androidAndroidTest.dependencies {
+ implementation(ANDROIDX_TEST_RULES)
+ implementation(ANDROIDX_TEST_RUNNER)
+ implementation(JUNIT)
+ implementation project(":compose:foundation:foundation")
+ implementation project(":compose:test:test-core")
+ }
+ }
}
androidx {
diff --git a/ui/ui-animation/integration-tests/animation-demos/build.gradle b/ui/ui-animation/integration-tests/animation-demos/build.gradle
index c8a0485..32a8a17 100644
--- a/ui/ui-animation/integration-tests/animation-demos/build.gradle
+++ b/ui/ui-animation/integration-tests/animation-demos/build.gradle
@@ -15,7 +15,7 @@
implementation(KOTLIN_STDLIB)
implementation project(":compose:runtime:runtime")
- implementation project(":ui:integration-tests:demos:common")
+ implementation project(":compose:integration-tests:demos:common")
implementation project(":compose:core:core")
implementation project(":compose:foundation:foundation-layout")
implementation project(":compose:core:core-text")
diff --git a/ui/ui-animation/src/androidTest/AndroidManifest.xml b/ui/ui-animation/src/androidAndroidTest/AndroidManifest.xml
similarity index 100%
rename from ui/ui-animation/src/androidTest/AndroidManifest.xml
rename to ui/ui-animation/src/androidAndroidTest/AndroidManifest.xml
diff --git a/ui/ui-animation/src/androidTest/java/androidx/ui/animation/CrossfadeTest.kt b/ui/ui-animation/src/androidAndroidTest/kotlin/androidx/ui/animation/CrossfadeTest.kt
similarity index 91%
rename from ui/ui-animation/src/androidTest/java/androidx/ui/animation/CrossfadeTest.kt
rename to ui/ui-animation/src/androidAndroidTest/kotlin/androidx/ui/animation/CrossfadeTest.kt
index 23a3cc7..6a5881f 100644
--- a/ui/ui-animation/src/androidTest/java/androidx/ui/animation/CrossfadeTest.kt
+++ b/ui/ui-animation/src/androidAndroidTest/kotlin/androidx/ui/animation/CrossfadeTest.kt
@@ -25,7 +25,7 @@
import androidx.test.filters.MediumTest
import androidx.ui.foundation.Text
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByText
+import androidx.ui.test.onNodeWithText
import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.waitForIdle
import org.junit.Assert.assertTrue
@@ -53,7 +53,7 @@
}
composeTestRule.clockTestRule.advanceClock(DefaultDurationMillis.toLong())
- findByText(First).assertExists()
+ onNodeWithText(First).assertExists()
}
@Test
@@ -84,8 +84,8 @@
assertTrue(disposed)
}
- findByText(First).assertDoesNotExist()
- findByText(Second).assertExists()
+ onNodeWithText(First).assertDoesNotExist()
+ onNodeWithText(Second).assertExists()
}
@Test
@@ -133,8 +133,8 @@
}
composeTestRule.clockTestRule.advanceClock(DefaultDurationMillis.toLong())
- findByText(First).assertExists()
- findByText(Second).assertDoesNotExist()
+ onNodeWithText(First).assertExists()
+ onNodeWithText(Second).assertDoesNotExist()
runOnIdleCompose {
current = "other"
@@ -144,8 +144,8 @@
composeTestRule.clockTestRule.advanceClock(DefaultDurationMillis.toLong())
- findByText(First).assertDoesNotExist()
- findByText(Second).assertExists()
+ onNodeWithText(First).assertDoesNotExist()
+ onNodeWithText(Second).assertExists()
}
companion object {
diff --git a/ui/ui-animation/src/androidTest/java/androidx/ui/animation/SingleValueAnimationTest.kt b/ui/ui-animation/src/androidAndroidTest/kotlin/androidx/ui/animation/SingleValueAnimationTest.kt
similarity index 100%
rename from ui/ui-animation/src/androidTest/java/androidx/ui/animation/SingleValueAnimationTest.kt
rename to ui/ui-animation/src/androidAndroidTest/kotlin/androidx/ui/animation/SingleValueAnimationTest.kt
diff --git a/ui/ui-animation/src/main/AndroidManifest.xml b/ui/ui-animation/src/androidMain/AndroidManifest.xml
similarity index 100%
rename from ui/ui-animation/src/main/AndroidManifest.xml
rename to ui/ui-animation/src/androidMain/AndroidManifest.xml
diff --git a/ui/ui-animation/src/main/java/androidx/ui/animation/AnimatedValueEffects.kt b/ui/ui-animation/src/commonMain/kotlin/androidx/ui/animation/AnimatedValueEffects.kt
similarity index 100%
rename from ui/ui-animation/src/main/java/androidx/ui/animation/AnimatedValueEffects.kt
rename to ui/ui-animation/src/commonMain/kotlin/androidx/ui/animation/AnimatedValueEffects.kt
diff --git a/ui/ui-animation/src/main/java/androidx/ui/animation/Crossfade.kt b/ui/ui-animation/src/commonMain/kotlin/androidx/ui/animation/Crossfade.kt
similarity index 100%
rename from ui/ui-animation/src/main/java/androidx/ui/animation/Crossfade.kt
rename to ui/ui-animation/src/commonMain/kotlin/androidx/ui/animation/Crossfade.kt
diff --git a/ui/ui-animation/src/main/java/androidx/ui/animation/DisposableAnimationClock.kt b/ui/ui-animation/src/commonMain/kotlin/androidx/ui/animation/DisposableAnimationClock.kt
similarity index 74%
rename from ui/ui-animation/src/main/java/androidx/ui/animation/DisposableAnimationClock.kt
rename to ui/ui-animation/src/commonMain/kotlin/androidx/ui/animation/DisposableAnimationClock.kt
index e9df8e3..9a1025724 100644
--- a/ui/ui-animation/src/main/java/androidx/ui/animation/DisposableAnimationClock.kt
+++ b/ui/ui-animation/src/commonMain/kotlin/androidx/ui/animation/DisposableAnimationClock.kt
@@ -18,12 +18,9 @@
import androidx.animation.AnimationClockObservable
import androidx.animation.AnimationClockObserver
-import androidx.compose.AtomicReference
import androidx.compose.Composable
import androidx.compose.onCommit
import androidx.compose.remember
-import kotlinx.collections.immutable.PersistentSet
-import kotlinx.collections.immutable.persistentSetOf
/**
* Return a new [AnimationClockObservable] wrapping this one that will auto-unsubscribe all
@@ -54,29 +51,22 @@
) : AnimationClockObservable {
// TODO switch to atomicfu if this class survives a move to suspending animation API
- private val allSubscriptions = AtomicReference<PersistentSet<AnimationClockObserver>?>(
- persistentSetOf()
- )
+ private val allSubscriptions = mutableSetOf<AnimationClockObserver>()
+ private var disposed = false
override fun subscribe(observer: AnimationClockObserver) {
- while (true) {
- val old = allSubscriptions.get()
- val new = old?.add(observer) ?: return // null means already disposed
- if (allSubscriptions.compareAndSet(old, new)) {
+ synchronized(allSubscriptions) {
+ if (!disposed) {
+ allSubscriptions += observer
clock.subscribe(observer)
- return
}
}
}
override fun unsubscribe(observer: AnimationClockObserver) {
- while (true) {
- val old = allSubscriptions.get() ?: return // null means already disposed
- val new = old.remove(observer)
- if (old == new) return
- if (allSubscriptions.compareAndSet(old, new)) {
+ synchronized(allSubscriptions) {
+ if (allSubscriptions.remove(observer)) {
clock.unsubscribe(observer)
- return
}
}
}
@@ -87,11 +77,15 @@
* After a call to [dispose], [isDisposed] will return `true`.
*/
fun dispose() {
- allSubscriptions.getAndSet(null)?.forEach { clock.unsubscribe(it) }
+ synchronized(allSubscriptions) {
+ allSubscriptions.forEach { clock.unsubscribe(it) }
+ allSubscriptions.clear()
+ disposed = true
+ }
}
/**
* `true` if [dispose] has been called and no new subscriptions are permitted.
*/
- val isDisposed: Boolean get() = allSubscriptions.get() == null
+ val isDisposed: Boolean get() = synchronized(allSubscriptions) { disposed == true }
}
\ No newline at end of file
diff --git a/ui/ui-animation/src/main/java/androidx/ui/animation/PropertyKeys.kt b/ui/ui-animation/src/commonMain/kotlin/androidx/ui/animation/PropertyKeys.kt
similarity index 100%
rename from ui/ui-animation/src/main/java/androidx/ui/animation/PropertyKeys.kt
rename to ui/ui-animation/src/commonMain/kotlin/androidx/ui/animation/PropertyKeys.kt
diff --git a/ui/ui-animation/src/main/java/androidx/ui/animation/SingleValueAnimation.kt b/ui/ui-animation/src/commonMain/kotlin/androidx/ui/animation/SingleValueAnimation.kt
similarity index 99%
rename from ui/ui-animation/src/main/java/androidx/ui/animation/SingleValueAnimation.kt
rename to ui/ui-animation/src/commonMain/kotlin/androidx/ui/animation/SingleValueAnimation.kt
index 30d268a..ac8a0dd 100644
--- a/ui/ui-animation/src/main/java/androidx/ui/animation/SingleValueAnimation.kt
+++ b/ui/ui-animation/src/commonMain/kotlin/androidx/ui/animation/SingleValueAnimation.kt
@@ -411,7 +411,6 @@
fun <T : AnimationVector> animate(
target: T,
animSpec: AnimationSpec<T> = remember {
- android.util.Log.w("LTD", "visibility threshold: $visibilityThreshold")
SpringSpec(visibilityThreshold = visibilityThreshold)
},
visibilityThreshold: T? = null,
diff --git a/ui/ui-animation/src/main/java/androidx/ui/animation/Transition.kt b/ui/ui-animation/src/commonMain/kotlin/androidx/ui/animation/Transition.kt
similarity index 64%
rename from ui/ui-animation/src/main/java/androidx/ui/animation/Transition.kt
rename to ui/ui-animation/src/commonMain/kotlin/androidx/ui/animation/Transition.kt
index 2b6e100..f423c6a 100644
--- a/ui/ui-animation/src/main/java/androidx/ui/animation/Transition.kt
+++ b/ui/ui-animation/src/commonMain/kotlin/androidx/ui/animation/Transition.kt
@@ -97,6 +97,58 @@
}
/**
+ * [Transition] composable creates a state-based transition using the animation configuration
+ * defined in [TransitionDefinition]. This can be especially useful when animating multiple
+ * values from a predefined set of values to another. For animating a single value, consider using
+ * [animatedValue], [animatedFloat], [animatedColor] or the more light-weight [animate] APIs.
+ *
+ * [Transition] starts a new animation or changes the on-going animation when the [toState]
+ * parameter is changed to a different value. It dutifully ensures that the animation will head
+ * towards new [toState] regardless of what state (or in-between state) it’s currently in: If the
+ * transition is not currently animating, having a new [toState] value will start a new animation,
+ * otherwise the in-flight animation will correct course and animate towards the new [toState]
+ * based on the interruption handling logic.
+ *
+ * [Transition] takes a transition definition, a target state and child composables.
+ * These child composables will be receiving a [TransitionState] object as an argument, which
+ * captures all the current values of the animation. Child composables should read the animation
+ * values from the [TransitionState] object, and apply the value wherever necessary.
+ *
+ * @sample androidx.ui.animation.samples.TransitionSample
+ *
+ * @param definition Transition definition that defines states and transitions
+ * @param toState New state to transition to
+ * @param clock Optional animation clock that pulses animations when time changes. By default,
+ * the system uses a choreographer based clock read from the [AnimationClockAmbient].
+ * A custom implementation of the [AnimationClockObservable] (such as a
+ * [androidx.animation.ManualAnimationClock]) can be supplied here if there’s a need to
+ * manually control the clock (for example in tests).
+ * @param initState Optional initial state for the transition. When undefined, the initial state
+ * will be set to the first [toState] seen in the transition.
+ * @param onStateChangeFinished An optional listener to get notified when state change animation
+ * has completed
+ * @param children The children composables that will be animated
+ *
+ * @see [TransitionDefinition]
+ */
+@Deprecated("Transition has been renamed to transition, which returns a TransitionState instead " +
+ "of passing it to children",
+ replaceWith = ReplaceWith(
+ "transition(definition, toState, clock, initState, onStateChangeFinished)",
+ "androidx.ui.animation.transition"))
+@Composable
+fun <T> Transition(
+ definition: TransitionDefinition<T>,
+ toState: T,
+ clock: AnimationClockObservable = AnimationClockAmbient.current,
+ initState: T = toState,
+ onStateChangeFinished: ((T) -> Unit)? = null,
+ children: @Composable (state: TransitionState) -> Unit
+) {
+ val state = transition(definition, toState, clock, initState, onStateChangeFinished)
+ children(state)
+}
+/**
* Stores the enabled state for [transition] animations. Useful for tests to disable
* animations and have reliable screenshot tests.
*/
diff --git a/ui/ui-animation/src/test/java/androidx/ui/animation/ConverterTest.kt b/ui/ui-animation/src/test/kotlin/androidx/ui/animation/ConverterTest.kt
similarity index 100%
rename from ui/ui-animation/src/test/java/androidx/ui/animation/ConverterTest.kt
rename to ui/ui-animation/src/test/kotlin/androidx/ui/animation/ConverterTest.kt
diff --git a/ui/ui-animation/src/test/java/androidx/ui/animation/DisposableAnimationClockTest.kt b/ui/ui-animation/src/test/kotlin/androidx/ui/animation/DisposableAnimationClockTest.kt
similarity index 100%
rename from ui/ui-animation/src/test/java/androidx/ui/animation/DisposableAnimationClockTest.kt
rename to ui/ui-animation/src/test/kotlin/androidx/ui/animation/DisposableAnimationClockTest.kt
diff --git a/ui/ui-animation/src/test/java/androidx/ui/animation/PropertyKeyTest.kt b/ui/ui-animation/src/test/kotlin/androidx/ui/animation/PropertyKeyTest.kt
similarity index 100%
rename from ui/ui-animation/src/test/java/androidx/ui/animation/PropertyKeyTest.kt
rename to ui/ui-animation/src/test/kotlin/androidx/ui/animation/PropertyKeyTest.kt
diff --git a/ui/ui-core/api/0.1.0-dev15.txt b/ui/ui-core/api/0.1.0-dev15.txt
index 03499e6..a90510a 100644
--- a/ui/ui-core/api/0.1.0-dev15.txt
+++ b/ui/ui-core/api/0.1.0-dev15.txt
@@ -934,6 +934,10 @@
property public abstract androidx.ui.core.focus.FocusDetailedState focusDetailedState;
}
+ public final class FocusModifier2Kt {
+ method @androidx.compose.Composable @androidx.ui.core.focus.ExperimentalFocus public static androidx.ui.core.Modifier focus(androidx.ui.core.Modifier);
+ }
+
public final class FocusModifierKt {
method @androidx.compose.Composable public static androidx.ui.core.focus.FocusModifier FocusModifier();
method public static androidx.ui.core.focus.FocusState getFocusState(androidx.ui.core.focus.FocusModifier);
@@ -1925,17 +1929,6 @@
method public static <T> T? getOrNull(androidx.ui.core.semantics.SemanticsConfiguration, androidx.ui.semantics.SemanticsPropertyKey<T> key);
}
- public final class SemanticsHintOverrides {
- ctor public SemanticsHintOverrides(String? onTapHint, String? onLongPressHint);
- method public String? component1();
- method public String? component2();
- method public androidx.ui.core.semantics.SemanticsHintOverrides copy(String? onTapHint, String? onLongPressHint);
- method public String? getOnLongPressHint();
- method public String? getOnTapHint();
- method public boolean isNotEmpty();
- property public final boolean isNotEmpty;
- }
-
public interface SemanticsModifier extends androidx.ui.core.Modifier.Element {
method public int getId();
method public androidx.ui.core.semantics.SemanticsConfiguration getSemanticsConfiguration();
@@ -1944,7 +1937,7 @@
}
public final class SemanticsModifierKt {
- method public static androidx.ui.core.Modifier semantics(androidx.ui.core.Modifier, boolean mergeAllDescendants = false, kotlin.jvm.functions.Function1<? super androidx.ui.semantics.SemanticsPropertyReceiver,kotlin.Unit>? properties = null);
+ method public static androidx.ui.core.Modifier semantics(androidx.ui.core.Modifier, boolean mergeAllDescendants = false, kotlin.jvm.functions.Function1<? super androidx.ui.semantics.SemanticsPropertyReceiver,kotlin.Unit> properties);
}
public final class SemanticsNode {
@@ -1959,22 +1952,17 @@
method public boolean getMergingEnabled();
method public androidx.ui.core.semantics.SemanticsNode? getParent();
method public androidx.ui.unit.IntSize getSize();
- method public androidx.ui.core.semantics.SemanticsConfiguration getUnmergedConfig();
method public boolean isRoot();
- method public void setComponentNode(androidx.ui.core.LayoutNode p);
property public final androidx.ui.unit.PxBounds boundsInRoot;
property public final java.util.List<androidx.ui.core.semantics.SemanticsNode> children;
+ property public final androidx.ui.core.LayoutNode componentNode;
property public final androidx.ui.core.semantics.SemanticsConfiguration config;
property public final androidx.ui.unit.PxBounds globalBounds;
property public final androidx.ui.geometry.Offset globalPosition;
+ property public final int id;
property public final boolean isRoot;
property public final androidx.ui.core.semantics.SemanticsNode? parent;
property public final androidx.ui.unit.IntSize size;
- field public static final androidx.ui.core.semantics.SemanticsNode.Companion Companion;
- }
-
- public static final class SemanticsNode.Companion {
- method public int generateNewId();
}
public final class SemanticsNodeKt {
@@ -2306,14 +2294,14 @@
method public androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> getCustomActions();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getOnClick();
method @Deprecated public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getScrollBackward();
+ method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> getScrollBy();
method @Deprecated public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getScrollForward();
- method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> getScrollTo();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>>> getSetProgress();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> CustomActions;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> OnClick;
property @Deprecated public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> ScrollBackward;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> ScrollBy;
property @Deprecated public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> ScrollForward;
- property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> ScrollTo;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>>> SetProgress;
field public static final androidx.ui.semantics.SemanticsActions INSTANCE;
}
@@ -2322,64 +2310,50 @@
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> getAccessibilityLabel();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityRangeInfo> getAccessibilityRangeInfo();
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> getAccessibilityValue();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getEnabled();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getHidden();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getIsPopup();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getDisabled();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getHidden();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getIsPopup();
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> getTestTag();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.text.AnnotatedString> getText();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> AccessibilityLabel;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityRangeInfo> AccessibilityRangeInfo;
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> AccessibilityValue;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> Enabled;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> Hidden;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> IsPopup;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> Disabled;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> Hidden;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> IsPopup;
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> TestTag;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.text.AnnotatedString> Text;
field public static final androidx.ui.semantics.SemanticsProperties INSTANCE;
}
public final class SemanticsPropertiesKt {
- method public static void ScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,java.lang.Boolean> action);
+ method public static void disabled(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getAccessibilityValue(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.semantics.AccessibilityRangeInfo getAccessibilityValueRange(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static java.util.List<androidx.ui.semantics.CustomAccessibilityAction> getCustomActions(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getEnabled(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getHidden(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getOnClick(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getPopup(androidx.ui.semantics.SemanticsPropertyReceiver);
- method @Deprecated public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getScrollBackward(androidx.ui.semantics.SemanticsPropertyReceiver);
- method @Deprecated public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getScrollForward(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> getScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>> getSetProgress(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getTestTag(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.text.AnnotatedString getText(androidx.ui.semantics.SemanticsPropertyReceiver);
+ method public static void hidden(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static void onClick(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
+ method public static void popup(androidx.ui.semantics.SemanticsPropertyReceiver);
method @Deprecated public static void scrollBackward(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
+ method public static void scrollBy(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,java.lang.Boolean> action);
method @Deprecated public static void scrollForward(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
method public static void setAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
method public static void setAccessibilityValue(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
method public static void setAccessibilityValueRange(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityRangeInfo p);
method public static void setCustomActions(androidx.ui.semantics.SemanticsPropertyReceiver, java.util.List<androidx.ui.semantics.CustomAccessibilityAction> p);
- method public static void setEnabled(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
- method public static void setHidden(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
- method public static void setOnClick(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
- method public static void setPopup(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setProgress(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function1<? super java.lang.Float,java.lang.Boolean> action);
- method @Deprecated public static void setScrollBackward(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
- method @Deprecated public static void setScrollForward(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
- method public static void setScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> p);
- method public static void setSetProgress(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>> p);
method public static void setTestTag(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
method public static void setText(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.text.AnnotatedString p);
}
- public class SemanticsPropertyKey<T> implements kotlin.properties.ReadWriteProperty<androidx.ui.semantics.SemanticsPropertyReceiver,T> {
+ public final class SemanticsPropertyKey<T> {
ctor public SemanticsPropertyKey(String name);
- method public final String getName();
- method public final T! getValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property);
- method public T! merge(T? existingValue, T? newValue);
- method public final void setValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property, T? value);
+ method public String getName();
+ method public operator T! getValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property);
+ method public operator void setValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property, T? value);
}
public interface SemanticsPropertyReceiver {
diff --git a/ui/ui-core/api/current.txt b/ui/ui-core/api/current.txt
index 03499e6..a90510a 100644
--- a/ui/ui-core/api/current.txt
+++ b/ui/ui-core/api/current.txt
@@ -934,6 +934,10 @@
property public abstract androidx.ui.core.focus.FocusDetailedState focusDetailedState;
}
+ public final class FocusModifier2Kt {
+ method @androidx.compose.Composable @androidx.ui.core.focus.ExperimentalFocus public static androidx.ui.core.Modifier focus(androidx.ui.core.Modifier);
+ }
+
public final class FocusModifierKt {
method @androidx.compose.Composable public static androidx.ui.core.focus.FocusModifier FocusModifier();
method public static androidx.ui.core.focus.FocusState getFocusState(androidx.ui.core.focus.FocusModifier);
@@ -1925,17 +1929,6 @@
method public static <T> T? getOrNull(androidx.ui.core.semantics.SemanticsConfiguration, androidx.ui.semantics.SemanticsPropertyKey<T> key);
}
- public final class SemanticsHintOverrides {
- ctor public SemanticsHintOverrides(String? onTapHint, String? onLongPressHint);
- method public String? component1();
- method public String? component2();
- method public androidx.ui.core.semantics.SemanticsHintOverrides copy(String? onTapHint, String? onLongPressHint);
- method public String? getOnLongPressHint();
- method public String? getOnTapHint();
- method public boolean isNotEmpty();
- property public final boolean isNotEmpty;
- }
-
public interface SemanticsModifier extends androidx.ui.core.Modifier.Element {
method public int getId();
method public androidx.ui.core.semantics.SemanticsConfiguration getSemanticsConfiguration();
@@ -1944,7 +1937,7 @@
}
public final class SemanticsModifierKt {
- method public static androidx.ui.core.Modifier semantics(androidx.ui.core.Modifier, boolean mergeAllDescendants = false, kotlin.jvm.functions.Function1<? super androidx.ui.semantics.SemanticsPropertyReceiver,kotlin.Unit>? properties = null);
+ method public static androidx.ui.core.Modifier semantics(androidx.ui.core.Modifier, boolean mergeAllDescendants = false, kotlin.jvm.functions.Function1<? super androidx.ui.semantics.SemanticsPropertyReceiver,kotlin.Unit> properties);
}
public final class SemanticsNode {
@@ -1959,22 +1952,17 @@
method public boolean getMergingEnabled();
method public androidx.ui.core.semantics.SemanticsNode? getParent();
method public androidx.ui.unit.IntSize getSize();
- method public androidx.ui.core.semantics.SemanticsConfiguration getUnmergedConfig();
method public boolean isRoot();
- method public void setComponentNode(androidx.ui.core.LayoutNode p);
property public final androidx.ui.unit.PxBounds boundsInRoot;
property public final java.util.List<androidx.ui.core.semantics.SemanticsNode> children;
+ property public final androidx.ui.core.LayoutNode componentNode;
property public final androidx.ui.core.semantics.SemanticsConfiguration config;
property public final androidx.ui.unit.PxBounds globalBounds;
property public final androidx.ui.geometry.Offset globalPosition;
+ property public final int id;
property public final boolean isRoot;
property public final androidx.ui.core.semantics.SemanticsNode? parent;
property public final androidx.ui.unit.IntSize size;
- field public static final androidx.ui.core.semantics.SemanticsNode.Companion Companion;
- }
-
- public static final class SemanticsNode.Companion {
- method public int generateNewId();
}
public final class SemanticsNodeKt {
@@ -2306,14 +2294,14 @@
method public androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> getCustomActions();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getOnClick();
method @Deprecated public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getScrollBackward();
+ method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> getScrollBy();
method @Deprecated public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getScrollForward();
- method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> getScrollTo();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>>> getSetProgress();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> CustomActions;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> OnClick;
property @Deprecated public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> ScrollBackward;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> ScrollBy;
property @Deprecated public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> ScrollForward;
- property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> ScrollTo;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>>> SetProgress;
field public static final androidx.ui.semantics.SemanticsActions INSTANCE;
}
@@ -2322,64 +2310,50 @@
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> getAccessibilityLabel();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityRangeInfo> getAccessibilityRangeInfo();
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> getAccessibilityValue();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getEnabled();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getHidden();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getIsPopup();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getDisabled();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getHidden();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getIsPopup();
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> getTestTag();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.text.AnnotatedString> getText();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> AccessibilityLabel;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityRangeInfo> AccessibilityRangeInfo;
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> AccessibilityValue;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> Enabled;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> Hidden;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> IsPopup;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> Disabled;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> Hidden;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> IsPopup;
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> TestTag;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.text.AnnotatedString> Text;
field public static final androidx.ui.semantics.SemanticsProperties INSTANCE;
}
public final class SemanticsPropertiesKt {
- method public static void ScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,java.lang.Boolean> action);
+ method public static void disabled(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getAccessibilityValue(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.semantics.AccessibilityRangeInfo getAccessibilityValueRange(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static java.util.List<androidx.ui.semantics.CustomAccessibilityAction> getCustomActions(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getEnabled(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getHidden(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getOnClick(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getPopup(androidx.ui.semantics.SemanticsPropertyReceiver);
- method @Deprecated public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getScrollBackward(androidx.ui.semantics.SemanticsPropertyReceiver);
- method @Deprecated public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getScrollForward(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> getScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>> getSetProgress(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getTestTag(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.text.AnnotatedString getText(androidx.ui.semantics.SemanticsPropertyReceiver);
+ method public static void hidden(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static void onClick(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
+ method public static void popup(androidx.ui.semantics.SemanticsPropertyReceiver);
method @Deprecated public static void scrollBackward(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
+ method public static void scrollBy(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,java.lang.Boolean> action);
method @Deprecated public static void scrollForward(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
method public static void setAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
method public static void setAccessibilityValue(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
method public static void setAccessibilityValueRange(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityRangeInfo p);
method public static void setCustomActions(androidx.ui.semantics.SemanticsPropertyReceiver, java.util.List<androidx.ui.semantics.CustomAccessibilityAction> p);
- method public static void setEnabled(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
- method public static void setHidden(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
- method public static void setOnClick(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
- method public static void setPopup(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setProgress(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function1<? super java.lang.Float,java.lang.Boolean> action);
- method @Deprecated public static void setScrollBackward(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
- method @Deprecated public static void setScrollForward(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
- method public static void setScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> p);
- method public static void setSetProgress(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>> p);
method public static void setTestTag(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
method public static void setText(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.text.AnnotatedString p);
}
- public class SemanticsPropertyKey<T> implements kotlin.properties.ReadWriteProperty<androidx.ui.semantics.SemanticsPropertyReceiver,T> {
+ public final class SemanticsPropertyKey<T> {
ctor public SemanticsPropertyKey(String name);
- method public final String getName();
- method public final T! getValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property);
- method public T! merge(T? existingValue, T? newValue);
- method public final void setValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property, T? value);
+ method public String getName();
+ method public operator T! getValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property);
+ method public operator void setValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property, T? value);
}
public interface SemanticsPropertyReceiver {
diff --git a/ui/ui-core/api/public_plus_experimental_0.1.0-dev15.txt b/ui/ui-core/api/public_plus_experimental_0.1.0-dev15.txt
index 03499e6..a90510a 100644
--- a/ui/ui-core/api/public_plus_experimental_0.1.0-dev15.txt
+++ b/ui/ui-core/api/public_plus_experimental_0.1.0-dev15.txt
@@ -934,6 +934,10 @@
property public abstract androidx.ui.core.focus.FocusDetailedState focusDetailedState;
}
+ public final class FocusModifier2Kt {
+ method @androidx.compose.Composable @androidx.ui.core.focus.ExperimentalFocus public static androidx.ui.core.Modifier focus(androidx.ui.core.Modifier);
+ }
+
public final class FocusModifierKt {
method @androidx.compose.Composable public static androidx.ui.core.focus.FocusModifier FocusModifier();
method public static androidx.ui.core.focus.FocusState getFocusState(androidx.ui.core.focus.FocusModifier);
@@ -1925,17 +1929,6 @@
method public static <T> T? getOrNull(androidx.ui.core.semantics.SemanticsConfiguration, androidx.ui.semantics.SemanticsPropertyKey<T> key);
}
- public final class SemanticsHintOverrides {
- ctor public SemanticsHintOverrides(String? onTapHint, String? onLongPressHint);
- method public String? component1();
- method public String? component2();
- method public androidx.ui.core.semantics.SemanticsHintOverrides copy(String? onTapHint, String? onLongPressHint);
- method public String? getOnLongPressHint();
- method public String? getOnTapHint();
- method public boolean isNotEmpty();
- property public final boolean isNotEmpty;
- }
-
public interface SemanticsModifier extends androidx.ui.core.Modifier.Element {
method public int getId();
method public androidx.ui.core.semantics.SemanticsConfiguration getSemanticsConfiguration();
@@ -1944,7 +1937,7 @@
}
public final class SemanticsModifierKt {
- method public static androidx.ui.core.Modifier semantics(androidx.ui.core.Modifier, boolean mergeAllDescendants = false, kotlin.jvm.functions.Function1<? super androidx.ui.semantics.SemanticsPropertyReceiver,kotlin.Unit>? properties = null);
+ method public static androidx.ui.core.Modifier semantics(androidx.ui.core.Modifier, boolean mergeAllDescendants = false, kotlin.jvm.functions.Function1<? super androidx.ui.semantics.SemanticsPropertyReceiver,kotlin.Unit> properties);
}
public final class SemanticsNode {
@@ -1959,22 +1952,17 @@
method public boolean getMergingEnabled();
method public androidx.ui.core.semantics.SemanticsNode? getParent();
method public androidx.ui.unit.IntSize getSize();
- method public androidx.ui.core.semantics.SemanticsConfiguration getUnmergedConfig();
method public boolean isRoot();
- method public void setComponentNode(androidx.ui.core.LayoutNode p);
property public final androidx.ui.unit.PxBounds boundsInRoot;
property public final java.util.List<androidx.ui.core.semantics.SemanticsNode> children;
+ property public final androidx.ui.core.LayoutNode componentNode;
property public final androidx.ui.core.semantics.SemanticsConfiguration config;
property public final androidx.ui.unit.PxBounds globalBounds;
property public final androidx.ui.geometry.Offset globalPosition;
+ property public final int id;
property public final boolean isRoot;
property public final androidx.ui.core.semantics.SemanticsNode? parent;
property public final androidx.ui.unit.IntSize size;
- field public static final androidx.ui.core.semantics.SemanticsNode.Companion Companion;
- }
-
- public static final class SemanticsNode.Companion {
- method public int generateNewId();
}
public final class SemanticsNodeKt {
@@ -2306,14 +2294,14 @@
method public androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> getCustomActions();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getOnClick();
method @Deprecated public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getScrollBackward();
+ method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> getScrollBy();
method @Deprecated public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getScrollForward();
- method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> getScrollTo();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>>> getSetProgress();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> CustomActions;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> OnClick;
property @Deprecated public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> ScrollBackward;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> ScrollBy;
property @Deprecated public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> ScrollForward;
- property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> ScrollTo;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>>> SetProgress;
field public static final androidx.ui.semantics.SemanticsActions INSTANCE;
}
@@ -2322,64 +2310,50 @@
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> getAccessibilityLabel();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityRangeInfo> getAccessibilityRangeInfo();
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> getAccessibilityValue();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getEnabled();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getHidden();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getIsPopup();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getDisabled();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getHidden();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getIsPopup();
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> getTestTag();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.text.AnnotatedString> getText();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> AccessibilityLabel;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityRangeInfo> AccessibilityRangeInfo;
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> AccessibilityValue;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> Enabled;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> Hidden;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> IsPopup;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> Disabled;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> Hidden;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> IsPopup;
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> TestTag;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.text.AnnotatedString> Text;
field public static final androidx.ui.semantics.SemanticsProperties INSTANCE;
}
public final class SemanticsPropertiesKt {
- method public static void ScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,java.lang.Boolean> action);
+ method public static void disabled(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getAccessibilityValue(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.semantics.AccessibilityRangeInfo getAccessibilityValueRange(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static java.util.List<androidx.ui.semantics.CustomAccessibilityAction> getCustomActions(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getEnabled(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getHidden(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getOnClick(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getPopup(androidx.ui.semantics.SemanticsPropertyReceiver);
- method @Deprecated public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getScrollBackward(androidx.ui.semantics.SemanticsPropertyReceiver);
- method @Deprecated public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getScrollForward(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> getScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>> getSetProgress(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getTestTag(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.text.AnnotatedString getText(androidx.ui.semantics.SemanticsPropertyReceiver);
+ method public static void hidden(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static void onClick(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
+ method public static void popup(androidx.ui.semantics.SemanticsPropertyReceiver);
method @Deprecated public static void scrollBackward(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
+ method public static void scrollBy(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,java.lang.Boolean> action);
method @Deprecated public static void scrollForward(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
method public static void setAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
method public static void setAccessibilityValue(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
method public static void setAccessibilityValueRange(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityRangeInfo p);
method public static void setCustomActions(androidx.ui.semantics.SemanticsPropertyReceiver, java.util.List<androidx.ui.semantics.CustomAccessibilityAction> p);
- method public static void setEnabled(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
- method public static void setHidden(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
- method public static void setOnClick(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
- method public static void setPopup(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setProgress(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function1<? super java.lang.Float,java.lang.Boolean> action);
- method @Deprecated public static void setScrollBackward(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
- method @Deprecated public static void setScrollForward(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
- method public static void setScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> p);
- method public static void setSetProgress(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>> p);
method public static void setTestTag(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
method public static void setText(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.text.AnnotatedString p);
}
- public class SemanticsPropertyKey<T> implements kotlin.properties.ReadWriteProperty<androidx.ui.semantics.SemanticsPropertyReceiver,T> {
+ public final class SemanticsPropertyKey<T> {
ctor public SemanticsPropertyKey(String name);
- method public final String getName();
- method public final T! getValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property);
- method public T! merge(T? existingValue, T? newValue);
- method public final void setValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property, T? value);
+ method public String getName();
+ method public operator T! getValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property);
+ method public operator void setValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property, T? value);
}
public interface SemanticsPropertyReceiver {
diff --git a/ui/ui-core/api/public_plus_experimental_current.txt b/ui/ui-core/api/public_plus_experimental_current.txt
index 03499e6..a90510a 100644
--- a/ui/ui-core/api/public_plus_experimental_current.txt
+++ b/ui/ui-core/api/public_plus_experimental_current.txt
@@ -934,6 +934,10 @@
property public abstract androidx.ui.core.focus.FocusDetailedState focusDetailedState;
}
+ public final class FocusModifier2Kt {
+ method @androidx.compose.Composable @androidx.ui.core.focus.ExperimentalFocus public static androidx.ui.core.Modifier focus(androidx.ui.core.Modifier);
+ }
+
public final class FocusModifierKt {
method @androidx.compose.Composable public static androidx.ui.core.focus.FocusModifier FocusModifier();
method public static androidx.ui.core.focus.FocusState getFocusState(androidx.ui.core.focus.FocusModifier);
@@ -1925,17 +1929,6 @@
method public static <T> T? getOrNull(androidx.ui.core.semantics.SemanticsConfiguration, androidx.ui.semantics.SemanticsPropertyKey<T> key);
}
- public final class SemanticsHintOverrides {
- ctor public SemanticsHintOverrides(String? onTapHint, String? onLongPressHint);
- method public String? component1();
- method public String? component2();
- method public androidx.ui.core.semantics.SemanticsHintOverrides copy(String? onTapHint, String? onLongPressHint);
- method public String? getOnLongPressHint();
- method public String? getOnTapHint();
- method public boolean isNotEmpty();
- property public final boolean isNotEmpty;
- }
-
public interface SemanticsModifier extends androidx.ui.core.Modifier.Element {
method public int getId();
method public androidx.ui.core.semantics.SemanticsConfiguration getSemanticsConfiguration();
@@ -1944,7 +1937,7 @@
}
public final class SemanticsModifierKt {
- method public static androidx.ui.core.Modifier semantics(androidx.ui.core.Modifier, boolean mergeAllDescendants = false, kotlin.jvm.functions.Function1<? super androidx.ui.semantics.SemanticsPropertyReceiver,kotlin.Unit>? properties = null);
+ method public static androidx.ui.core.Modifier semantics(androidx.ui.core.Modifier, boolean mergeAllDescendants = false, kotlin.jvm.functions.Function1<? super androidx.ui.semantics.SemanticsPropertyReceiver,kotlin.Unit> properties);
}
public final class SemanticsNode {
@@ -1959,22 +1952,17 @@
method public boolean getMergingEnabled();
method public androidx.ui.core.semantics.SemanticsNode? getParent();
method public androidx.ui.unit.IntSize getSize();
- method public androidx.ui.core.semantics.SemanticsConfiguration getUnmergedConfig();
method public boolean isRoot();
- method public void setComponentNode(androidx.ui.core.LayoutNode p);
property public final androidx.ui.unit.PxBounds boundsInRoot;
property public final java.util.List<androidx.ui.core.semantics.SemanticsNode> children;
+ property public final androidx.ui.core.LayoutNode componentNode;
property public final androidx.ui.core.semantics.SemanticsConfiguration config;
property public final androidx.ui.unit.PxBounds globalBounds;
property public final androidx.ui.geometry.Offset globalPosition;
+ property public final int id;
property public final boolean isRoot;
property public final androidx.ui.core.semantics.SemanticsNode? parent;
property public final androidx.ui.unit.IntSize size;
- field public static final androidx.ui.core.semantics.SemanticsNode.Companion Companion;
- }
-
- public static final class SemanticsNode.Companion {
- method public int generateNewId();
}
public final class SemanticsNodeKt {
@@ -2306,14 +2294,14 @@
method public androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> getCustomActions();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getOnClick();
method @Deprecated public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getScrollBackward();
+ method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> getScrollBy();
method @Deprecated public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getScrollForward();
- method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> getScrollTo();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>>> getSetProgress();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> CustomActions;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> OnClick;
property @Deprecated public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> ScrollBackward;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> ScrollBy;
property @Deprecated public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> ScrollForward;
- property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> ScrollTo;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>>> SetProgress;
field public static final androidx.ui.semantics.SemanticsActions INSTANCE;
}
@@ -2322,64 +2310,50 @@
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> getAccessibilityLabel();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityRangeInfo> getAccessibilityRangeInfo();
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> getAccessibilityValue();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getEnabled();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getHidden();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getIsPopup();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getDisabled();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getHidden();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getIsPopup();
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> getTestTag();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.text.AnnotatedString> getText();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> AccessibilityLabel;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityRangeInfo> AccessibilityRangeInfo;
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> AccessibilityValue;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> Enabled;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> Hidden;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> IsPopup;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> Disabled;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> Hidden;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> IsPopup;
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> TestTag;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.text.AnnotatedString> Text;
field public static final androidx.ui.semantics.SemanticsProperties INSTANCE;
}
public final class SemanticsPropertiesKt {
- method public static void ScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,java.lang.Boolean> action);
+ method public static void disabled(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getAccessibilityValue(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.semantics.AccessibilityRangeInfo getAccessibilityValueRange(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static java.util.List<androidx.ui.semantics.CustomAccessibilityAction> getCustomActions(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getEnabled(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getHidden(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getOnClick(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getPopup(androidx.ui.semantics.SemanticsPropertyReceiver);
- method @Deprecated public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getScrollBackward(androidx.ui.semantics.SemanticsPropertyReceiver);
- method @Deprecated public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getScrollForward(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> getScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>> getSetProgress(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getTestTag(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.text.AnnotatedString getText(androidx.ui.semantics.SemanticsPropertyReceiver);
+ method public static void hidden(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static void onClick(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
+ method public static void popup(androidx.ui.semantics.SemanticsPropertyReceiver);
method @Deprecated public static void scrollBackward(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
+ method public static void scrollBy(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,java.lang.Boolean> action);
method @Deprecated public static void scrollForward(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
method public static void setAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
method public static void setAccessibilityValue(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
method public static void setAccessibilityValueRange(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityRangeInfo p);
method public static void setCustomActions(androidx.ui.semantics.SemanticsPropertyReceiver, java.util.List<androidx.ui.semantics.CustomAccessibilityAction> p);
- method public static void setEnabled(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
- method public static void setHidden(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
- method public static void setOnClick(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
- method public static void setPopup(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setProgress(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function1<? super java.lang.Float,java.lang.Boolean> action);
- method @Deprecated public static void setScrollBackward(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
- method @Deprecated public static void setScrollForward(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
- method public static void setScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> p);
- method public static void setSetProgress(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>> p);
method public static void setTestTag(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
method public static void setText(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.text.AnnotatedString p);
}
- public class SemanticsPropertyKey<T> implements kotlin.properties.ReadWriteProperty<androidx.ui.semantics.SemanticsPropertyReceiver,T> {
+ public final class SemanticsPropertyKey<T> {
ctor public SemanticsPropertyKey(String name);
- method public final String getName();
- method public final T! getValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property);
- method public T! merge(T? existingValue, T? newValue);
- method public final void setValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property, T? value);
+ method public String getName();
+ method public operator T! getValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property);
+ method public operator void setValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property, T? value);
}
public interface SemanticsPropertyReceiver {
diff --git a/ui/ui-core/api/restricted_0.1.0-dev15.txt b/ui/ui-core/api/restricted_0.1.0-dev15.txt
index ff1b11d..afa5b10 100644
--- a/ui/ui-core/api/restricted_0.1.0-dev15.txt
+++ b/ui/ui-core/api/restricted_0.1.0-dev15.txt
@@ -986,6 +986,10 @@
property public abstract androidx.ui.core.focus.FocusDetailedState focusDetailedState;
}
+ public final class FocusModifier2Kt {
+ method @androidx.compose.Composable @androidx.ui.core.focus.ExperimentalFocus public static androidx.ui.core.Modifier focus(androidx.ui.core.Modifier);
+ }
+
public final class FocusModifierKt {
method @androidx.compose.Composable public static androidx.ui.core.focus.FocusModifier FocusModifier();
method public static androidx.ui.core.focus.FocusState getFocusState(androidx.ui.core.focus.FocusModifier);
@@ -1977,17 +1981,6 @@
method public static <T> T? getOrNull(androidx.ui.core.semantics.SemanticsConfiguration, androidx.ui.semantics.SemanticsPropertyKey<T> key);
}
- public final class SemanticsHintOverrides {
- ctor public SemanticsHintOverrides(String? onTapHint, String? onLongPressHint);
- method public String? component1();
- method public String? component2();
- method public androidx.ui.core.semantics.SemanticsHintOverrides copy(String? onTapHint, String? onLongPressHint);
- method public String? getOnLongPressHint();
- method public String? getOnTapHint();
- method public boolean isNotEmpty();
- property public final boolean isNotEmpty;
- }
-
public interface SemanticsModifier extends androidx.ui.core.Modifier.Element {
method public int getId();
method public androidx.ui.core.semantics.SemanticsConfiguration getSemanticsConfiguration();
@@ -1996,7 +1989,7 @@
}
public final class SemanticsModifierKt {
- method public static androidx.ui.core.Modifier semantics(androidx.ui.core.Modifier, boolean mergeAllDescendants = false, kotlin.jvm.functions.Function1<? super androidx.ui.semantics.SemanticsPropertyReceiver,kotlin.Unit>? properties = null);
+ method public static androidx.ui.core.Modifier semantics(androidx.ui.core.Modifier, boolean mergeAllDescendants = false, kotlin.jvm.functions.Function1<? super androidx.ui.semantics.SemanticsPropertyReceiver,kotlin.Unit> properties);
}
public final class SemanticsNode {
@@ -2011,22 +2004,17 @@
method public boolean getMergingEnabled();
method public androidx.ui.core.semantics.SemanticsNode? getParent();
method public androidx.ui.unit.IntSize getSize();
- method public androidx.ui.core.semantics.SemanticsConfiguration getUnmergedConfig();
method public boolean isRoot();
- method public void setComponentNode(androidx.ui.core.LayoutNode p);
property public final androidx.ui.unit.PxBounds boundsInRoot;
property public final java.util.List<androidx.ui.core.semantics.SemanticsNode> children;
+ property public final androidx.ui.core.LayoutNode componentNode;
property public final androidx.ui.core.semantics.SemanticsConfiguration config;
property public final androidx.ui.unit.PxBounds globalBounds;
property public final androidx.ui.geometry.Offset globalPosition;
+ property public final int id;
property public final boolean isRoot;
property public final androidx.ui.core.semantics.SemanticsNode? parent;
property public final androidx.ui.unit.IntSize size;
- field public static final androidx.ui.core.semantics.SemanticsNode.Companion Companion;
- }
-
- public static final class SemanticsNode.Companion {
- method public int generateNewId();
}
public final class SemanticsNodeKt {
@@ -2367,14 +2355,14 @@
method public androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> getCustomActions();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getOnClick();
method @Deprecated public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getScrollBackward();
+ method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> getScrollBy();
method @Deprecated public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getScrollForward();
- method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> getScrollTo();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>>> getSetProgress();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> CustomActions;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> OnClick;
property @Deprecated public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> ScrollBackward;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> ScrollBy;
property @Deprecated public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> ScrollForward;
- property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> ScrollTo;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>>> SetProgress;
field public static final androidx.ui.semantics.SemanticsActions INSTANCE;
}
@@ -2383,64 +2371,50 @@
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> getAccessibilityLabel();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityRangeInfo> getAccessibilityRangeInfo();
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> getAccessibilityValue();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getEnabled();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getHidden();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getIsPopup();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getDisabled();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getHidden();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getIsPopup();
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> getTestTag();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.text.AnnotatedString> getText();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> AccessibilityLabel;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityRangeInfo> AccessibilityRangeInfo;
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> AccessibilityValue;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> Enabled;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> Hidden;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> IsPopup;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> Disabled;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> Hidden;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> IsPopup;
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> TestTag;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.text.AnnotatedString> Text;
field public static final androidx.ui.semantics.SemanticsProperties INSTANCE;
}
public final class SemanticsPropertiesKt {
- method public static void ScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,java.lang.Boolean> action);
+ method public static void disabled(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getAccessibilityValue(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.semantics.AccessibilityRangeInfo getAccessibilityValueRange(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static java.util.List<androidx.ui.semantics.CustomAccessibilityAction> getCustomActions(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getEnabled(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getHidden(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getOnClick(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getPopup(androidx.ui.semantics.SemanticsPropertyReceiver);
- method @Deprecated public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getScrollBackward(androidx.ui.semantics.SemanticsPropertyReceiver);
- method @Deprecated public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getScrollForward(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> getScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>> getSetProgress(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getTestTag(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.text.AnnotatedString getText(androidx.ui.semantics.SemanticsPropertyReceiver);
+ method public static void hidden(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static void onClick(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
+ method public static void popup(androidx.ui.semantics.SemanticsPropertyReceiver);
method @Deprecated public static void scrollBackward(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
+ method public static void scrollBy(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,java.lang.Boolean> action);
method @Deprecated public static void scrollForward(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
method public static void setAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
method public static void setAccessibilityValue(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
method public static void setAccessibilityValueRange(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityRangeInfo p);
method public static void setCustomActions(androidx.ui.semantics.SemanticsPropertyReceiver, java.util.List<androidx.ui.semantics.CustomAccessibilityAction> p);
- method public static void setEnabled(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
- method public static void setHidden(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
- method public static void setOnClick(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
- method public static void setPopup(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setProgress(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function1<? super java.lang.Float,java.lang.Boolean> action);
- method @Deprecated public static void setScrollBackward(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
- method @Deprecated public static void setScrollForward(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
- method public static void setScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> p);
- method public static void setSetProgress(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>> p);
method public static void setTestTag(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
method public static void setText(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.text.AnnotatedString p);
}
- public class SemanticsPropertyKey<T> implements kotlin.properties.ReadWriteProperty<androidx.ui.semantics.SemanticsPropertyReceiver,T> {
+ public final class SemanticsPropertyKey<T> {
ctor public SemanticsPropertyKey(String name);
- method public final String getName();
- method public final T! getValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property);
- method public T! merge(T? existingValue, T? newValue);
- method public final void setValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property, T? value);
+ method public String getName();
+ method public operator T! getValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property);
+ method public operator void setValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property, T? value);
}
public interface SemanticsPropertyReceiver {
diff --git a/ui/ui-core/api/restricted_current.txt b/ui/ui-core/api/restricted_current.txt
index ff1b11d..afa5b10 100644
--- a/ui/ui-core/api/restricted_current.txt
+++ b/ui/ui-core/api/restricted_current.txt
@@ -986,6 +986,10 @@
property public abstract androidx.ui.core.focus.FocusDetailedState focusDetailedState;
}
+ public final class FocusModifier2Kt {
+ method @androidx.compose.Composable @androidx.ui.core.focus.ExperimentalFocus public static androidx.ui.core.Modifier focus(androidx.ui.core.Modifier);
+ }
+
public final class FocusModifierKt {
method @androidx.compose.Composable public static androidx.ui.core.focus.FocusModifier FocusModifier();
method public static androidx.ui.core.focus.FocusState getFocusState(androidx.ui.core.focus.FocusModifier);
@@ -1977,17 +1981,6 @@
method public static <T> T? getOrNull(androidx.ui.core.semantics.SemanticsConfiguration, androidx.ui.semantics.SemanticsPropertyKey<T> key);
}
- public final class SemanticsHintOverrides {
- ctor public SemanticsHintOverrides(String? onTapHint, String? onLongPressHint);
- method public String? component1();
- method public String? component2();
- method public androidx.ui.core.semantics.SemanticsHintOverrides copy(String? onTapHint, String? onLongPressHint);
- method public String? getOnLongPressHint();
- method public String? getOnTapHint();
- method public boolean isNotEmpty();
- property public final boolean isNotEmpty;
- }
-
public interface SemanticsModifier extends androidx.ui.core.Modifier.Element {
method public int getId();
method public androidx.ui.core.semantics.SemanticsConfiguration getSemanticsConfiguration();
@@ -1996,7 +1989,7 @@
}
public final class SemanticsModifierKt {
- method public static androidx.ui.core.Modifier semantics(androidx.ui.core.Modifier, boolean mergeAllDescendants = false, kotlin.jvm.functions.Function1<? super androidx.ui.semantics.SemanticsPropertyReceiver,kotlin.Unit>? properties = null);
+ method public static androidx.ui.core.Modifier semantics(androidx.ui.core.Modifier, boolean mergeAllDescendants = false, kotlin.jvm.functions.Function1<? super androidx.ui.semantics.SemanticsPropertyReceiver,kotlin.Unit> properties);
}
public final class SemanticsNode {
@@ -2011,22 +2004,17 @@
method public boolean getMergingEnabled();
method public androidx.ui.core.semantics.SemanticsNode? getParent();
method public androidx.ui.unit.IntSize getSize();
- method public androidx.ui.core.semantics.SemanticsConfiguration getUnmergedConfig();
method public boolean isRoot();
- method public void setComponentNode(androidx.ui.core.LayoutNode p);
property public final androidx.ui.unit.PxBounds boundsInRoot;
property public final java.util.List<androidx.ui.core.semantics.SemanticsNode> children;
+ property public final androidx.ui.core.LayoutNode componentNode;
property public final androidx.ui.core.semantics.SemanticsConfiguration config;
property public final androidx.ui.unit.PxBounds globalBounds;
property public final androidx.ui.geometry.Offset globalPosition;
+ property public final int id;
property public final boolean isRoot;
property public final androidx.ui.core.semantics.SemanticsNode? parent;
property public final androidx.ui.unit.IntSize size;
- field public static final androidx.ui.core.semantics.SemanticsNode.Companion Companion;
- }
-
- public static final class SemanticsNode.Companion {
- method public int generateNewId();
}
public final class SemanticsNodeKt {
@@ -2367,14 +2355,14 @@
method public androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> getCustomActions();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getOnClick();
method @Deprecated public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getScrollBackward();
+ method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> getScrollBy();
method @Deprecated public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> getScrollForward();
- method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> getScrollTo();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>>> getSetProgress();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.util.List<androidx.ui.semantics.CustomAccessibilityAction>> CustomActions;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> OnClick;
property @Deprecated public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> ScrollBackward;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> ScrollBy;
property @Deprecated public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> ScrollForward;
- property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>>> ScrollTo;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>>> SetProgress;
field public static final androidx.ui.semantics.SemanticsActions INSTANCE;
}
@@ -2383,64 +2371,50 @@
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> getAccessibilityLabel();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityRangeInfo> getAccessibilityRangeInfo();
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> getAccessibilityValue();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getEnabled();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getHidden();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getIsPopup();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getDisabled();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getHidden();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getIsPopup();
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> getTestTag();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.text.AnnotatedString> getText();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> AccessibilityLabel;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityRangeInfo> AccessibilityRangeInfo;
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> AccessibilityValue;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> Enabled;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> Hidden;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> IsPopup;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> Disabled;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> Hidden;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> IsPopup;
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.String> TestTag;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.text.AnnotatedString> Text;
field public static final androidx.ui.semantics.SemanticsProperties INSTANCE;
}
public final class SemanticsPropertiesKt {
- method public static void ScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,java.lang.Boolean> action);
+ method public static void disabled(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getAccessibilityValue(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.semantics.AccessibilityRangeInfo getAccessibilityValueRange(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static java.util.List<androidx.ui.semantics.CustomAccessibilityAction> getCustomActions(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getEnabled(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getHidden(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getOnClick(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getPopup(androidx.ui.semantics.SemanticsPropertyReceiver);
- method @Deprecated public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getScrollBackward(androidx.ui.semantics.SemanticsPropertyReceiver);
- method @Deprecated public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> getScrollForward(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> getScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>> getSetProgress(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static String getTestTag(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.text.AnnotatedString getText(androidx.ui.semantics.SemanticsPropertyReceiver);
+ method public static void hidden(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static void onClick(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
+ method public static void popup(androidx.ui.semantics.SemanticsPropertyReceiver);
method @Deprecated public static void scrollBackward(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
+ method public static void scrollBy(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function2<? super java.lang.Float,? super java.lang.Float,java.lang.Boolean> action);
method @Deprecated public static void scrollForward(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function0<java.lang.Boolean> action);
method public static void setAccessibilityLabel(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
method public static void setAccessibilityValue(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
method public static void setAccessibilityValueRange(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityRangeInfo p);
method public static void setCustomActions(androidx.ui.semantics.SemanticsPropertyReceiver, java.util.List<androidx.ui.semantics.CustomAccessibilityAction> p);
- method public static void setEnabled(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
- method public static void setHidden(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
- method public static void setOnClick(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
- method public static void setPopup(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setProgress(androidx.ui.semantics.SemanticsPropertyReceiver, String? label = null, kotlin.jvm.functions.Function1<? super java.lang.Float,java.lang.Boolean> action);
- method @Deprecated public static void setScrollBackward(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
- method @Deprecated public static void setScrollForward(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>> p);
- method public static void setScrollTo(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function2<java.lang.Float,java.lang.Float,java.lang.Boolean>> p);
- method public static void setSetProgress(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function1<java.lang.Float,java.lang.Boolean>> p);
method public static void setTestTag(androidx.ui.semantics.SemanticsPropertyReceiver, String p);
method public static void setText(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.text.AnnotatedString p);
}
- public class SemanticsPropertyKey<T> implements kotlin.properties.ReadWriteProperty<androidx.ui.semantics.SemanticsPropertyReceiver,T> {
+ public final class SemanticsPropertyKey<T> {
ctor public SemanticsPropertyKey(String name);
- method public final String getName();
- method public final T! getValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property);
- method public T! merge(T? existingValue, T? newValue);
- method public final void setValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property, T? value);
+ method public String getName();
+ method public operator T! getValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property);
+ method public operator void setValue(androidx.ui.semantics.SemanticsPropertyReceiver thisRef, kotlin.reflect.KProperty<?> property, T? value);
}
public interface SemanticsPropertyReceiver {
diff --git a/ui/ui-core/build.gradle b/ui/ui-core/build.gradle
index ce206cc..47a0b16 100644
--- a/ui/ui-core/build.gradle
+++ b/ui/ui-core/build.gradle
@@ -91,7 +91,7 @@
exclude group: 'org.mockito' // to keep control on the mockito version
}
implementation project(":compose:test:test-core")
- implementation project(":ui:ui-test-font")
+ implementation project(":compose:core:core-test-font")
implementation project(":compose:foundation:foundation-layout")
implementation project(":compose:foundation:foundation")
}
diff --git a/ui/ui-core/integration-tests/ui-core-demos/build.gradle b/ui/ui-core/integration-tests/ui-core-demos/build.gradle
index a28804a..e9836f3 100644
--- a/ui/ui-core/integration-tests/ui-core-demos/build.gradle
+++ b/ui/ui-core/integration-tests/ui-core-demos/build.gradle
@@ -15,7 +15,7 @@
implementation(KOTLIN_STDLIB)
implementation project(":compose:runtime:runtime")
- implementation project(":ui:integration-tests:demos:common")
+ implementation project(":compose:integration-tests:demos:common")
implementation project(":compose:core:core")
implementation project(":compose:foundation:foundation-layout")
implementation project(":compose:core:core-text")
diff --git a/ui/ui-core/integration-tests/ui-core-demos/src/main/java/androidx/ui/core/demos/viewinterop/ViewRef.kt b/ui/ui-core/integration-tests/ui-core-demos/src/main/java/androidx/ui/core/demos/viewinterop/ViewRef.kt
index 3ebb69a..7d02c7b 100644
--- a/ui/ui-core/integration-tests/ui-core-demos/src/main/java/androidx/ui/core/demos/viewinterop/ViewRef.kt
+++ b/ui/ui-core/integration-tests/ui-core-demos/src/main/java/androidx/ui/core/demos/viewinterop/ViewRef.kt
@@ -19,7 +19,7 @@
import android.view.View
import androidx.ui.core.Ref
-// TODO(popam): this file is a subset of ViewRef.kt in ui-android-view. Deduplicate later
+// TODO(popam): this file is a subset of ViewRef.kt in android-view. Deduplicate later
/**
* A Ref is essentially a "value-holder" class that can be used with Compose to get
diff --git a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/HotReloadTests.kt b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/HotReloadTests.kt
index b2ebce3..2c1232f 100644
--- a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/HotReloadTests.kt
+++ b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/HotReloadTests.kt
@@ -33,7 +33,7 @@
import androidx.ui.semantics.accessibilityLabel
import androidx.ui.test.android.AndroidComposeTestRule
import androidx.ui.test.assertLabelEquals
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnUiThread
import org.junit.After
import org.junit.Assert.assertEquals
@@ -147,7 +147,7 @@
assertTrue(composeLatch.await(1, TimeUnit.SECONDS))
- fun target() = findByTag("text103")
+ fun target() = onNodeWithTag("text103")
// Assert that the composition has the correct value
target().assertLabelEquals(value)
diff --git a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/PainterModifierTest.kt b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/PainterModifierTest.kt
index c80b9e4..575ebc1f 100644
--- a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/PainterModifierTest.kt
+++ b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/PainterModifierTest.kt
@@ -58,7 +58,7 @@
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findRoot
+import androidx.ui.test.onRoot
import org.junit.Assert
import org.junit.Assert.assertEquals
import org.junit.Rule
@@ -447,7 +447,7 @@
)
}
- findRoot()
+ onRoot()
.assertWidthIsEqualTo(composableWidth.dp)
.assertHeightIsEqualTo(composableHeight.dp)
}
@@ -567,7 +567,7 @@
}
private fun obtainScreenshotBitmap(width: Int, height: Int = width): Bitmap {
- val bitmap = findRoot().captureToBitmap()
+ val bitmap = onRoot().captureToBitmap()
Assert.assertEquals(width, bitmap.width)
Assert.assertEquals(height, bitmap.height)
return bitmap
diff --git a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/keyinput/ProcessKeyInputTest.kt b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/keyinput/ProcessKeyInputTest.kt
index b6545e7..ec6dd86 100644
--- a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/keyinput/ProcessKeyInputTest.kt
+++ b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/keyinput/ProcessKeyInputTest.kt
@@ -24,8 +24,8 @@
import androidx.ui.core.keyinput.KeyEventType.KeyUp
import androidx.ui.foundation.Box
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doSendKeyEvent
-import androidx.ui.test.findRoot
+import androidx.ui.test.onRoot
+import androidx.ui.test.performKeyPress
import androidx.ui.test.runOnIdleCompose
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
@@ -48,7 +48,7 @@
}
// Act.
- findRoot().doSendKeyEvent(keyEvent(A, KeyUp))
+ onRoot().performKeyPress(keyEvent(A, KeyUp))
}
@Test(expected = IllegalStateException::class)
@@ -59,7 +59,7 @@
}
// Act.
- findRoot().doSendKeyEvent(keyEvent(A, KeyUp))
+ onRoot().performKeyPress(keyEvent(A, KeyUp))
}
@Test(expected = IllegalStateException::class)
@@ -71,7 +71,7 @@
}
// Act.
- findRoot().doSendKeyEvent(keyEvent(A, KeyUp))
+ onRoot().performKeyPress(keyEvent(A, KeyUp))
}
@Test
@@ -87,7 +87,7 @@
}
// Act.
- val keyConsumed = findRoot().doSendKeyEvent(keyEvent(A, KeyUp))
+ val keyConsumed = onRoot().performKeyPress(keyEvent(A, KeyUp))
// Assert.
runOnIdleCompose {
@@ -114,7 +114,7 @@
}
// Act.
- val keyConsumed = findRoot().doSendKeyEvent(keyEvent(A, KeyUp))
+ val keyConsumed = onRoot().performKeyPress(keyEvent(A, KeyUp))
// Assert.
runOnIdleCompose {
@@ -142,7 +142,7 @@
}
// Act.
- val keyConsumed = findRoot().doSendKeyEvent(keyEvent(A, KeyUp))
+ val keyConsumed = onRoot().performKeyPress(keyEvent(A, KeyUp))
// Assert.
runOnIdleCompose {
@@ -176,7 +176,7 @@
}
// Act.
- findRoot().doSendKeyEvent(keyEvent(A, KeyUp))
+ onRoot().performKeyPress(keyEvent(A, KeyUp))
// Assert.
runOnIdleCompose {
@@ -211,7 +211,7 @@
}
// Act.
- findRoot().doSendKeyEvent(keyEvent(A, KeyUp))
+ onRoot().performKeyPress(keyEvent(A, KeyUp))
// Assert.
runOnIdleCompose {
@@ -260,7 +260,7 @@
}
// Act.
- findRoot().doSendKeyEvent(keyEvent(A, KeyUp))
+ onRoot().performKeyPress(keyEvent(A, KeyUp))
// Assert.
runOnIdleCompose {
@@ -311,7 +311,7 @@
}
// Act.
- findRoot().doSendKeyEvent(keyEvent(A, KeyUp))
+ onRoot().performKeyPress(keyEvent(A, KeyUp))
// Assert.
runOnIdleCompose {
@@ -376,7 +376,7 @@
}
// Act.
- findRoot().doSendKeyEvent(keyEvent(A, KeyUp))
+ onRoot().performKeyPress(keyEvent(A, KeyUp))
// Assert.
runOnIdleCompose {
diff --git a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/test/AndroidViewCompatTest.kt b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/test/AndroidViewCompatTest.kt
index dfc6f93..4c34346 100644
--- a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/test/AndroidViewCompatTest.kt
+++ b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/test/AndroidViewCompatTest.kt
@@ -81,7 +81,7 @@
import androidx.ui.test.assertIsDisplayed
import androidx.ui.test.assertPixels
import androidx.ui.test.captureToBitmap
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.runOnUiThread
import androidx.ui.unit.IntOffset
@@ -142,7 +142,7 @@
}
}
}
- findByTag("content").assertIsDisplayed()
+ onNodeWithTag("content").assertIsDisplayed()
val squareView = squareRef.value
assertNotNull(squareView)
Espresso
@@ -155,7 +155,7 @@
squareSize.value = 200
expectedSize = 200
}
- findByTag("content").assertIsDisplayed()
+ onNodeWithTag("content").assertIsDisplayed()
Espresso
.onView(instanceOf(ColoredSquareView::class.java))
.check(matches(isDescendantOfA(instanceOf(Owner::class.java))))
@@ -166,7 +166,7 @@
squareView!!.size = 300
expectedSize = 300
}
- findByTag("content").assertIsDisplayed()
+ onNodeWithTag("content").assertIsDisplayed()
Espresso
.onView(instanceOf(ColoredSquareView::class.java))
.check(matches(isDescendantOfA(instanceOf(Owner::class.java))))
@@ -203,7 +203,7 @@
Color.White
}
}
- findByTag("content")
+ onNodeWithTag("content")
.assertIsDisplayed()
.captureToBitmap()
.assertPixels(expectedColorProvider = expectedPixelColor)
@@ -217,7 +217,7 @@
.onView(instanceOf(ColoredSquareView::class.java))
.check(matches(isDescendantOfA(instanceOf(Owner::class.java))))
.check(matches(`is`(squareView)))
- findByTag("content")
+ onNodeWithTag("content")
.assertIsDisplayed()
.captureToBitmap()
.assertPixels(expectedColorProvider = expectedPixelColor)
@@ -231,7 +231,7 @@
.onView(instanceOf(ColoredSquareView::class.java))
.check(matches(isDescendantOfA(instanceOf(Owner::class.java))))
.check(matches(`is`(squareView)))
- findByTag("content")
+ onNodeWithTag("content")
.assertIsDisplayed()
.captureToBitmap()
.assertPixels(expectedColorProvider = expectedPixelColor)
@@ -425,13 +425,13 @@
view.setBackgroundColor(android.graphics.Color.BLUE)
}
}
- findByTag("view").captureToBitmap().assertPixels(IntSize(size, size)) { Color.Blue }
+ onNodeWithTag("view").captureToBitmap().assertPixels(IntSize(size, size)) { Color.Blue }
runOnIdleCompose { size += 20 }
- findByTag("view").captureToBitmap().assertPixels(IntSize(size, size)) { Color.Blue }
+ onNodeWithTag("view").captureToBitmap().assertPixels(IntSize(size, size)) { Color.Blue }
runOnIdleCompose { size += 20 }
- findByTag("view").captureToBitmap().assertPixels(IntSize(size, size)) { Color.Blue }
+ onNodeWithTag("view").captureToBitmap().assertPixels(IntSize(size, size)) { Color.Blue }
}
@Test
@@ -551,7 +551,7 @@
}
}
- findByTag("box").captureToBitmap().assertPixels(
+ onNodeWithTag("box").captureToBitmap().assertPixels(
IntSize((padding * 2 + size * 2).roundToInt(), (padding * 2 + size).roundToInt())
) { offset ->
if (offset.y < padding || offset.y >= padding + size || offset.x < padding ||
@@ -641,11 +641,13 @@
}
}
- findByTag("view").captureToBitmap().assertPixels(IntSize(sizePx, sizePx)) { Color.Green }
+ onNodeWithTag("view")
+ .captureToBitmap().assertPixels(IntSize(sizePx, sizePx)) { Color.Green }
runOnIdleCompose { first = false }
- findByTag("view").captureToBitmap().assertPixels(IntSize(sizePx, sizePx)) { Color.Blue }
+ onNodeWithTag("view")
+ .captureToBitmap().assertPixels(IntSize(sizePx, sizePx)) { Color.Blue }
}
@Test
@@ -677,14 +679,14 @@
}
}
- findByTag("view").captureToBitmap()
+ onNodeWithTag("view").captureToBitmap()
.assertPixels(IntSize(sizePx * 2, sizePx)) {
if (it.x < sizePx) Color.Green else Color.Blue
}
runOnIdleCompose { first = false }
- findByTag("view").captureToBitmap()
+ onNodeWithTag("view").captureToBitmap()
.assertPixels(IntSize(sizePx * 2, sizePx)) {
if (it.x < sizePx) Color.Blue else Color.Green
}
diff --git a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/test/DrawShadowTest.kt b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/test/DrawShadowTest.kt
index 8dcd648..0163ff7 100644
--- a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/test/DrawShadowTest.kt
+++ b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/test/DrawShadowTest.kt
@@ -59,7 +59,6 @@
private lateinit var activity: TestActivity
private lateinit var drawLatch: CountDownLatch
- // TODO move RectangleShape to ui-framework b/137222372
private val rectShape = object : Shape {
override fun createOutline(size: Size, density: Density): Outline =
Outline.Rectangle(size.toRect())
diff --git a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/test/LayerTouchTransformTest.kt b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/test/LayerTouchTransformTest.kt
index c6b4706..a31936b 100644
--- a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/test/LayerTouchTransformTest.kt
+++ b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/core/test/LayerTouchTransformTest.kt
@@ -38,9 +38,9 @@
import androidx.ui.layout.preferredSize
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doPartialGesture
-import androidx.ui.test.findByTag
-import androidx.ui.test.sendDown
+import androidx.ui.test.performPartialGesture
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.down
import androidx.ui.geometry.Offset
import androidx.ui.unit.dp
import org.junit.Assert
@@ -122,7 +122,7 @@
// its bounds
val mappedPosition = Offset(342.0f, 168.0f)
- val node = findByTag(testTag).doPartialGesture { sendDown(mappedPosition) }
+ val node = onNodeWithTag(testTag).performPartialGesture { down(mappedPosition) }
latch = CountDownLatch(1).apply {
await(5, TimeUnit.SECONDS)
diff --git a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/graphics/vector/VectorTest.kt b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/graphics/vector/VectorTest.kt
index 24c39dc..c328913 100644
--- a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/graphics/vector/VectorTest.kt
+++ b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/graphics/vector/VectorTest.kt
@@ -25,54 +25,43 @@
import androidx.ui.core.DensityAmbient
import androidx.ui.core.Modifier
import androidx.ui.core.paint
-import androidx.ui.core.setContent
import androidx.ui.core.test.AtLeastSize
-import androidx.ui.core.test.runOnUiThreadIR
-import androidx.ui.core.test.waitAndScreenShot
-import androidx.ui.framework.test.TestActivity
+import androidx.ui.foundation.Box
import androidx.ui.graphics.Color
import androidx.ui.graphics.ColorFilter
import androidx.ui.graphics.SolidColor
import androidx.ui.graphics.toArgb
+import androidx.ui.layout.preferredHeight
+import androidx.ui.layout.preferredSize
+import androidx.ui.layout.preferredWidth
+import androidx.ui.test.captureToBitmap
+import androidx.ui.test.createComposeRule
+import androidx.ui.test.onRoot
+import androidx.ui.test.runOnUiThread
+import androidx.ui.test.waitForIdle
import androidx.ui.unit.dp
import org.junit.Assert
import org.junit.Assert.assertEquals
-import org.junit.Assert.assertTrue
-import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import java.util.concurrent.CountDownLatch
-import java.util.concurrent.TimeUnit
@SmallTest
@RunWith(JUnit4::class)
class VectorTest {
- @Suppress("DEPRECATION")
@get:Rule
- val rule = androidx.test.rule.ActivityTestRule<TestActivity>(TestActivity::class.java)
- private lateinit var activity: TestActivity
- private lateinit var drawLatch: CountDownLatch
-
- @Before
- fun setup() {
- activity = rule.activity
- activity.hasFocusLatch.await(5, TimeUnit.SECONDS)
- drawLatch = CountDownLatch(1)
- }
+ val rule = createComposeRule()
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.O)
@Test
fun testVectorTint() {
- rule.runOnUiThreadIR {
- activity.setContent {
- VectorTint()
- }
+ rule.setContent {
+ VectorTint()
}
- assertTrue(drawLatch.await(1, TimeUnit.SECONDS))
takeScreenShot(200).apply {
assertEquals(getPixel(100, 100), Color.Cyan.toArgb())
}
@@ -81,13 +70,10 @@
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.O)
@Test
fun testVectorAlignment() {
- rule.runOnUiThreadIR {
- activity.setContent {
- VectorTint(minimumSize = 500, alignment = Alignment.BottomEnd)
- }
+ rule.setContent {
+ VectorTint(minimumSize = 500, alignment = Alignment.BottomEnd)
}
- assertTrue(drawLatch.await(1, TimeUnit.SECONDS))
takeScreenShot(500).apply {
assertEquals(getPixel(480, 480), Color.Cyan.toArgb())
}
@@ -99,13 +85,10 @@
val latch1 = CountDownLatch(1)
val latch2 = CountDownLatch(1)
val testCase = VectorInvalidationTestCase(latch1)
- rule.runOnUiThreadIR {
- activity.setContent {
- testCase.createTestVector()
- }
+ rule.setContent {
+ testCase.createTestVector()
}
- latch1.await(5, TimeUnit.SECONDS)
val size = testCase.vectorSize
takeScreenShot(size).apply {
assertEquals(Color.Blue.toArgb(), getPixel(5, size - 5))
@@ -113,11 +96,12 @@
}
testCase.latch = latch2
- rule.runOnUiThreadIR {
+ runOnUiThread {
testCase.toggle()
}
- latch2.await(5, TimeUnit.SECONDS)
+ waitForIdle()
+
takeScreenShot(size).apply {
assertEquals(Color.White.toArgb(), getPixel(5, size - 5))
assertEquals(Color.Red.toArgb(), getPixel(size - 5, 5))
@@ -127,43 +111,51 @@
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.O)
@Test
fun testVectorClipPath() {
- rule.runOnUiThreadIR {
- activity.setContent {
- VectorClip()
- }
+ rule.setContent {
+ VectorClip()
}
- assertTrue(drawLatch.await(1, TimeUnit.SECONDS))
takeScreenShot(200).apply {
assertEquals(getPixel(100, 50), Color.Cyan.toArgb())
assertEquals(getPixel(100, 150), Color.Black.toArgb())
}
}
+ @Test
+ fun testVectorZeroSizeDoesNotCrash() {
+ // Make sure that if we are given the size of zero we should not crash and instead
+ // act as a no-op
+ rule.setContent {
+ Box(modifier = Modifier.preferredSize(0.dp).paint(createTestVectorPainter()))
+ }
+ }
+
+ @Test
+ fun testVectorZeroWidthDoesNotCrash() {
+ rule.setContent {
+ Box(modifier = Modifier.preferredWidth(0.dp).preferredHeight(100.dp).paint
+ (createTestVectorPainter()))
+ }
+ }
+
+ @Test
+ fun testVectorZeroHeightDoesNotCrash() {
+ rule.setContent {
+ Box(modifier = Modifier.preferredWidth(50.dp).preferredHeight(0.dp).paint(
+ createTestVectorPainter()
+ ))
+ }
+ }
+
@Composable
private fun VectorTint(
size: Int = 200,
minimumSize: Int = size,
alignment: Alignment = Alignment.Center
) {
- val sizePx = size.toFloat()
- val sizeDp = (size / DensityAmbient.current.density).dp
- val background = Modifier.paint(
- VectorPainter(
- defaultWidth = sizeDp,
- defaultHeight = sizeDp) { _, _ ->
- Path(
- pathData = PathData {
- lineTo(sizePx, 0.0f)
- lineTo(sizePx, sizePx)
- lineTo(0.0f, sizePx)
- close()
- },
- fill = SolidColor(Color.Black)
- )
- drawLatch.countDown()
- },
+ val background = Modifier.paint(
+ createTestVectorPainter(size),
colorFilter = ColorFilter.tint(Color.Cyan),
alignment = alignment
)
@@ -172,6 +164,25 @@
}
@Composable
+ private fun createTestVectorPainter(size: Int = 200): VectorPainter {
+ val sizePx = size.toFloat()
+ val sizeDp = (size / DensityAmbient.current.density).dp
+ return VectorPainter(
+ defaultWidth = sizeDp,
+ defaultHeight = sizeDp) { _, _ ->
+ Path(
+ pathData = PathData {
+ lineTo(sizePx, 0.0f)
+ lineTo(sizePx, sizePx)
+ lineTo(0.0f, sizePx)
+ close()
+ },
+ fill = SolidColor(Color.Black)
+ )
+ }
+ }
+
+ @Composable
private fun VectorClip(
size: Int = 200,
minimumSize: Int = size,
@@ -217,8 +228,6 @@
fill = SolidColor(Color.Black)
)
}
-
- drawLatch.countDown()
},
alignment = alignment
)
@@ -227,7 +236,7 @@
}
private fun takeScreenShot(width: Int, height: Int = width): Bitmap {
- val bitmap = rule.waitAndScreenShot()
+ val bitmap = onRoot().captureToBitmap()
Assert.assertEquals(width, bitmap.width)
Assert.assertEquals(height, bitmap.height)
return bitmap
diff --git a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/semantics/SemanticsTests.kt b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/semantics/SemanticsTests.kt
index cd1a1cd..6feea64 100644
--- a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/semantics/SemanticsTests.kt
+++ b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/semantics/SemanticsTests.kt
@@ -30,11 +30,11 @@
import androidx.ui.test.assertLabelEquals
import androidx.ui.test.assertValueEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findAllByText
-import androidx.ui.test.findByTag
+import androidx.ui.test.onAllNodesWithText
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.assert
-import androidx.ui.test.findAllByLabel
-import androidx.ui.test.findByLabel
+import androidx.ui.test.onAllNodesWithLabel
+import androidx.ui.test.onNodeWithLabel
import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.runOnUiThread
import com.google.common.truth.Truth.assertThat
@@ -70,16 +70,16 @@
val label1 = "foo"
val label2 = "bar"
composeTestRule.setContent {
- SimpleTestLayout(Modifier.semantics(mergeAllDescendants = true).testTag(tag1)) {
+ SimpleTestLayout(Modifier.semantics(mergeAllDescendants = true) {}.testTag(tag1)) {
SimpleTestLayout(Modifier.semantics { accessibilityLabel = label1 }) { }
- SimpleTestLayout(Modifier.semantics(mergeAllDescendants = true).testTag(tag2)) {
+ SimpleTestLayout(Modifier.semantics(mergeAllDescendants = true) {}.testTag(tag2)) {
SimpleTestLayout(Modifier.semantics { accessibilityLabel = label2 }) { }
}
}
}
- findByTag(tag1).assertLabelEquals(label1)
- findByTag(tag2).assertLabelEquals(label2)
+ onNodeWithTag(tag1).assertLabelEquals(label1)
+ onNodeWithTag(tag2).assertLabelEquals(label2)
}
@Test
@@ -87,20 +87,20 @@
val label = "foo"
val showSubtree = mutableStateOf(true)
composeTestRule.setContent {
- SimpleTestLayout(Modifier.semantics(mergeAllDescendants = true).testTag(TestTag)) {
+ SimpleTestLayout(Modifier.semantics(mergeAllDescendants = true) {}.testTag(TestTag)) {
if (showSubtree.value) {
SimpleTestLayout(Modifier.semantics { accessibilityLabel = label }) { }
}
}
}
- findByTag(TestTag).assertLabelEquals(label)
+ onNodeWithTag(TestTag).assertLabelEquals(label)
runOnIdleCompose { showSubtree.value = false }
- findByTag(TestTag).assertDoesNotHaveProperty(SemanticsProperties.AccessibilityLabel)
+ onNodeWithTag(TestTag).assertDoesNotHaveProperty(SemanticsProperties.AccessibilityLabel)
- findAllByText(label).assertCountEquals(0)
+ onAllNodesWithText(label).assertCountEquals(0)
}
@Test
@@ -109,7 +109,7 @@
val value = "bar"
val showNewNode = mutableStateOf(false)
composeTestRule.setContent {
- SimpleTestLayout(Modifier.semantics(mergeAllDescendants = true).testTag(TestTag)) {
+ SimpleTestLayout(Modifier.semantics(mergeAllDescendants = true) {}.testTag(TestTag)) {
SimpleTestLayout(Modifier.semantics { accessibilityLabel = label }) { }
if (showNewNode.value) {
SimpleTestLayout(Modifier.semantics { accessibilityValue = value }) { }
@@ -117,13 +117,13 @@
}
}
- findByTag(TestTag)
+ onNodeWithTag(TestTag)
.assertLabelEquals(label)
.assertDoesNotHaveProperty(SemanticsProperties.AccessibilityValue)
runOnIdleCompose { showNewNode.value = true }
- findByTag(TestTag)
+ onNodeWithTag(TestTag)
.assertLabelEquals(label)
.assertValueEquals(value)
}
@@ -140,13 +140,13 @@
}
}
- findAllByLabel(label).assertCountEquals(1)
+ onAllNodesWithLabel(label).assertCountEquals(1)
runOnIdleCompose {
showSubtree.value = false
}
- findAllByLabel(label).assertCountEquals(0)
+ onAllNodesWithLabel(label).assertCountEquals(0)
}
@Test
@@ -160,11 +160,11 @@
) {}
}
- findByTag(TestTag).assertLabelEquals(beforeLabel)
+ onNodeWithTag(TestTag).assertLabelEquals(beforeLabel)
runOnIdleCompose { isAfter.value = true }
- findByTag(TestTag).assertLabelEquals(afterLabel)
+ onNodeWithTag(TestTag).assertLabelEquals(afterLabel)
}
@Test
@@ -181,11 +181,11 @@
}
}
- findByTag(TestTag).assertLabelEquals(beforeLabel)
+ onNodeWithTag(TestTag).assertLabelEquals(beforeLabel)
runOnIdleCompose { isAfter.value = true }
- findByTag(TestTag).assertLabelEquals(afterLabel)
+ onNodeWithTag(TestTag).assertLabelEquals(afterLabel)
}
@Test
@@ -204,11 +204,11 @@
}
}
- findByTag(TestTag).assertLabelEquals(beforeLabel)
+ onNodeWithTag(TestTag).assertLabelEquals(beforeLabel)
runOnIdleCompose { isAfter.value = true }
- findByTag(TestTag).assertLabelEquals(afterLabel)
+ onNodeWithTag(TestTag).assertLabelEquals(afterLabel)
}
@Test
@@ -218,18 +218,18 @@
val isAfter = mutableStateOf(false)
composeTestRule.setContent {
- SimpleTestLayout(Modifier.testTag(TestTag).semantics(mergeAllDescendants = true)) {
+ SimpleTestLayout(Modifier.testTag(TestTag).semantics(mergeAllDescendants = true) {}) {
SimpleTestLayout(Modifier.semantics {
accessibilityLabel = if (isAfter.value) afterLabel else beforeLabel }
) {}
}
}
- findByTag(TestTag).assertLabelEquals(beforeLabel)
+ onNodeWithTag(TestTag).assertLabelEquals(beforeLabel)
runOnIdleCompose { isAfter.value = true }
- findByTag(TestTag).assertLabelEquals(afterLabel)
+ onNodeWithTag(TestTag).assertLabelEquals(afterLabel)
}
@Test
@@ -237,14 +237,14 @@
val label = "label"
composeTestRule.setContent {
SimpleTestLayout(Modifier.testTag(TestTag)) {
- SimpleTestLayout(Modifier.semantics(mergeAllDescendants = true)) {
+ SimpleTestLayout(Modifier.semantics(mergeAllDescendants = true) {}) {
SimpleTestLayout(Modifier.semantics { accessibilityLabel = label }) { }
}
}
}
- findByTag(TestTag).assertDoesNotHaveProperty(SemanticsProperties.AccessibilityLabel)
- findByLabel(label) // assert exists
+ onNodeWithTag(TestTag).assertDoesNotHaveProperty(SemanticsProperties.AccessibilityLabel)
+ onNodeWithLabel(label) // assert exists
}
@Test
@@ -265,11 +265,11 @@
}
}
- findByTag(TestTag).assertLabelEquals(beforeLabel)
+ onNodeWithTag(TestTag).assertLabelEquals(beforeLabel)
runOnIdleCompose { isAfter.value = true }
- findByTag(TestTag).assertLabelEquals(afterLabel)
+ onNodeWithTag(TestTag).assertLabelEquals(afterLabel)
}
@Test
@@ -300,13 +300,13 @@
}
// This isn't the important part, just makes sure everything is behaving as expected
- findByTag(TestTag).assertLabelEquals(beforeLabel)
+ onNodeWithTag(TestTag).assertLabelEquals(beforeLabel)
assertThat(nodeCount).isEqualTo(1)
runOnIdleCompose { isAfter.value = true }
// Make sure everything is still behaving as expected
- findByTag(TestTag).assertLabelEquals(afterLabel)
+ onNodeWithTag(TestTag).assertLabelEquals(afterLabel)
// This is the important part: make sure we didn't replace the identity due to unwanted
// pivotal properties
assertThat(nodeCount).isEqualTo(1)
diff --git a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/viewinterop/ComposedViewTest.kt b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/viewinterop/ComposedViewTest.kt
index c435b9d..baf05e4 100644
--- a/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/viewinterop/ComposedViewTest.kt
+++ b/ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/viewinterop/ComposedViewTest.kt
@@ -45,7 +45,7 @@
import androidx.ui.test.android.AndroidComposeTestRule
import androidx.ui.test.assertPixels
import androidx.ui.test.captureToBitmap
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.runOnUiThread
import androidx.ui.unit.Dp
@@ -189,7 +189,7 @@
AndroidView(frameLayout, Modifier.testTag("view").drawBackground(Color.Blue))
}
- findByTag("view").captureToBitmap().assertPixels(IntSize(size, size)) {
+ onNodeWithTag("view").captureToBitmap().assertPixels(IntSize(size, size)) {
Color.Blue
}
}
diff --git a/ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidActuals.kt b/ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidActuals.kt
index 07f5af7..468ab05 100644
--- a/ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidActuals.kt
+++ b/ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidActuals.kt
@@ -16,8 +16,10 @@
package androidx.ui.core
-actual typealias NativeRectF = android.graphics.RectF
-actual typealias NativeMatrix = android.graphics.Matrix
+internal actual typealias AtomicInt = java.util.concurrent.atomic.AtomicInteger
+
+internal actual typealias NativeRectF = android.graphics.RectF
+internal actual typealias NativeMatrix = android.graphics.Matrix
internal actual fun simpleIdentityToString(obj: Any, name: String?): String {
val className = name ?: if (obj::class.java.isAnonymousClass) {
diff --git a/ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidComposeView.kt b/ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidComposeView.kt
index a06492c..8e091ba4 100644
--- a/ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidComposeView.kt
+++ b/ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidComposeView.kt
@@ -70,7 +70,6 @@
import androidx.ui.core.pointerinput.PointerInputEventProcessor
import androidx.ui.core.pointerinput.ProcessResult
import androidx.ui.core.semantics.SemanticsModifierCore
-import androidx.ui.core.semantics.SemanticsNode
import androidx.ui.core.semantics.SemanticsOwner
import androidx.ui.core.text.AndroidFontResourceLoader
import androidx.ui.core.texttoolbar.AndroidTextToolbar
@@ -124,9 +123,9 @@
private set
private val semanticsModifier = SemanticsModifierCore(
- id = SemanticsNode.generateNewId(),
+ id = SemanticsModifierCore.generateSemanticsId(),
mergeAllDescendants = false,
- properties = null
+ properties = {}
)
private val focusModifier = FocusModifierImpl(Inactive)
private val keyInputModifier = KeyInputModifier(null, null)
diff --git a/ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidComposeViewAccessibilityDelegateCompat.kt b/ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidComposeViewAccessibilityDelegateCompat.kt
index 6640ab1..0c61f80 100644
--- a/ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidComposeViewAccessibilityDelegateCompat.kt
+++ b/ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidComposeViewAccessibilityDelegateCompat.kt
@@ -201,9 +201,8 @@
semanticsNode.config.getOrNull(SemanticsProperties.AccessibilityValue)
info.contentDescription =
semanticsNode.config.getOrNull(SemanticsProperties.AccessibilityLabel)
- info.isEnabled = semanticsNode.config.getOrElse(SemanticsProperties.Enabled) { true }
- info.isVisibleToUser = !(semanticsNode.config.getOrElse(
- SemanticsProperties.Hidden) { false })
+ info.isEnabled = (semanticsNode.config.getOrNull(SemanticsProperties.Disabled) == null)
+ info.isVisibleToUser = (semanticsNode.config.getOrNull(SemanticsProperties.Hidden) == null)
info.isClickable = semanticsNode.config.contains(SemanticsActions.OnClick)
if (info.isClickable) {
info.addAction(
@@ -458,7 +457,7 @@
AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS ->
return clearAccessibilityFocus(virtualViewId)
AccessibilityNodeInfoCompat.ACTION_CLICK -> {
- return if (node.canPerformAction(SemanticsActions.OnClick)) {
+ return if (node.config.contains(SemanticsActions.OnClick)) {
node.config[SemanticsActions.OnClick].action()
} else {
false
@@ -468,7 +467,7 @@
// TODO(b/157692376): remove scroll forward/backward api together with slider
// scroll action.
@Suppress("DEPRECATION")
- return if (node.canPerformAction(SemanticsActions.ScrollForward)) {
+ return if (node.config.contains(SemanticsActions.ScrollForward)) {
node.config[SemanticsActions.ScrollForward].action()
} else {
false
@@ -476,7 +475,7 @@
}
AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD -> {
@Suppress("DEPRECATION")
- return if (node.canPerformAction(SemanticsActions.ScrollBackward)) {
+ return if (node.config.contains(SemanticsActions.ScrollBackward)) {
node.config[SemanticsActions.ScrollBackward].action()
} else {
false
@@ -489,7 +488,7 @@
) {
return false
}
- return if (node.canPerformAction(SemanticsActions.SetProgress)) {
+ return if (node.config.contains(SemanticsActions.SetProgress)) {
node.config[SemanticsActions.SetProgress].action(
arguments.getFloat(
AccessibilityNodeInfoCompat.ACTION_ARGUMENT_PROGRESS_VALUE
diff --git a/ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidPopup.kt b/ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidPopup.kt
index 1dd7771..543a5ed 100644
--- a/ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidPopup.kt
+++ b/ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidPopup.kt
@@ -104,7 +104,7 @@
val parentComposition = compositionReference()
onCommit {
composition = popupLayout.setContent(recomposer, parentComposition) {
- SimpleStack(Modifier.semantics { this.popup = true }.onPositioned {
+ SimpleStack(Modifier.semantics { this.popup() }.onPositioned {
// Get the size of the content
popupLayout.popupPositionProperties.childrenSize = it.size
diff --git a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/DelegatingLayoutNodeWrapper.kt b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/DelegatingLayoutNodeWrapper.kt
index 77acc72..cf5f6f7 100644
--- a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/DelegatingLayoutNodeWrapper.kt
+++ b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/DelegatingLayoutNodeWrapper.kt
@@ -17,6 +17,7 @@
package androidx.ui.core
import androidx.ui.core.focus.ModifiedFocusNode
+import androidx.ui.core.focus.ModifiedFocusNode2
import androidx.ui.core.keyinput.ModifiedKeyInputNode
import androidx.ui.core.pointerinput.PointerInputFilter
import androidx.ui.geometry.Offset
@@ -116,8 +117,12 @@
override fun findPreviousFocusWrapper() = wrappedBy?.findPreviousFocusWrapper()
+ override fun findPreviousFocusWrapper2() = wrappedBy?.findPreviousFocusWrapper2()
+
override fun findNextFocusWrapper() = wrapped.findNextFocusWrapper()
+ override fun findNextFocusWrapper2() = wrapped.findNextFocusWrapper2()
+
override fun findLastFocusWrapper(): ModifiedFocusNode? {
var lastFocusWrapper: ModifiedFocusNode? = null
@@ -130,6 +135,18 @@
return lastFocusWrapper
}
+ override fun findLastFocusWrapper2(): ModifiedFocusNode2? {
+ var lastFocusWrapper: ModifiedFocusNode2? = null
+
+ // Find last focus wrapper for the current layout node.
+ var next: ModifiedFocusNode2? = findNextFocusWrapper2()
+ while (next != null) {
+ lastFocusWrapper = next
+ next = next.wrapped.findNextFocusWrapper2()
+ }
+ return lastFocusWrapper
+ }
+
override fun findPreviousKeyInputWrapper() = wrappedBy?.findPreviousKeyInputWrapper()
override fun findNextKeyInputWrapper() = wrapped.findNextKeyInputWrapper()
diff --git a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/Expect.kt b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/Expect.kt
index ca38393..5c8a0bf 100644
--- a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/Expect.kt
+++ b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/Expect.kt
@@ -16,6 +16,14 @@
package androidx.ui.core
+// TODO(aelias): Mark the typealiases internal when https://youtrack.jetbrains.com/issue/KT-36695 is fixed.
+// Currently, they behave as internal because the actual is internal, even though the expect is public.
+
+expect class AtomicInt(value_: Int) {
+ fun addAndGet(delta: Int): Int
+ fun compareAndSet(expected: Int, new: Int): Boolean
+}
+
// TODO(b/160140398): rewrite depending code using androidx.ui.geometry.Rect and androidx.ui.vectormath64.Matrix3.
expect class NativeRectF() {
var left: Float
diff --git a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/InnerPlaceable.kt b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/InnerPlaceable.kt
index b546458..e5549bf 100644
--- a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/InnerPlaceable.kt
+++ b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/InnerPlaceable.kt
@@ -18,6 +18,7 @@
import androidx.ui.core.LayoutNode.LayoutState.Ready
import androidx.ui.core.focus.ModifiedFocusNode
+import androidx.ui.core.focus.ModifiedFocusNode2
import androidx.ui.core.keyinput.ModifiedKeyInputNode
import androidx.ui.core.pointerinput.PointerInputFilter
import androidx.ui.geometry.Offset
@@ -62,10 +63,16 @@
override fun findPreviousFocusWrapper() = wrappedBy?.findPreviousFocusWrapper()
+ override fun findPreviousFocusWrapper2() = wrappedBy?.findPreviousFocusWrapper2()
+
override fun findNextFocusWrapper() = null
+ override fun findNextFocusWrapper2() = null
+
override fun findLastFocusWrapper(): ModifiedFocusNode? = findPreviousFocusWrapper()
+ override fun findLastFocusWrapper2(): ModifiedFocusNode2? = findPreviousFocusWrapper2()
+
override fun findPreviousKeyInputWrapper() = wrappedBy?.findPreviousKeyInputWrapper()
override fun findNextKeyInputWrapper() = null
diff --git a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/LayoutNodeWrapper.kt b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/LayoutNodeWrapper.kt
index d0bab09..371562b 100644
--- a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/LayoutNodeWrapper.kt
+++ b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/LayoutNodeWrapper.kt
@@ -19,6 +19,7 @@
package androidx.ui.core
import androidx.ui.core.focus.ModifiedFocusNode
+import androidx.ui.core.focus.ModifiedFocusNode2
import androidx.ui.core.keyinput.ModifiedKeyInputNode
import androidx.ui.core.pointerinput.PointerInputFilter
import androidx.ui.geometry.Offset
@@ -297,23 +298,49 @@
/**
* Returns the first [ModifiedFocusNode] in the wrapper list that wraps this
* [LayoutNodeWrapper].
+ *
+ * TODO(b/160921940): Remove this function after removing ModifiedFocusNode.
*/
abstract fun findPreviousFocusWrapper(): ModifiedFocusNode?
/**
+ * Returns the first [focus node][ModifiedFocusNode2] in the wrapper list that wraps this
+ * [LayoutNodeWrapper].
+ */
+ abstract fun findPreviousFocusWrapper2(): ModifiedFocusNode2?
+
+ /**
* Returns the next [ModifiedFocusNode] in the wrapper list that is wrapped by this
* [LayoutNodeWrapper].
+ *
+ * TODO(b/160921940): Remove this function after removing ModifiedFocusNode.
*/
abstract fun findNextFocusWrapper(): ModifiedFocusNode?
/**
+ * Returns the next [focus node][ModifiedFocusNode2] in the wrapper list that is wrapped by
+ * this [LayoutNodeWrapper].
+ */
+ abstract fun findNextFocusWrapper2(): ModifiedFocusNode2?
+
+ /**
* Returns the last [ModifiedFocusNode] found following this [LayoutNodeWrapper]. It searches
- * the wrapper list associated with this [LayoutNodeWrapper]
+ * the wrapper list associated with this [LayoutNodeWrapper].
+ *
+ * TODO(b/160921940): Remove this function after removing ModifiedFocusNode.
*/
abstract fun findLastFocusWrapper(): ModifiedFocusNode?
/**
+ * Returns the last [focus node][ModifiedFocusNode2] found following this [LayoutNodeWrapper].
+ * It searches the wrapper list associated with this [LayoutNodeWrapper].
+ */
+ abstract fun findLastFocusWrapper2(): ModifiedFocusNode2?
+
+ /**
* Find the first ancestor that is a [ModifiedFocusNode].
+ *
+ * TODO(b/160921940): Remove this function after removing ModifiedFocusNode.
*/
internal fun findParentFocusNode(): ModifiedFocusNode? {
// TODO(b/152066829): We shouldn't need to search through the parentLayoutNode, as the
@@ -336,6 +363,29 @@
}
/**
+ * Find the first ancestor that is a [ModifiedFocusNode2].
+ */
+ internal fun findParentFocusNode2(): ModifiedFocusNode2? {
+ // TODO(b/152066829): We shouldn't need to search through the parentLayoutNode, as the
+ // wrappedBy property should automatically point to the last layoutWrapper of the parent.
+ // Find out why this doesn't work.
+ var focusParent = wrappedBy?.findPreviousFocusWrapper2()
+ if (focusParent != null) {
+ return focusParent
+ }
+
+ var parentLayoutNode = layoutNode.parent
+ while (parentLayoutNode != null) {
+ focusParent = parentLayoutNode.outerLayoutNodeWrapper.findLastFocusWrapper2()
+ if (focusParent != null) {
+ return focusParent
+ }
+ parentLayoutNode = parentLayoutNode.parent
+ }
+ return null
+ }
+
+ /**
* Find the first ancestor that is a [ModifiedKeyInputNode].
*/
internal fun findParentKeyInputNode(): ModifiedKeyInputNode? {
diff --git a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/focus/FocusModifier2.kt b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/focus/FocusModifier2.kt
new file mode 100644
index 0000000..44fa1af
--- /dev/null
+++ b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/focus/FocusModifier2.kt
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * 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 androidx.ui.core.focus
+
+import androidx.compose.Composable
+import androidx.compose.remember
+import androidx.ui.core.Modifier
+
+/**
+ * A [Modifier.Element] that wraps makes the modifiers on the right into a Focusable. Use a
+ * different instance of [FocusModifier2] for each focusable component.
+ *
+ * TODO(b/160923332): Rename FocusModifier2 to FocusModifier
+ *
+ * TODO(b/152528891): Write tests for [FocusModifier2] after we finalize on the api (API
+ * review tracked by b/152529882).
+ */
+@OptIn(ExperimentalFocus::class)
+internal class FocusModifier2(
+ initialFocus: FocusState2
+) : Modifier.Element {
+
+ var focusState: FocusState2 = initialFocus
+ set(value) {
+ field = value
+ // TODO(b/160923326): Propagate focus state change to all observers
+ // observing this focus modifier.
+ }
+
+ var focusedChild: ModifiedFocusNode2? = null
+
+ lateinit var focusNode: ModifiedFocusNode2
+}
+
+/**
+ * Add this modifier to a component to make it focusable.
+ */
+@ExperimentalFocus
+@Composable
+fun Modifier.focus(): Modifier = this + remember { FocusModifier2(FocusState2.Inactive) }
\ No newline at end of file
diff --git a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/focus/FocusNodeUtils.kt b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/focus/FocusNodeUtils.kt
index 2893056..144484f 100644
--- a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/focus/FocusNodeUtils.kt
+++ b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/focus/FocusNodeUtils.kt
@@ -30,4 +30,14 @@
this.outerLayoutNodeWrapper.findNextFocusWrapper()?.let { focusableChildren.add(it) }
?: children.fastForEach { layout -> focusableChildren.addAll(layout.focusableChildren()) }
return focusableChildren
+}
+
+@OptIn(ExperimentalLayoutNodeApi::class)
+internal fun LayoutNode.focusableChildren2(): List<ModifiedFocusNode2> {
+ val focusableChildren = mutableListOf<ModifiedFocusNode2>()
+ // TODO(b/152529395): Write a test for LayoutNode.focusableChildren(). We were calling the wrong
+ // function on [LayoutNodeWrapper] but no test caught this.
+ this.outerLayoutNodeWrapper.findNextFocusWrapper2()?.let { focusableChildren.add(it) }
+ ?: children.fastForEach { layout -> focusableChildren.addAll(layout.focusableChildren2()) }
+ return focusableChildren
}
\ No newline at end of file
diff --git a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/focus/ModifiedFocusNode2.kt b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/focus/ModifiedFocusNode2.kt
new file mode 100644
index 0000000..badabd0
--- /dev/null
+++ b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/focus/ModifiedFocusNode2.kt
@@ -0,0 +1,302 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * 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 androidx.ui.core.focus
+
+import androidx.ui.core.DelegatingLayoutNodeWrapper
+import androidx.ui.core.ExperimentalLayoutNodeApi
+import androidx.ui.core.LayoutNodeWrapper
+import androidx.ui.core.focus.FocusState2.Active
+import androidx.ui.core.focus.FocusState2.ActiveParent
+import androidx.ui.core.focus.FocusState2.Captured
+import androidx.ui.core.focus.FocusState2.Disabled
+import androidx.ui.core.focus.FocusState2.Inactive
+import androidx.ui.util.fastForEach
+
+@OptIn(
+ ExperimentalFocus::class,
+ ExperimentalLayoutNodeApi::class
+)
+internal class ModifiedFocusNode2(
+ wrapped: LayoutNodeWrapper,
+ modifier: FocusModifier2
+) : DelegatingLayoutNodeWrapper<FocusModifier2>(wrapped, modifier) {
+
+ init {
+ modifier.focusNode = this
+ }
+
+ /**
+ * Request focus for this node.
+ *
+ * @param propagateFocus Whether the focus should be propagated to the node's children.
+ *
+ * In Compose, the parent [FocusNode][ModifiedFocusNode2] controls focus for its focusable
+ * children. Calling this function will send a focus request to this
+ * [FocusNode][ModifiedFocusNode2]'s parent [FocusNode][ModifiedFocusNode2].
+ */
+ fun requestFocus(propagateFocus: Boolean = true) {
+ when (modifier.focusState) {
+ Active, Captured, Disabled -> return
+ ActiveParent -> {
+ val focusedChild = modifier.focusedChild
+ requireNotNull(focusedChild)
+
+ // We don't need to do anything if [propagateFocus] is true,
+ // since this subtree already has focus.
+ if (propagateFocus) return
+
+ if (focusedChild.clearFocus()) {
+ grantFocus(propagateFocus)
+ }
+ }
+ Inactive -> {
+ val focusParent = findParentFocusNode2()
+ if (focusParent == null) {
+ if (requestFocusForOwner()) {
+ grantFocus(propagateFocus)
+ }
+ } else {
+ focusParent.requestFocusForChild(this, propagateFocus)
+ }
+ }
+ }
+ }
+
+ /**
+ * Deny requests to clear focus.
+ *
+ * This is used when a component wants to hold onto focus (eg. A phone number field with an
+ * invalid number.
+ *
+ * @return true if the focus was successfully captured. False otherwise.
+ */
+ fun captureFocus() = when (modifier.focusState) {
+ Active -> {
+ modifier.focusState = Captured
+ true
+ }
+ Captured -> true
+ else -> false
+ }
+
+ /**
+ * When the node is in the [Captured] state, it rejects all requests to clear focus. Calling
+ * [freeFocus] puts the node in the [Active] state, where it is no longer preventing other
+ * nodes from requesting focus.
+ *
+ * @return true if the captured focus was released. False Otherwise.
+ */
+ fun freeFocus() = when (modifier.focusState) {
+ Captured -> {
+ modifier.focusState = Active
+ true
+ }
+ Active -> true
+ else -> false
+ }
+
+ /**
+ * This function grants focus to this node.
+ *
+ * @param propagateFocus Whether the focus should be propagated to the node's children.
+ *
+ * Note: This function is private, and should only be called by a parent [ModifiedFocusNode2] to
+ * grant focus to one of its child [ModifiedFocusNode2]s.
+ */
+ private fun grantFocus(propagateFocus: Boolean) {
+
+ // TODO (b/144126570) use ChildFocusablility.
+ // For now we assume children get focus before parent).
+
+ // TODO (b/144126759): Design a system to decide which child gets focus.
+ // for now we grant focus to the first child.
+ val focusedCandidate = focusableChildren().firstOrNull()
+
+ if (focusedCandidate == null || !propagateFocus) {
+ // No Focused Children, or we don't want to propagate focus to children.
+ modifier.focusState = Active
+ } else {
+ modifier.focusState = ActiveParent
+ modifier.focusedChild = focusedCandidate
+ focusedCandidate.grantFocus(propagateFocus)
+ }
+ }
+
+ /**
+ * This function clears focus from this node.
+ *
+ * Note: This function should only be called by a parent [focus node][ModifiedFocusNode2] to
+ * clear focus from one of its child [focus node][ModifiedFocusNode2]s. It does not change the
+ * state of the parent.
+ */
+ internal fun clearFocus(forcedClear: Boolean = false): Boolean {
+ return when (modifier.focusState) {
+ Active -> {
+ findParentFocusNode()?.modifier?.focusedChild = null
+ modifier.focusState = Inactive
+ true
+ }
+ /**
+ * If the node is [ActiveParent], we need to clear focus from the [Active] descendant
+ * first, before clearing focus of this node.
+ */
+ ActiveParent -> {
+ val focusedChild = modifier.focusedChild
+ requireNotNull(focusedChild)
+ val success = focusedChild.clearFocus(forcedClear)
+ if (success) {
+ findParentFocusNode()?.modifier?.focusedChild = null
+ modifier.focusState = Inactive
+ }
+ success
+ }
+ /**
+ * If the node is [Captured], deny requests to clear focus, except for a forced clear.
+ */
+ Captured -> {
+ if (forcedClear) {
+ modifier.focusState = Inactive
+ findParentFocusNode()?.modifier?.focusedChild = null
+ }
+ forcedClear
+ }
+ /**
+ * Nothing to do if the node is not focused.
+ */
+ Inactive, Disabled -> true
+ }
+ }
+
+ /**
+ * Focusable children of this [focus node][ModifiedFocusNode2] can use this function to request
+ * focus.
+ *
+ * @param childNode: The node that is requesting focus.
+ * @param propagateFocus Whether the focus should be propagated to the node's children.
+ * @return true if focus was granted, false otherwise.
+ */
+ private fun requestFocusForChild(
+ childNode: ModifiedFocusNode2,
+ propagateFocus: Boolean
+ ): Boolean {
+
+ // Only this node's children can ask for focus.
+ if (!focusableChildren().contains(childNode)) {
+ error("Non child node cannot request focus.")
+ }
+
+ return when (modifier.focusState) {
+ /**
+ * If this node is [Active], it can give focus to the requesting child.
+ */
+ Active -> {
+ modifier.focusState = ActiveParent
+ modifier.focusedChild = childNode
+ childNode.grantFocus(propagateFocus)
+ true
+ }
+ /**
+ * If this node is [ActiveParent] ie, one of the parent's descendants is [Active],
+ * remove focus from the currently focused child and grant it to the requesting child.
+ */
+ ActiveParent -> {
+ val previouslyFocusedNode = modifier.focusedChild
+ requireNotNull(previouslyFocusedNode)
+ if (previouslyFocusedNode.clearFocus()) {
+ modifier.focusedChild = childNode
+ childNode.grantFocus(propagateFocus)
+ true
+ } else {
+ // Currently focused component does not want to give up focus.
+ false
+ }
+ }
+ /**
+ * If this node is not [Active], we must gain focus first before granting it
+ * to the requesting child.
+ */
+ Inactive -> {
+ val focusParent = findParentFocusNode2()
+ if (focusParent == null) {
+ // If the owner successfully gains focus, proceed otherwise return false.
+ if (requestFocusForOwner()) {
+ modifier.focusState = Active
+ requestFocusForChild(childNode, propagateFocus)
+ } else {
+ false
+ }
+ } else if (focusParent.requestFocusForChild(this, propagateFocus = false)) {
+ requestFocusForChild(childNode, propagateFocus)
+ } else {
+ // Could not gain focus, so have no focus to give.
+ false
+ }
+ }
+ /**
+ * If this node is [Captured], decline requests from the children.
+ */
+ Captured -> false
+ /**
+ * Children of a [Disabled] parent should also be [Disabled].
+ */
+ Disabled -> error("non root FocusNode needs a focusable parent")
+ }
+ }
+
+ private fun requestFocusForOwner(): Boolean {
+ val owner = layoutNode.owner
+ requireNotNull(owner, { "Owner not initialized." })
+ return owner.requestFocus()
+ }
+
+ override fun detach() {
+ // TODO(b/160924457): Find the next focus node and propagate it's foucus state to all the
+ // focus observers observing this focus node.
+ super.detach()
+ }
+
+ override fun findPreviousFocusWrapper2() = this
+
+ override fun findNextFocusWrapper2() = this
+
+ // TODO(b/152051577): Measure the performance of focusableChildren.
+ // Consider caching the children.
+ internal fun focusableChildren(): List<ModifiedFocusNode2> {
+ // Check the modifier chain that this focus node is part of. If it has a focus modifier,
+ // that means you have found the only focusable child for this node.
+ val focusableChild = wrapped.findNextFocusWrapper2()
+ // findChildFocusNodeInWrapperChain()
+ if (focusableChild != null) {
+ return listOf(focusableChild)
+ }
+
+ // Go through all your children and find the first focusable node from each child.
+ val focusableChildren = mutableListOf<ModifiedFocusNode2>()
+ layoutNode.children.fastForEach { node ->
+ focusableChildren.addAll(node.focusableChildren2())
+ }
+ return focusableChildren
+ }
+
+ internal fun findActiveFocusNode(): ModifiedFocusNode2? {
+ return when (modifier.focusState) {
+ Active, Captured -> this
+ ActiveParent -> modifier.focusedChild?.findActiveFocusNode()
+ Inactive, Disabled -> null
+ }
+ }
+}
diff --git a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsConfiguration.kt b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsConfiguration.kt
index 97af431..a89739eb 100644
--- a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsConfiguration.kt
+++ b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsConfiguration.kt
@@ -96,23 +96,14 @@
*
* The [other] configuration must not contain any properties that cannot be
* merged into this configuration.
- *
- * @param ignoreAlreadySet if true, ignore properties that are already set instead of merging
*/
- internal fun absorb(other: SemanticsConfiguration, ignoreAlreadySet: Boolean = false) {
+ internal fun absorb(other: SemanticsConfiguration) {
if (other.isMergingSemanticsOfDescendants) {
isMergingSemanticsOfDescendants = true
}
-
for (entry in other.props) {
val key = entry.key
- if (props.containsKey(key)) {
- if (!ignoreAlreadySet) {
- @Suppress("UNCHECKED_CAST")
- key as SemanticsPropertyKey<Any?>
- props[key] = key.merge(props[key], entry.value)
- }
- } else {
+ if (!props.containsKey(key)) {
props[key] = entry.value
}
}
@@ -142,7 +133,6 @@
return result
}
- private val CommaSeparator = ", "
override fun toString(): String {
val propsString = StringBuilder()
var nextSeparator = ""
@@ -150,7 +140,7 @@
if (isMergingSemanticsOfDescendants) {
propsString.append(nextSeparator)
propsString.append("mergeDescendants=true")
- nextSeparator = CommaSeparator
+ nextSeparator = ", "
}
for ((key, value) in props) {
@@ -158,7 +148,7 @@
propsString.append(key.name)
propsString.append(" : ")
propsString.append(value)
- nextSeparator = CommaSeparator
+ nextSeparator = ", "
}
return "${simpleIdentityToString(this@SemanticsConfiguration, null)}{ $propsString }"
}
diff --git a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsHintOverrides.kt b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsHintOverrides.kt
deleted file mode 100644
index a49173d..0000000
--- a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsHintOverrides.kt
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * 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 androidx.ui.core.semantics
-
-/**
- * Provides hint values which override the default hints on supported
- * platforms.
- *
- * On iOS, these values are always ignored.
- */
-// @immutable
-data class SemanticsHintOverrides(
- /**
- * The hint text for a tap action.
- *
- * If null, the standard hint is used instead.
- *
- * The hint should describe what happens when a tap occurs, not the
- * manner in which a tap is accomplished.
- *
- * Bad: 'Double tap to show movies'.
- * Good: 'show movies'.
- */
- val onTapHint: String?,
- /**
- * The hint text for a long press action.
- *
- * If null, the standard hint is used instead.
- *
- * The hint should describe what happens when a long press occurs, not
- * the manner in which the long press is accomplished.
- *
- * Bad: 'Double tap and hold to show tooltip'.
- * Good: 'show tooltip'.
- */
- val onLongPressHint: String?
-) {
-
- // TODO: b/150777826 - fix and re-enable assertion
- /*
- init {
- check(onTapHint != "")
- check(onLongPressHint != "")
- }
- */
-
- /** Whether there are any non-null hint values. */
- val isNotEmpty
- get() = onTapHint != null || onLongPressHint != null
-}
\ No newline at end of file
diff --git a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsModifier.kt b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsModifier.kt
index 00e458f..07a0cb5 100644
--- a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsModifier.kt
+++ b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsModifier.kt
@@ -17,6 +17,7 @@
package androidx.ui.core.semantics
import androidx.compose.remember
+import androidx.ui.core.AtomicInt
import androidx.ui.core.Modifier
import androidx.ui.core.composed
import androidx.ui.semantics.SemanticsPropertyReceiver
@@ -27,7 +28,9 @@
*/
interface SemanticsModifier : Modifier.Element {
/**
- * The unique id of this semantics. Should be generated from SemanticsNode.generateNewId().
+ * The unique id of this semantics.
+ *
+ * Should be generated from SemanticsModifierCore.generateSemanticsId().
*/
val id: Int
@@ -41,14 +44,18 @@
internal class SemanticsModifierCore(
override val id: Int,
mergeAllDescendants: Boolean,
- properties: (SemanticsPropertyReceiver.() -> Unit)?
+ properties: (SemanticsPropertyReceiver.() -> Unit)
) : SemanticsModifier {
override val semanticsConfiguration: SemanticsConfiguration =
SemanticsConfiguration().also {
it.isMergingSemanticsOfDescendants = mergeAllDescendants
- properties?.invoke(it)
+ it.properties()
}
+ companion object {
+ private var lastIdentifier = AtomicInt(0)
+ fun generateSemanticsId() = lastIdentifier.addAndGet(1)
+ }
}
/**
@@ -61,8 +68,8 @@
*/
fun Modifier.semantics(
mergeAllDescendants: Boolean = false,
- properties: (SemanticsPropertyReceiver.() -> Unit)? = null
+ properties: (SemanticsPropertyReceiver.() -> Unit)
): Modifier = composed {
- val id = remember { SemanticsNode.generateNewId() }
+ val id = remember { SemanticsModifierCore.generateSemanticsId() }
SemanticsModifierCore(id, mergeAllDescendants, properties)
}
diff --git a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsNode.kt b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsNode.kt
index 68a359a..3bed72e 100644
--- a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsNode.kt
+++ b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsNode.kt
@@ -24,8 +24,6 @@
import androidx.ui.core.findClosestParentNode
import androidx.ui.core.globalBounds
import androidx.ui.core.globalPosition
-import androidx.ui.semantics.AccessibilityAction
-import androidx.ui.semantics.SemanticsPropertyKey
import androidx.ui.unit.IntSize
import androidx.ui.unit.PxBounds
import androidx.ui.geometry.Offset
@@ -41,17 +39,19 @@
internal typealias SemanticsNodeVisitor = (node: SemanticsNode) -> Boolean
/**
- * A node that represents some semantic data.
+ * A list of key/value pairs associated with a layout node or its subtree.
+ *
+ * Each SemanticsNode takes its id and initial key/value list from the
+ * outermost modifier on one layout node. It also contains the "collapsed" configuration
+ * of any other semantics modifiers on the same layout node, and if "mergeDescendants" is
+ * specified and enabled, also the "merged" configuration of its subtree.
*/
@OptIn(ExperimentalLayoutNodeApi::class)
class SemanticsNode internal constructor(
- /**
- * The unique identifier for this node.
- *
- * The first root node has an id of 1. Other nodes are given a unique id when
- * they are created.
+ /*
+ * This is expected to be the outermost semantics modifier on a layout node.
*/
- val id: Int,
+ internal val layoutNodeWrapper: SemanticsWrapper,
/**
* mergingEnabled specifies whether mergeAllDescendants config has any effect.
*
@@ -62,40 +62,12 @@
*
* mergingEnabled is typically true or false consistently on every node of a SemanticsNode tree.
*/
- val mergingEnabled: Boolean,
- val unmergedConfig: SemanticsConfiguration,
- var componentNode: LayoutNode
+ val mergingEnabled: Boolean
) {
- companion object {
- // TODO(b/145955412) maybe randomize? don't want this to be a contract
- // TODO: Might need to be atomic for multi-threaded composition
- private var lastIdentifier: Int = 0
-
- fun generateNewId(): Int {
- lastIdentifier += 1
- return lastIdentifier
- }
-
- /**
- * In tests use this function to reset the counter used to generate
- * [SemanticsNode.id].
- */
- internal fun debugResetSemanticsIdCounter() {
- lastIdentifier = 0
- }
- }
-
- /**
- * Creates a semantic node.
- *
- * Each semantic node has a unique identifier that is assigned when the node
- * is created.
- */
- internal constructor(
- mergingEnabled: Boolean,
- unmergedConfig: SemanticsConfiguration,
- layoutNode: LayoutNode
- ) : this(generateNewId(), mergingEnabled, unmergedConfig, layoutNode)
+ internal val unmergedConfig = layoutNodeWrapper.collapsedSemanticsConfiguration()
+ val id: Int = layoutNodeWrapper.semanticsModifier.id
+ // TODO(aelias): Make this internal and expose the Owner instead
+ val componentNode: LayoutNode = layoutNodeWrapper.layoutNode
// GEOMETRY
@@ -152,7 +124,7 @@
private fun buildMergedConfig(
mergedConfig: SemanticsConfiguration
): SemanticsConfiguration {
- mergedConfig.absorb(unmergedConfig, ignoreAlreadySet = true)
+ mergedConfig.absorb(unmergedConfig)
unmergedChildren().fastForEach { child ->
if (child.isMergingSemanticsOfDescendants == false) {
@@ -253,11 +225,6 @@
return SemanticsNode(outerSemantics, mergingEnabled)
}
- internal fun <T : Function<Boolean>> canPerformAction(
- action: SemanticsPropertyKey<AccessibilityAction<T>>
- ) =
- this.config.contains(action)
-
private fun findOneLayerOfMergingSemanticsNodes(
list: MutableList<SemanticsNode> = mutableListOf<SemanticsNode>()
): List<SemanticsNode> {
@@ -272,26 +239,13 @@
}
}
-@OptIn(ExperimentalLayoutNodeApi::class)
-internal fun SemanticsNode(
- outerSemantics: SemanticsWrapper,
- mergingEnabled: Boolean
-): SemanticsNode {
- with (outerSemantics) {
- return SemanticsNode(modifier.id,
- mergingEnabled,
- collapsedSemanticsConfiguration(),
- layoutNode)
- }
-}
-
/**
* Returns the outermost semantics node on a LayoutNode.
*/
@OptIn(ExperimentalLayoutNodeApi::class)
internal val LayoutNode.outerSemantics: SemanticsWrapper?
get() {
- return (this as? LayoutNode)?.outerLayoutNodeWrapper?.nearestSemantics
+ return outerLayoutNodeWrapper.nearestSemantics
}
/**
diff --git a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsOwner.kt b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsOwner.kt
index ed64320..80178c3 100644
--- a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsOwner.kt
+++ b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsOwner.kt
@@ -18,12 +18,8 @@
import androidx.ui.core.ExperimentalLayoutNodeApi
import androidx.ui.core.LayoutNode
-import androidx.ui.semantics.AccessibilityAction
-import androidx.ui.semantics.SemanticsPropertyKey
import androidx.ui.util.fastForEach
-// TODO(b/142821673): Clean up and integrate this (probably with AndroidComposeView)
-
/**
* Owns [SemanticsNode] objects and notifies listeners of changes to the
* semantics tree
@@ -43,26 +39,6 @@
get() {
return SemanticsNode(rootNode.outerSemantics!!, mergingEnabled = false)
}
-
- private fun <T : Function<Boolean>> getSemanticsActionHandlerForId(
- id: Int,
- action: SemanticsPropertyKey<AccessibilityAction<T>>
- ): AccessibilityAction<*>? {
- var result: SemanticsNode? = rootSemanticsNode.findChildById(id)
- if (result != null && !result.canPerformAction(action)) {
- result.visitDescendants { node: SemanticsNode ->
- if (node.canPerformAction(action)) {
- result = node
- return@visitDescendants false // found node, abort walk
- }
- return@visitDescendants true // continue walk
- }
- }
- if (result?.canPerformAction(action) != true) {
- return null
- }
- return result!!.unmergedConfig.getOrNull(action)
- }
}
/**
diff --git a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsWrapper.kt b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsWrapper.kt
index 5b6a304..8dc5f75 100644
--- a/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsWrapper.kt
+++ b/ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsWrapper.kt
@@ -27,11 +27,11 @@
) : DelegatingLayoutNodeWrapper<SemanticsModifier>(wrapped, semanticsModifier) {
fun collapsedSemanticsConfiguration(): SemanticsConfiguration {
var config = SemanticsConfiguration()
- config.absorb(modifier.semanticsConfiguration, ignoreAlreadySet = true)
+ config.absorb(modifier.semanticsConfiguration)
val innerConfig = wrapped.nearestSemantics?.collapsedSemanticsConfiguration()
if (innerConfig != null) {
- config.absorb(innerConfig, ignoreAlreadySet = true)
+ config.absorb(innerConfig)
}
return config
}
@@ -46,6 +46,6 @@
}
override fun toString(): String {
- return "${super.toString()} localConfig: ${modifier.semanticsConfiguration}"
+ return "${super.toString()} id: ${modifier.id} config: ${modifier.semanticsConfiguration}"
}
}
diff --git a/ui/ui-core/src/commonMain/kotlin/androidx/ui/semantics/SemanticsProperties.kt b/ui/ui-core/src/commonMain/kotlin/androidx/ui/semantics/SemanticsProperties.kt
index f79ae99..8307e97 100644
--- a/ui/ui-core/src/commonMain/kotlin/androidx/ui/semantics/SemanticsProperties.kt
+++ b/ui/ui-core/src/commonMain/kotlin/androidx/ui/semantics/SemanticsProperties.kt
@@ -17,8 +17,6 @@
package androidx.ui.semantics
import androidx.ui.text.AnnotatedString
-import androidx.ui.text.annotatedString
-import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
/**
@@ -31,13 +29,7 @@
*
* @see SemanticsPropertyReceiver.accessibilityLabel
*/
- val AccessibilityLabel = object : SemanticsPropertyKey<String>("AccessibilityLabel") {
- override fun merge(existingValue: String, newValue: String): String {
- // TODO(b/138173613): Needs TextDirection, probably needs to pass both nodes
- // to retrieve it
- return existingValue + "\n" + newValue
- }
- }
+ val AccessibilityLabel = SemanticsPropertyKey<String>("AccessibilityLabel")
/**
* Developer-set state description of the semantics node. For example: on/off. If this not
@@ -58,18 +50,18 @@
SemanticsPropertyKey<AccessibilityRangeInfo>("AccessibilityRangeInfo")
/**
- * Whether this semantics node is enabled.
+ * Whether this semantics node is disabled.
*
- * @see SemanticsPropertyReceiver.enabled
+ * @see SemanticsPropertyReceiver.disabled
*/
- val Enabled = SemanticsPropertyKey<Boolean>("Enabled")
+ val Disabled = SemanticsPropertyKey<Unit>("Disabled")
/**
* Whether this semantics node is hidden.
*
* @see SemanticsPropertyReceiver.hidden
*/
- val Hidden = SemanticsPropertyKey<Boolean>("Hidden")
+ val Hidden = SemanticsPropertyKey<Unit>("Hidden")
/**
* Whether this semantics node represents a Popup. Not to be confused with if this node is
@@ -77,7 +69,7 @@
*
* @see SemanticsPropertyReceiver.popup
*/
- val IsPopup = SemanticsPropertyKey<Boolean>("IsPopup")
+ val IsPopup = SemanticsPropertyKey<Unit>("IsPopup")
// TODO(b/138172781): Move to FoundationSemanticsProperties
/**
@@ -93,23 +85,7 @@
*
* @see SemanticsPropertyReceiver.text
*/
- val Text = object : SemanticsPropertyKey<AnnotatedString>("Text") {
- override fun merge(
- existingValue: AnnotatedString,
- newValue: AnnotatedString
- ): AnnotatedString {
- // TODO(b/138173613): Needs TextDirection, probably needs to pass both nodes
- // to retrieve it
- return annotatedString {
- append(existingValue)
- append("\n")
- append(newValue)
- }
- }
- }
-
- // TODO(b/151228491): TextDirection needs to be in core for platform use
- // val TextDirection = SemanticsPropertyKey<TextDirection>("TextDirection")
+ val Text = SemanticsPropertyKey<AnnotatedString>("Text")
}
/**
@@ -127,10 +103,10 @@
/**
* Action to scroll to a specified position.
*
- * @see SemanticsPropertyReceiver.ScrollTo
+ * @see SemanticsPropertyReceiver.ScrollBy
*/
- val ScrollTo =
- SemanticsPropertyKey<AccessibilityAction<(x: Float, y: Float) -> Boolean>>("ScrollTo")
+ val ScrollBy =
+ SemanticsPropertyKey<AccessibilityAction<(x: Float, y: Float) -> Boolean>>("ScrollBy")
/**
* Action to scroll the content forward.
@@ -169,46 +145,25 @@
SemanticsPropertyKey<List<CustomAccessibilityAction>>("CustomActions")
}
-open class SemanticsPropertyKey<T>(
+class SemanticsPropertyKey<T>(
/**
* The name of the property. Should be the same as the constant from which it is accessed.
*/
val name: String
-) :
- ReadWriteProperty<SemanticsPropertyReceiver, T> {
- /**
- * Subclasses that wish to implement merging should override this to output the merged value
- *
- * This implementation always throws IllegalStateException. It should be overridden for
- * properties that can be merged.
- */
- open fun merge(existingValue: T, newValue: T): T {
- throw IllegalStateException(
- "merge function called on unmergeable property $name. " +
- "Existing value: $existingValue, new value: $newValue. " +
- "You may need to add a semantic boundary."
- )
- }
-
+) {
/**
* Throws [UnsupportedOperationException]. Should not be called.
*/
- // noinspection DeprecatedCallableAddReplaceWith
- // TODO(KT-32770): Re-deprecate this
- // @Deprecated(
- // message = "You cannot retrieve a semantics property directly - " +
- // "use one of the SemanticsConfiguration.getOr* methods instead",
- // level = DeprecationLevel.ERROR
- // )
- // TODO(KT-6519): Remove this getter entirely
- final override fun getValue(thisRef: SemanticsPropertyReceiver, property: KProperty<*>): T {
+ // TODO(KT-6519): Remove this getter
+ // TODO(KT-32770): Cannot deprecate this either as the getter is considered called by "by"
+ final operator fun getValue(thisRef: SemanticsPropertyReceiver, property: KProperty<*>): T {
throw UnsupportedOperationException(
"You cannot retrieve a semantics property directly - " +
"use one of the SemanticsConfiguration.getOr* methods instead"
)
}
- final override fun setValue(
+ final operator fun setValue(
thisRef: SemanticsPropertyReceiver,
property: KProperty<*>,
value: T
@@ -230,15 +185,7 @@
* forward action should return false if the widget is not enabled or has reached the end of the
* list.
*/
-data class AccessibilityAction<T : Function<Boolean>>(val label: CharSequence?, val action: T) {
- // TODO(b/145951226): Workaround for a bytecode issue, remove this
- override fun hashCode(): Int {
- var result = label?.hashCode() ?: 0
- // (action as Any) is the workaround
- result = 31 * result + (action as Any).hashCode()
- return result
- }
-}
+data class AccessibilityAction<T : Function<Boolean>>(val label: CharSequence?, val action: T)
/**
* Data class for custom accessibility action.
@@ -247,15 +194,7 @@
* @param action The function to invoke when this action is performed. The function should have no
* arguments and return a boolean result indicating whether the action is successfully handled.
*/
-data class CustomAccessibilityAction(val label: CharSequence, val action: () -> Boolean) {
- // TODO(b/145951226): Workaround for a bytecode issue, remove this
- override fun hashCode(): Int {
- var result = label.hashCode()
- // (action as Any) is the workaround
- result = 31 * result + (action as Any).hashCode()
- return result
- }
-}
+data class CustomAccessibilityAction(val label: CharSequence, val action: () -> Boolean)
data class AccessibilityRangeInfo(
val current: Float,
@@ -292,18 +231,22 @@
var SemanticsPropertyReceiver.accessibilityValueRange by SemanticsProperties.AccessibilityRangeInfo
/**
- * Whether this semantics node is enabled.
+ * Whether this semantics node is disabled.
*
- * @see SemanticsProperties.Enabled
+ * @see SemanticsProperties.Disabled
*/
-var SemanticsPropertyReceiver.enabled by SemanticsProperties.Enabled
+fun SemanticsPropertyReceiver.disabled() {
+ this[SemanticsProperties.Disabled] = Unit
+}
/**
* Whether this semantics node is hidden.
*
* @See SemanticsProperties.Hidden
*/
-var SemanticsPropertyReceiver.hidden by SemanticsProperties.Hidden
+fun SemanticsPropertyReceiver.hidden() {
+ this[SemanticsProperties.Hidden] = Unit
+}
/**
* Whether this semantics node represents a Popup. Not to be confused with if this node is
@@ -311,7 +254,9 @@
*
* @See SemanticsProperties.IsPopup
*/
-var SemanticsPropertyReceiver.popup by SemanticsProperties.IsPopup
+fun SemanticsPropertyReceiver.popup() {
+ this[SemanticsProperties.IsPopup] = Unit
+}
// TODO(b/138172781): Move to FoundationSemanticsProperties.kt
/**
@@ -328,8 +273,6 @@
*/
var SemanticsPropertyReceiver.text by SemanticsProperties.Text
-// var SemanticsPropertyReceiver.textDirection by SemanticsProperties.TextDirection
-
/**
* Custom actions which are defined by app developers.
*
@@ -338,45 +281,6 @@
var SemanticsPropertyReceiver.customActions by SemanticsActions.CustomActions
/**
- * Action to be performed when the node is clicked.
- *
- * @see SemanticsActions.OnClick
- */
-var SemanticsPropertyReceiver.onClick by SemanticsActions.OnClick
-
-/**
- * Action to scroll to a specified position.
- *
- * @see SemanticsActions.ScrollTo
- */
-var SemanticsPropertyReceiver.ScrollTo by SemanticsActions.ScrollTo
-
-/**
- * Action to scroll the content forward.
- *
- * @see SemanticsActions.ScrollForward
- */
-@Deprecated("Use scroll up/down/left/right instead")
-@Suppress("DEPRECATION")
-var SemanticsPropertyReceiver.scrollForward by SemanticsActions.ScrollForward
-
-/**
- * Action to scroll the content backward.
- *
- * @see SemanticsActions.ScrollBackward
- */
-@Deprecated("Use scroll up/down/left/right instead")
-@Suppress("DEPRECATION")
-var SemanticsPropertyReceiver.scrollBackward by SemanticsActions.ScrollBackward
-
-/**
- * Action to set slider progress.
- *
- * @see SemanticsActions.SetProgress
- */
-var SemanticsPropertyReceiver.setProgress by SemanticsActions.SetProgress
-
-/**
* This function adds the [SemanticsActions.OnClick] to the [SemanticsPropertyReceiver].
*
* @param label Optional label for this action.
@@ -387,16 +291,16 @@
}
/**
- * This function adds the [SemanticsActions.ScrollTo] to the [SemanticsPropertyReceiver].
+ * This function adds the [SemanticsActions.ScrollBy] to the [SemanticsPropertyReceiver].
*
* @param label Optional label for this action.
- * @param action Action to be performed when the [SemanticsActions.ScrollTo] is called.
+ * @param action Action to be performed when the [SemanticsActions.ScrollBy] is called.
*/
-fun SemanticsPropertyReceiver.ScrollTo(
+fun SemanticsPropertyReceiver.scrollBy(
label: String? = null,
action: (x: Float, y: Float) -> Boolean
) {
- this[SemanticsActions.ScrollTo] = AccessibilityAction(label, action)
+ this[SemanticsActions.ScrollBy] = AccessibilityAction(label, action)
}
/**
@@ -437,52 +341,3 @@
) {
this[SemanticsActions.SetProgress] = AccessibilityAction(label, action)
}
-
-// TODO(b/138173613): Use this for merging labels
-/*
-
- /**
- * U+202A LEFT-TO-RIGHT EMBEDDING
- *
- * Treat the following text as embedded left-to-right.
- *
- * Use [PDF] to end the embedding.
- */
- private const val LRE = "\u202A"
-
- /**
- * U+202B RIGHT-TO-LEFT EMBEDDING
- *
- * Treat the following text as embedded right-to-left.
- *
- * Use [PDF] to end the embedding.
- */
- private const val RLE = "\u202B"
-
- /**
- * U+202C POP DIRECTIONAL FORMATTING
- *
- * End the scope of the last [LRE], [RLE], [RLO], or [LRO].
- */
- private const val PDF = "\u202C"
-
-private fun concatStrings(
- thisString: String?,
- otherString: String?,
- thisTextDirection: TextDirection?,
- otherTextDirection: TextDirection?
-): String? {
- if (otherString.isNullOrEmpty())
- return thisString
- var nestedLabel = otherString
- if (thisTextDirection != otherTextDirection && otherTextDirection != null) {
- nestedLabel = when (otherTextDirection) {
- TextDirection.Rtl -> "${RLE}$nestedLabel${PDF}"
- TextDirection.Ltr -> "${LRE}$nestedLabel${PDF}"
- }
- }
- if (thisString.isNullOrEmpty())
- return nestedLabel
- return "$thisString\n$nestedLabel"
-}
-*/
diff --git a/ui/ui-desktop/README.md b/ui/ui-desktop/README.md
index f829147..b4157da 100644
--- a/ui/ui-desktop/README.md
+++ b/ui/ui-desktop/README.md
@@ -2,4 +2,4 @@
To try:
- ./gradlew :ui:ui-desktop:samples:run
+ ./gradlew :compose:desktop:desktop:samples:run
diff --git a/ui/ui-desktop/build.gradle b/ui/ui-desktop/build.gradle
index c086fc8..9e03d56 100644
--- a/ui/ui-desktop/build.gradle
+++ b/ui/ui-desktop/build.gradle
@@ -89,7 +89,7 @@
kotlinPlugin project(path: ":compose:compose-compiler")
}
-def composeClassDir = "${project.rootProject.buildDir}/ui-desktop/compose-libs/"
+def composeClassDir = "${project.rootProject.buildDir}/desktop/compose-libs/"
kotlin {
jvm()
@@ -111,7 +111,7 @@
api "org.jetbrains.skija:skija:0.4.1"
- api project(":ui:ui-desktop:android-emu")
+ api project(":compose:desktop:desktop:android-emu")
api fileTree(composeClassDir)
@@ -138,7 +138,7 @@
}
def uiComponents = [
- ":ui:ui-android-view",
+ ":compose:android-view:android-view",
":compose:animation:animation",
":compose:animation:animation-core",
":compose:core:core",
@@ -340,7 +340,7 @@
}
}
project.tasks.register("jar", Jar).configure {
- baseName = "ui-desktop"
+ baseName = "desktop"
from { kotlin.jvm().compilations["main"].output.allOutputs }
}
@@ -349,5 +349,5 @@
}
rootProject.tasks.getByName("buildOnServer").configure {
- dependsOn(":ui:ui-desktop:jar")
+ dependsOn(":compose:desktop:desktop:jar")
}
diff --git a/ui/ui-desktop/samples/build.gradle b/ui/ui-desktop/samples/build.gradle
index 5ceffaa..4ae7390 100644
--- a/ui/ui-desktop/samples/build.gradle
+++ b/ui/ui-desktop/samples/build.gradle
@@ -26,7 +26,7 @@
kotlinPlugin project(path: ":compose:compose-compiler")
}
-def sdkDir = "${project.rootProject.buildDir}/ui-desktop/compose-libs/"
+def sdkDir = "${project.rootProject.buildDir}/desktop/compose-libs/"
kotlin {
jvm()
@@ -37,7 +37,7 @@
}
jvmMain.dependencies {
- implementation project(":ui:ui-desktop")
+ implementation project(":compose:desktop:desktop")
implementation fileTree(sdkDir)
}
}
@@ -50,7 +50,7 @@
}
task run1(type: JavaExec) {
- dependsOn(":ui:ui-desktop:jar")
+ dependsOn(":compose:desktop:desktop:jar")
main = 'androidx.ui.desktop.examples.example1.MainKt'
def compilation = kotlin.jvm().compilations["main"]
classpath =
@@ -60,7 +60,7 @@
}
task run2(type: JavaExec) {
- dependsOn(":ui:ui-desktop:jar")
+ dependsOn(":compose:desktop:desktop:jar")
main = 'androidx.ui.desktop.examples.example2.MainKt'
def compilation = kotlin.jvm().compilations["main"]
classpath =
@@ -70,7 +70,7 @@
}
task run3(type: JavaExec) {
- dependsOn(":ui:ui-desktop:jar")
+ dependsOn(":compose:desktop:desktop:jar")
main = 'androidx.ui.desktop.examples.popupexample.MainKt'
def compilation = kotlin.jvm().compilations["main"]
classpath =
diff --git a/ui/ui-foundation/api/0.1.0-dev15.txt b/ui/ui-foundation/api/0.1.0-dev15.txt
index 8814c9a..ec9a8bd 100644
--- a/ui/ui-foundation/api/0.1.0-dev15.txt
+++ b/ui/ui-foundation/api/0.1.0-dev15.txt
@@ -359,22 +359,21 @@
public final class FoundationSemanticsProperties {
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getInMutuallyExclusiveGroup();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getIsDialog();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getIsDialog();
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getSelected();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.foundation.selection.ToggleableState> getToggleableState();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> InMutuallyExclusiveGroup;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> IsDialog;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> IsDialog;
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> Selected;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.foundation.selection.ToggleableState> ToggleableState;
field public static final androidx.ui.foundation.semantics.FoundationSemanticsProperties INSTANCE;
}
public final class FoundationSemanticsPropertiesKt {
- method public static boolean getDialog(androidx.ui.semantics.SemanticsPropertyReceiver);
+ method public static void dialog(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static boolean getInMutuallyExclusiveGroup(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static boolean getSelected(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.foundation.selection.ToggleableState getToggleableState(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static void setDialog(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setInMutuallyExclusiveGroup(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setSelected(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setToggleableState(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.foundation.selection.ToggleableState p);
diff --git a/ui/ui-foundation/api/current.txt b/ui/ui-foundation/api/current.txt
index 8814c9a..ec9a8bd 100644
--- a/ui/ui-foundation/api/current.txt
+++ b/ui/ui-foundation/api/current.txt
@@ -359,22 +359,21 @@
public final class FoundationSemanticsProperties {
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getInMutuallyExclusiveGroup();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getIsDialog();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getIsDialog();
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getSelected();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.foundation.selection.ToggleableState> getToggleableState();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> InMutuallyExclusiveGroup;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> IsDialog;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> IsDialog;
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> Selected;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.foundation.selection.ToggleableState> ToggleableState;
field public static final androidx.ui.foundation.semantics.FoundationSemanticsProperties INSTANCE;
}
public final class FoundationSemanticsPropertiesKt {
- method public static boolean getDialog(androidx.ui.semantics.SemanticsPropertyReceiver);
+ method public static void dialog(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static boolean getInMutuallyExclusiveGroup(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static boolean getSelected(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.foundation.selection.ToggleableState getToggleableState(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static void setDialog(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setInMutuallyExclusiveGroup(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setSelected(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setToggleableState(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.foundation.selection.ToggleableState p);
diff --git a/ui/ui-foundation/api/public_plus_experimental_0.1.0-dev15.txt b/ui/ui-foundation/api/public_plus_experimental_0.1.0-dev15.txt
index 8814c9a..ec9a8bd 100644
--- a/ui/ui-foundation/api/public_plus_experimental_0.1.0-dev15.txt
+++ b/ui/ui-foundation/api/public_plus_experimental_0.1.0-dev15.txt
@@ -359,22 +359,21 @@
public final class FoundationSemanticsProperties {
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getInMutuallyExclusiveGroup();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getIsDialog();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getIsDialog();
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getSelected();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.foundation.selection.ToggleableState> getToggleableState();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> InMutuallyExclusiveGroup;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> IsDialog;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> IsDialog;
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> Selected;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.foundation.selection.ToggleableState> ToggleableState;
field public static final androidx.ui.foundation.semantics.FoundationSemanticsProperties INSTANCE;
}
public final class FoundationSemanticsPropertiesKt {
- method public static boolean getDialog(androidx.ui.semantics.SemanticsPropertyReceiver);
+ method public static void dialog(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static boolean getInMutuallyExclusiveGroup(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static boolean getSelected(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.foundation.selection.ToggleableState getToggleableState(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static void setDialog(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setInMutuallyExclusiveGroup(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setSelected(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setToggleableState(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.foundation.selection.ToggleableState p);
diff --git a/ui/ui-foundation/api/public_plus_experimental_current.txt b/ui/ui-foundation/api/public_plus_experimental_current.txt
index 8814c9a..ec9a8bd 100644
--- a/ui/ui-foundation/api/public_plus_experimental_current.txt
+++ b/ui/ui-foundation/api/public_plus_experimental_current.txt
@@ -359,22 +359,21 @@
public final class FoundationSemanticsProperties {
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getInMutuallyExclusiveGroup();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getIsDialog();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getIsDialog();
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getSelected();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.foundation.selection.ToggleableState> getToggleableState();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> InMutuallyExclusiveGroup;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> IsDialog;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> IsDialog;
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> Selected;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.foundation.selection.ToggleableState> ToggleableState;
field public static final androidx.ui.foundation.semantics.FoundationSemanticsProperties INSTANCE;
}
public final class FoundationSemanticsPropertiesKt {
- method public static boolean getDialog(androidx.ui.semantics.SemanticsPropertyReceiver);
+ method public static void dialog(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static boolean getInMutuallyExclusiveGroup(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static boolean getSelected(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.foundation.selection.ToggleableState getToggleableState(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static void setDialog(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setInMutuallyExclusiveGroup(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setSelected(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setToggleableState(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.foundation.selection.ToggleableState p);
diff --git a/ui/ui-foundation/api/restricted_0.1.0-dev15.txt b/ui/ui-foundation/api/restricted_0.1.0-dev15.txt
index 8814c9a..ec9a8bd 100644
--- a/ui/ui-foundation/api/restricted_0.1.0-dev15.txt
+++ b/ui/ui-foundation/api/restricted_0.1.0-dev15.txt
@@ -359,22 +359,21 @@
public final class FoundationSemanticsProperties {
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getInMutuallyExclusiveGroup();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getIsDialog();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getIsDialog();
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getSelected();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.foundation.selection.ToggleableState> getToggleableState();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> InMutuallyExclusiveGroup;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> IsDialog;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> IsDialog;
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> Selected;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.foundation.selection.ToggleableState> ToggleableState;
field public static final androidx.ui.foundation.semantics.FoundationSemanticsProperties INSTANCE;
}
public final class FoundationSemanticsPropertiesKt {
- method public static boolean getDialog(androidx.ui.semantics.SemanticsPropertyReceiver);
+ method public static void dialog(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static boolean getInMutuallyExclusiveGroup(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static boolean getSelected(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.foundation.selection.ToggleableState getToggleableState(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static void setDialog(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setInMutuallyExclusiveGroup(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setSelected(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setToggleableState(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.foundation.selection.ToggleableState p);
diff --git a/ui/ui-foundation/api/restricted_current.txt b/ui/ui-foundation/api/restricted_current.txt
index 8814c9a..ec9a8bd 100644
--- a/ui/ui-foundation/api/restricted_current.txt
+++ b/ui/ui-foundation/api/restricted_current.txt
@@ -359,22 +359,21 @@
public final class FoundationSemanticsProperties {
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getInMutuallyExclusiveGroup();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getIsDialog();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getIsDialog();
method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getSelected();
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.foundation.selection.ToggleableState> getToggleableState();
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> InMutuallyExclusiveGroup;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> IsDialog;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> IsDialog;
property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> Selected;
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.foundation.selection.ToggleableState> ToggleableState;
field public static final androidx.ui.foundation.semantics.FoundationSemanticsProperties INSTANCE;
}
public final class FoundationSemanticsPropertiesKt {
- method public static boolean getDialog(androidx.ui.semantics.SemanticsPropertyReceiver);
+ method public static void dialog(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static boolean getInMutuallyExclusiveGroup(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static boolean getSelected(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static androidx.ui.foundation.selection.ToggleableState getToggleableState(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static void setDialog(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setInMutuallyExclusiveGroup(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setSelected(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
method public static void setToggleableState(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.foundation.selection.ToggleableState p);
diff --git a/ui/ui-foundation/integration-tests/foundation-demos/build.gradle b/ui/ui-foundation/integration-tests/foundation-demos/build.gradle
index 4f54eb9..61379eb 100644
--- a/ui/ui-foundation/integration-tests/foundation-demos/build.gradle
+++ b/ui/ui-foundation/integration-tests/foundation-demos/build.gradle
@@ -34,7 +34,7 @@
implementation(KOTLIN_STDLIB)
implementation project(":compose:runtime:runtime")
- implementation project(":ui:integration-tests:demos:common")
+ implementation project(":compose:integration-tests:demos:common")
implementation project(":compose:core:core")
implementation project(":compose:foundation:foundation")
implementation project(":compose:animation:animation")
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/BorderTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/BorderTest.kt
index ced47c0..8c84233 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/BorderTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/BorderTest.kt
@@ -34,7 +34,7 @@
import androidx.ui.test.assertShape
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.unit.Density
import org.junit.Rule
import org.junit.Test
@@ -71,7 +71,7 @@
) {}
}
}
- val bitmap = findByTag(testTag).captureToBitmap()
+ val bitmap = onNodeWithTag(testTag).captureToBitmap()
bitmap.assertShape(
density = composeTestRule.density,
backgroundColor = Color.Red,
@@ -98,7 +98,7 @@
) {}
}
}
- val bitmap = findByTag(testTag).captureToBitmap()
+ val bitmap = onNodeWithTag(testTag).captureToBitmap()
bitmap.assertShape(
density = composeTestRule.density,
backgroundColor = Color.Red,
@@ -122,7 +122,7 @@
) {}
}
}
- val bitmap = findByTag(testTag).captureToBitmap()
+ val bitmap = onNodeWithTag(testTag).captureToBitmap()
bitmap.assertShape(
density = composeTestRule.density,
backgroundColor = Color.White,
@@ -144,7 +144,7 @@
) {}
}
}
- val bitmap = findByTag(testTag).captureToBitmap()
+ val bitmap = onNodeWithTag(testTag).captureToBitmap()
bitmap.assertShape(
density = composeTestRule.density,
backgroundColor = Color.White,
@@ -170,7 +170,7 @@
}
}
}
- val bitmap = findByTag(testTag).captureToBitmap()
+ val bitmap = onNodeWithTag(testTag).captureToBitmap()
bitmap.assertShape(
density = composeTestRule.density,
backgroundColor = Color.White,
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/BoxTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/BoxTest.kt
index 5932bdb..107359e 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/BoxTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/BoxTest.kt
@@ -39,7 +39,7 @@
import androidx.ui.test.assertShape
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.geometry.Offset
import androidx.ui.unit.Density
import androidx.ui.unit.IntSize
@@ -258,7 +258,7 @@
)
}
}
- val bitmap = findByTag(contentTag).captureToBitmap()
+ val bitmap = onNodeWithTag(contentTag).captureToBitmap()
bitmap.assertShape(composeTestRule.density, RectangleShape, Color.Red, Color.Red)
}
@@ -278,7 +278,7 @@
}
}
with(composeTestRule.density) {
- val bitmap = findByTag(contentTag).captureToBitmap()
+ val bitmap = onNodeWithTag(contentTag).captureToBitmap()
bitmap.assertShape(
density = composeTestRule.density,
shape = RectangleShape,
@@ -306,7 +306,7 @@
}
}
with(composeTestRule.density) {
- val bitmap = findByTag(contentTag).captureToBitmap()
+ val bitmap = onNodeWithTag(contentTag).captureToBitmap()
bitmap.assertShape(
density = composeTestRule.density,
shape = CircleShape,
@@ -333,7 +333,7 @@
}
}
with(composeTestRule.density) {
- val bitmap = findByTag(contentTag).captureToBitmap()
+ val bitmap = onNodeWithTag(contentTag).captureToBitmap()
bitmap.assertShape(
density = composeTestRule.density,
shape = RectangleShape,
@@ -366,7 +366,7 @@
}
}
with(composeTestRule.density) {
- val bitmap = findByTag(contentTag).captureToBitmap()
+ val bitmap = onNodeWithTag(contentTag).captureToBitmap()
bitmap.assertShape(
density = composeTestRule.density,
shape = CircleShape,
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/CanvasTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/CanvasTest.kt
index 670b858..2e8143b 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/CanvasTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/CanvasTest.kt
@@ -34,7 +34,7 @@
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findRoot
+import androidx.ui.test.onRoot
import androidx.ui.unit.dp
import org.junit.Assert
import org.junit.Rule
@@ -80,7 +80,7 @@
val paintBoxColor = Color.Red.toArgb()
val containerBgColor = Color.White.toArgb()
val strokeOffset = (strokeWidth / 2).toInt() + 3
- findRoot().captureToBitmap().apply {
+ onRoot().captureToBitmap().apply {
val imageStartX = width / 2 - boxWidth / 2
val imageStartY = height / 2 - boxHeight / 2
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ClickableTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ClickableTest.kt
index bbc906e..a0d18c7 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ClickableTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ClickableTest.kt
@@ -29,16 +29,16 @@
import androidx.ui.test.assertIsNotEnabled
import androidx.ui.test.center
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.doGesture
-import androidx.ui.test.doPartialGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendClick
-import androidx.ui.test.sendDoubleClick
-import androidx.ui.test.sendDown
-import androidx.ui.test.sendLongClick
-import androidx.ui.test.sendUp
+import androidx.ui.test.click
+import androidx.ui.test.doubleClick
+import androidx.ui.test.down
+import androidx.ui.test.longClick
+import androidx.ui.test.performPartialGesture
+import androidx.ui.test.up
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -62,7 +62,7 @@
}
}
- findByTag("myClickable")
+ onNodeWithTag("myClickable")
.assertIsEnabled()
.assertHasClickAction()
}
@@ -78,7 +78,7 @@
}
}
- findByTag("myClickable")
+ onNodeWithTag("myClickable")
.assertIsNotEnabled()
.assertHasNoClickAction()
}
@@ -97,15 +97,15 @@
}
}
- findByTag("myClickable")
- .doClick()
+ onNodeWithTag("myClickable")
+ .performClick()
runOnIdleCompose {
assertThat(counter).isEqualTo(1)
}
- findByTag("myClickable")
- .doClick()
+ onNodeWithTag("myClickable")
+ .performClick()
runOnIdleCompose {
assertThat(counter).isEqualTo(2)
@@ -126,18 +126,18 @@
}
}
- findByTag("myClickable")
- .doGesture {
- sendLongClick()
+ onNodeWithTag("myClickable")
+ .performGesture {
+ longClick()
}
runOnIdleCompose {
assertThat(counter).isEqualTo(1)
}
- findByTag("myClickable")
- .doGesture {
- sendLongClick()
+ onNodeWithTag("myClickable")
+ .performGesture {
+ longClick()
}
runOnIdleCompose {
@@ -166,9 +166,9 @@
}
}
- findByTag("myClickable")
- .doGesture {
- sendClick()
+ onNodeWithTag("myClickable")
+ .performGesture {
+ click()
}
runOnIdleCompose {
@@ -176,9 +176,9 @@
assertThat(longClickCounter).isEqualTo(0)
}
- findByTag("myClickable")
- .doGesture {
- sendLongClick()
+ onNodeWithTag("myClickable")
+ .performGesture {
+ longClick()
}
runOnIdleCompose {
@@ -208,8 +208,8 @@
}
}
- findByTag("myClickable")
- .doClick()
+ onNodeWithTag("myClickable")
+ .performClick()
val res = clickLatch.await(1000, TimeUnit.MILLISECONDS)
runOnIdleCompose {
@@ -217,9 +217,9 @@
assertThat(res).isTrue()
}
- findByTag("myClickable")
- .doGesture {
- sendDoubleClick()
+ onNodeWithTag("myClickable")
+ .performGesture {
+ doubleClick()
}
runOnIdleCompose {
@@ -252,8 +252,8 @@
}
}
- findByTag("myClickable")
- .doClick()
+ onNodeWithTag("myClickable")
+ .performClick()
val res = clickLatch.await(1000, TimeUnit.MILLISECONDS)
runOnIdleCompose {
@@ -262,9 +262,9 @@
assertThat(res).isTrue()
}
- findByTag("myClickable")
- .doGesture {
- sendDoubleClick()
+ onNodeWithTag("myClickable")
+ .performGesture {
+ doubleClick()
}
runOnIdleCompose {
@@ -273,9 +273,9 @@
assertThat(clickLatch.await(1000, TimeUnit.MILLISECONDS)).isTrue()
}
- findByTag("myClickable")
- .doGesture {
- sendLongClick()
+ onNodeWithTag("myClickable")
+ .performGesture {
+ longClick()
}
runOnIdleCompose {
@@ -299,18 +299,18 @@
}
}
- findByTag("myClickable")
- .doGesture {
- sendDoubleClick()
+ onNodeWithTag("myClickable")
+ .performGesture {
+ doubleClick()
}
runOnIdleCompose {
assertThat(counter).isEqualTo(1)
}
- findByTag("myClickable")
- .doGesture {
- sendDoubleClick()
+ onNodeWithTag("myClickable")
+ .performGesture {
+ doubleClick()
}
runOnIdleCompose {
@@ -337,15 +337,15 @@
assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
}
- findByTag("myClickable")
- .doPartialGesture { sendDown(center) }
+ onNodeWithTag("myClickable")
+ .performPartialGesture { down(center) }
runOnIdleCompose {
assertThat(interactionState.value).contains(Interaction.Pressed)
}
- findByTag("myClickable")
- .doPartialGesture { sendUp() }
+ onNodeWithTag("myClickable")
+ .performPartialGesture { up() }
runOnIdleCompose {
assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
@@ -374,8 +374,8 @@
assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
}
- findByTag("myClickable")
- .doPartialGesture { sendDown(center) }
+ onNodeWithTag("myClickable")
+ .performPartialGesture { down(center) }
runOnIdleCompose {
assertThat(interactionState.value).contains(Interaction.Pressed)
@@ -417,8 +417,8 @@
}
}
- findByTag("myClickable")
- .doClick()
+ onNodeWithTag("myClickable")
+ .performClick()
runOnIdleCompose {
assertThat(doubleClickCounter).isEqualTo(0)
@@ -426,9 +426,9 @@
assertThat(clickLatch.count).isEqualTo(1)
}
- findByTag("myClickable")
- .doGesture {
- sendDoubleClick()
+ onNodeWithTag("myClickable")
+ .performGesture {
+ doubleClick()
}
runOnIdleCompose {
@@ -437,9 +437,9 @@
assertThat(clickLatch.count).isEqualTo(1)
}
- findByTag("myClickable")
- .doGesture {
- sendLongClick()
+ onNodeWithTag("myClickable")
+ .performGesture {
+ longClick()
}
runOnIdleCompose {
@@ -449,8 +449,8 @@
enabled.value = true
}
- findByTag("myClickable")
- .doClick()
+ onNodeWithTag("myClickable")
+ .performClick()
val res = clickLatch.await(1000, TimeUnit.MILLISECONDS)
runOnIdleCompose {
@@ -459,9 +459,9 @@
assertThat(res).isTrue()
}
- findByTag("myClickable")
- .doGesture {
- sendDoubleClick()
+ onNodeWithTag("myClickable")
+ .performGesture {
+ doubleClick()
}
runOnIdleCompose {
@@ -470,9 +470,9 @@
assertThat(clickLatch.await(1000, TimeUnit.MILLISECONDS)).isTrue()
}
- findByTag("myClickable")
- .doGesture {
- sendLongClick()
+ onNodeWithTag("myClickable")
+ .performGesture {
+ longClick()
}
runOnIdleCompose {
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ClickableTextTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ClickableTextTest.kt
index aa721f3..3e44c68 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ClickableTextTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ClickableTextTest.kt
@@ -20,8 +20,8 @@
import androidx.ui.core.Modifier
import androidx.ui.core.testTag
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
import androidx.ui.text.AnnotatedString
import com.nhaarman.mockitokotlin2.any
@@ -50,7 +50,7 @@
)
}
- findByTag("clickableText").doClick()
+ onNodeWithTag("clickableText").performClick()
runOnIdleCompose {
verify(onClick, times(1)).invoke(any())
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DeterminateProgressTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DeterminateProgressTest.kt
index 7f67e6b..e052952 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DeterminateProgressTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DeterminateProgressTest.kt
@@ -26,7 +26,7 @@
import androidx.ui.test.assertRangeInfoEquals
import androidx.ui.test.assertValueEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnUiThread
import androidx.ui.unit.dp
import org.junit.Rule
@@ -55,7 +55,7 @@
.drawBackground(Color.Cyan))
}
- findByTag(tag)
+ onNodeWithTag(tag)
.assertValueEquals("0 percent")
.assertRangeInfoEquals(AccessibilityRangeInfo(0f, 0f..1f))
@@ -63,7 +63,7 @@
progress.value = 0.005f
}
- findByTag(tag)
+ onNodeWithTag(tag)
.assertValueEquals("1 percent")
.assertRangeInfoEquals(AccessibilityRangeInfo(0.005f, 0f..1f))
@@ -71,7 +71,7 @@
progress.value = 0.5f
}
- findByTag(tag)
+ onNodeWithTag(tag)
.assertValueEquals("50 percent")
.assertRangeInfoEquals(AccessibilityRangeInfo(0.5f, 0f..1f))
}
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DialogUiTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DialogUiTest.kt
index dbce2e5..4125093 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DialogUiTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DialogUiTest.kt
@@ -24,8 +24,8 @@
import androidx.ui.core.Modifier
import androidx.ui.test.assertIsDisplayed
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.findByText
+import androidx.ui.test.performClick
+import androidx.ui.test.onNodeWithText
import androidx.ui.test.runOnIdleCompose
import org.junit.Assert.assertEquals
import org.junit.Ignore
@@ -54,7 +54,7 @@
}
}
- findByText(defaultText).assertIsDisplayed()
+ onNodeWithText(defaultText).assertIsDisplayed()
}
@Test
@@ -80,15 +80,15 @@
}
}
- findByText(textBeforeClick)
+ onNodeWithText(textBeforeClick)
.assertIsDisplayed()
// Click inside the dialog
- .doClick()
+ .performClick()
// Check that the Clickable was pressed and that the Dialog is still visible, but with
// the new text
- findByText(textBeforeClick).assertDoesNotExist()
- findByText(textAfterClick).assertIsDisplayed()
+ onNodeWithText(textBeforeClick).assertDoesNotExist()
+ onNodeWithText(textAfterClick).assertIsDisplayed()
}
@Test
@@ -103,14 +103,14 @@
}
}
- findByText(defaultText).assertIsDisplayed()
+ onNodeWithText(defaultText).assertIsDisplayed()
// Click outside the dialog to dismiss it
val outsideX = 0
val outsideY = composeTestRule.displayMetrics.heightPixels / 2
UiDevice.getInstance(getInstrumentation()).click(outsideX, outsideY)
- findByText(defaultText).assertDoesNotExist()
+ onNodeWithText(defaultText).assertDoesNotExist()
}
@Test
@@ -125,7 +125,7 @@
}
}
- findByText(defaultText).assertIsDisplayed()
+ onNodeWithText(defaultText).assertIsDisplayed()
// Click outside the dialog to try to dismiss it
val outsideX = 0
@@ -133,7 +133,7 @@
UiDevice.getInstance(getInstrumentation()).click(outsideX, outsideY)
// The Dialog should still be visible
- findByText(defaultText).assertIsDisplayed()
+ onNodeWithText(defaultText).assertIsDisplayed()
}
@Test
@@ -148,12 +148,12 @@
}
}
- findByText(defaultText).assertIsDisplayed()
+ onNodeWithText(defaultText).assertIsDisplayed()
// Click the back button to dismiss the Dialog
UiDevice.getInstance(getInstrumentation()).pressBack()
- findByText(defaultText).assertDoesNotExist()
+ onNodeWithText(defaultText).assertDoesNotExist()
}
// TODO(pavlis): Espresso loses focus on the dialog after back press. That makes the
@@ -171,13 +171,13 @@
}
}
- findByText(defaultText).assertIsDisplayed()
+ onNodeWithText(defaultText).assertIsDisplayed()
// Click the back button to try to dismiss the dialog
UiDevice.getInstance(getInstrumentation()).pressBack()
// The Dialog should still be visible
- findByText(defaultText).assertIsDisplayed()
+ onNodeWithText(defaultText).assertIsDisplayed()
}
@Test
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DraggableTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DraggableTest.kt
index 29cacf7..7d3f71f 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DraggableTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DraggableTest.kt
@@ -29,15 +29,15 @@
import androidx.ui.layout.preferredSize
import androidx.ui.test.center
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.doPartialGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performGesture
+import androidx.ui.test.performPartialGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendDown
-import androidx.ui.test.sendMoveBy
-import androidx.ui.test.sendSwipe
-import androidx.ui.test.sendSwipeWithVelocity
-import androidx.ui.test.sendUp
+import androidx.ui.test.down
+import androidx.ui.test.moveBy
+import androidx.ui.test.swipe
+import androidx.ui.test.swipeWithVelocity
+import androidx.ui.test.up
import androidx.ui.test.size
import androidx.ui.geometry.Offset
import androidx.ui.unit.dp
@@ -69,8 +69,8 @@
}
)
}
- findByTag(draggableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(draggableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
@@ -80,8 +80,8 @@
assertThat(total).isGreaterThan(0)
total
}
- findByTag(draggableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(draggableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x, this.center.y + 100f),
duration = 100.milliseconds
@@ -90,8 +90,8 @@
runOnIdleCompose {
assertThat(total).isEqualTo(lastTotal)
}
- findByTag(draggableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(draggableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x - 100f, this.center.y),
duration = 100.milliseconds
@@ -114,8 +114,8 @@
}
)
}
- findByTag(draggableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(draggableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x, this.center.y + 100f),
duration = 100.milliseconds
@@ -125,8 +125,8 @@
assertThat(total).isGreaterThan(0)
total
}
- findByTag(draggableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(draggableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
@@ -135,8 +135,8 @@
runOnIdleCompose {
assertThat(total).isEqualTo(lastTotal)
}
- findByTag(draggableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(draggableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x, this.center.y - 100f),
duration = 100.milliseconds
@@ -169,8 +169,8 @@
assertThat(startTrigger).isEqualTo(0)
assertThat(stopTrigger).isEqualTo(0)
}
- findByTag(draggableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(draggableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
@@ -196,8 +196,8 @@
enabled = enabled.value
)
}
- findByTag(draggableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(draggableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
@@ -208,8 +208,8 @@
enabled.value = false
total
}
- findByTag(draggableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(draggableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
@@ -234,8 +234,8 @@
}
)
}
- findByTag(draggableBoxTag).doGesture {
- this.sendSwipeWithVelocity(
+ onNodeWithTag(draggableBoxTag).performGesture {
+ this.swipeWithVelocity(
start = this.center,
end = Offset(this.center.x + 100f, this.center.y),
endVelocity = 112f,
@@ -261,8 +261,8 @@
startDragImmediately = true
)
}
- findByTag(draggableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(draggableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
@@ -291,8 +291,8 @@
)
} else Modifier
}
- findByTag(draggableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(draggableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
@@ -334,8 +334,8 @@
}
}
}
- findByTag(draggableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(draggableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x + 200f, this.center.y),
duration = 300.milliseconds
@@ -364,19 +364,19 @@
assertThat(interactionState.value).doesNotContain(Interaction.Dragged)
}
- findByTag(draggableBoxTag)
- .doPartialGesture {
- sendDown(Offset(size.width / 4f, size.height / 2f))
- sendMoveBy(Offset(size.width / 2f, 0f))
+ onNodeWithTag(draggableBoxTag)
+ .performPartialGesture {
+ down(Offset(size.width / 4f, size.height / 2f))
+ moveBy(Offset(size.width / 2f, 0f))
}
runOnIdleCompose {
assertThat(interactionState.value).contains(Interaction.Dragged)
}
- findByTag(draggableBoxTag)
- .doPartialGesture {
- sendUp()
+ onNodeWithTag(draggableBoxTag)
+ .performPartialGesture {
+ up()
}
runOnIdleCompose {
@@ -408,10 +408,10 @@
assertThat(interactionState.value).doesNotContain(Interaction.Dragged)
}
- findByTag(draggableBoxTag)
- .doPartialGesture {
- sendDown(Offset(size.width / 4f, size.height / 2f))
- sendMoveBy(Offset(size.width / 2f, 0f))
+ onNodeWithTag(draggableBoxTag)
+ .performPartialGesture {
+ down(Offset(size.width / 4f, size.height / 2f))
+ moveBy(Offset(size.width / 2f, 0f))
}
runOnIdleCompose {
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DrawBackgroundTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DrawBackgroundTest.kt
index 81cd2ad..bee152a 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DrawBackgroundTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DrawBackgroundTest.kt
@@ -32,7 +32,7 @@
import androidx.ui.test.assertShape
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.unit.Density
import org.junit.Rule
import org.junit.Test
@@ -61,7 +61,7 @@
}
}
}
- val bitmap = findByTag(contentTag).captureToBitmap()
+ val bitmap = onNodeWithTag(contentTag).captureToBitmap()
bitmap.assertShape(
density = composeTestRule.density,
backgroundColor = Color.Magenta,
@@ -87,7 +87,7 @@
}
}
}
- val bitmap = findByTag(contentTag).captureToBitmap()
+ val bitmap = onNodeWithTag(contentTag).captureToBitmap()
bitmap.assertShape(
density = composeTestRule.density,
backgroundColor = Color.Magenta,
@@ -109,7 +109,7 @@
)
}
}
- val bitmap = findByTag(contentTag).captureToBitmap()
+ val bitmap = onNodeWithTag(contentTag).captureToBitmap()
bitmap.assertShape(
density = composeTestRule.density,
backgroundColor = Color.Magenta,
@@ -133,7 +133,7 @@
)
}
}
- val bitmap = findByTag(contentTag).captureToBitmap()
+ val bitmap = onNodeWithTag(contentTag).captureToBitmap()
bitmap.assertShape(
density = composeTestRule.density,
backgroundColor = Color.Magenta,
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/FoundationTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/FoundationTest.kt
index 5ed7fc0..6326641 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/FoundationTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/FoundationTest.kt
@@ -24,7 +24,7 @@
import androidx.ui.layout.preferredSizeIn
import androidx.ui.test.ComposeTestRule
import androidx.ui.test.SemanticsNodeInteraction
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.unit.dp
/**
@@ -46,5 +46,5 @@
}
}
- return findByTag("containerForSizeAssertion")
+ return onNodeWithTag("containerForSizeAssertion")
}
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ImageTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ImageTest.kt
index e2f1abf..11d3fba 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ImageTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ImageTest.kt
@@ -40,8 +40,8 @@
import androidx.ui.res.loadVectorResource
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
-import androidx.ui.test.findRoot
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onRoot
import androidx.ui.unit.IntOffset
import androidx.ui.unit.IntSize
import androidx.ui.unit.dp
@@ -112,7 +112,7 @@
val bgColorArgb = bgColor.toArgb()
val pathArgb = pathColor.toArgb()
- findByTag(contentTag).captureToBitmap().apply {
+ onNodeWithTag(contentTag).captureToBitmap().apply {
val imageStartX = width / 2 - imageWidth / 2
val imageStartY = height / 2 - imageHeight / 2
Assert.assertEquals(bgColorArgb, getPixel(imageStartX + 2, imageStartY))
@@ -152,7 +152,7 @@
val bgColorArgb = bgColor.toArgb()
val pathArgb = pathColor.toArgb()
- findRoot().captureToBitmap().apply {
+ onRoot().captureToBitmap().apply {
val imageStartX = width / 2 - subsectionWidth / 2
val imageStartY = height / 2 - subsectionHeight / 2
Assert.assertEquals(bgColorArgb, getPixel(imageStartX + 2, imageStartY))
@@ -222,7 +222,7 @@
val bgColorArgb = bgColor.toArgb()
val pathArgb = pathColor.toArgb()
- findByTag(contentTag).captureToBitmap().apply {
+ onNodeWithTag(contentTag).captureToBitmap().apply {
val imageStartX = width / 2 - imageComposableWidth / 2
val imageStartY = height / 2 - imageComposableHeight / 2
Assert.assertEquals(bgColorArgb, getPixel(imageStartX + 5, imageStartY))
@@ -266,7 +266,7 @@
val bgColorArgb = bgColor.toArgb()
val pathArgb = pathColor.toArgb()
- findByTag(contentTag).captureToBitmap().apply {
+ onNodeWithTag(contentTag).captureToBitmap().apply {
val composableEndX = width / 2 + imageComposableWidth / 2
val composableEndY = height / 2 + imageComposableHeight / 2
val imageStartX = composableEndX - imageWidth
@@ -318,7 +318,7 @@
val imageColor = Color.Red.toArgb()
val containerBgColor = Color.White.toArgb()
- findRoot().captureToBitmap().apply {
+ onRoot().captureToBitmap().apply {
val imageStartX = width / 2 - boxWidth / 2
val imageStartY = height / 2 - boxHeight / 2
Assert.assertEquals(containerBgColor, getPixel(imageStartX - 1, imageStartY - 1))
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/IndicationTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/IndicationTest.kt
index acd9946..6fe8f9e 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/IndicationTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/IndicationTest.kt
@@ -24,11 +24,11 @@
import androidx.ui.layout.preferredSize
import androidx.ui.test.center
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doPartialGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performPartialGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendDown
-import androidx.ui.test.sendUp
+import androidx.ui.test.down
+import androidx.ui.test.up
import androidx.ui.geometry.Offset
import androidx.ui.unit.dp
import com.google.common.truth.Truth.assertThat
@@ -81,18 +81,18 @@
)
}
assertThat(countDownLatch.count).isEqualTo(2)
- findByTag(testTag)
+ onNodeWithTag(testTag)
.assertExists()
- .doPartialGesture {
- sendDown(center)
+ .performPartialGesture {
+ down(center)
}
runOnIdleCompose {
assertThat(countDownLatch.count).isEqualTo(1)
}
- findByTag(testTag)
+ onNodeWithTag(testTag)
.assertExists()
- .doPartialGesture {
- sendUp()
+ .performPartialGesture {
+ up()
}
assertThat(countDownLatch.await(1000, TimeUnit.MILLISECONDS)).isTrue()
}
@@ -137,41 +137,41 @@
}
assertThat(lastPosition).isNull()
var position1: Offset? = null
- findByTag(testTag)
+ onNodeWithTag(testTag)
.assertExists()
- .doPartialGesture {
+ .performPartialGesture {
position1 = Offset(center.x, center.y + 20f)
// pointer 1, when we have multitouch
- sendDown(position1!!)
+ down(position1!!)
}
runOnIdleCompose {
assertThat(lastPosition).isEqualTo(position1!!)
}
- findByTag(testTag)
+ onNodeWithTag(testTag)
.assertExists()
- .doPartialGesture {
+ .performPartialGesture {
val position2 = Offset(center.x + 20f, center.y)
// pointer 2, when we have multitouch
- sendDown(position2)
+ down(position2)
}
// should be still position1
runOnIdleCompose {
assertThat(lastPosition).isEqualTo(position1!!)
}
- findByTag(testTag)
+ onNodeWithTag(testTag)
.assertExists()
- .doPartialGesture {
+ .performPartialGesture {
// pointer 1, when we have multitouch
- sendUp()
+ up()
}
runOnIdleCompose {
assertThat(lastPosition).isNull()
}
- findByTag(testTag)
+ onNodeWithTag(testTag)
.assertExists()
- .doPartialGesture {
+ .performPartialGesture {
// pointer 2, when we have multitouch
- sendUp()
+ up()
}
}
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ScrollableTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ScrollableTest.kt
index 8795598..5692904 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ScrollableTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ScrollableTest.kt
@@ -35,12 +35,12 @@
import androidx.ui.layout.preferredSize
import androidx.ui.test.center
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.runOnUiThread
-import androidx.ui.test.sendSwipe
-import androidx.ui.test.sendSwipeWithVelocity
+import androidx.ui.test.swipe
+import androidx.ui.test.swipeWithVelocity
import androidx.ui.geometry.Offset
import androidx.ui.unit.dp
import androidx.ui.unit.milliseconds
@@ -80,8 +80,8 @@
dragDirection = DragDirection.Horizontal
)
}
- findByTag(scrollableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(scrollableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
@@ -93,8 +93,8 @@
assertThat(total).isGreaterThan(0)
total
}
- findByTag(scrollableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(scrollableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x, this.center.y + 100f),
duration = 100.milliseconds
@@ -105,8 +105,8 @@
runOnIdleCompose {
assertThat(total).isEqualTo(lastTotal)
}
- findByTag(scrollableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(scrollableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x - 100f, this.center.y),
duration = 100.milliseconds
@@ -136,8 +136,8 @@
dragDirection = DragDirection.Vertical
)
}
- findByTag(scrollableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(scrollableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x, this.center.y + 100f),
duration = 100.milliseconds
@@ -149,8 +149,8 @@
assertThat(total).isGreaterThan(0)
total
}
- findByTag(scrollableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(scrollableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
@@ -161,8 +161,8 @@
runOnIdleCompose {
assertThat(total).isEqualTo(lastTotal)
}
- findByTag(scrollableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(scrollableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x, this.center.y - 100f),
duration = 100.milliseconds
@@ -200,8 +200,8 @@
assertThat(startTrigger).isEqualTo(0)
assertThat(stopTrigger).isEqualTo(0)
}
- findByTag(scrollableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(scrollableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
@@ -240,8 +240,8 @@
enabled = enabled.value
)
}
- findByTag(scrollableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(scrollableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
@@ -253,8 +253,8 @@
enabled.value = false
total
}
- findByTag(scrollableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(scrollableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
@@ -288,8 +288,8 @@
}
)
}
- findByTag(scrollableBoxTag).doGesture {
- this.sendSwipeWithVelocity(
+ onNodeWithTag(scrollableBoxTag).performGesture {
+ this.swipeWithVelocity(
start = this.center,
end = Offset(this.center.x + 100f, this.center.y),
endVelocity = 112f,
@@ -299,8 +299,8 @@
}
// don't advance clocks, so animation won't trigger yet
// and interrupt
- findByTag(scrollableBoxTag).doGesture {
- this.sendSwipeWithVelocity(
+ onNodeWithTag(scrollableBoxTag).performGesture {
+ this.swipeWithVelocity(
start = this.center,
end = Offset(this.center.x - 100f, this.center.y),
endVelocity = 312f,
@@ -332,8 +332,8 @@
dragDirection = DragDirection.Horizontal
)
}
- findByTag(scrollableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(scrollableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x + 100f, this.center.y),
duration = 100.milliseconds
@@ -344,8 +344,8 @@
Truth.assertThat(total).isGreaterThan(0f)
total
}
- findByTag(scrollableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(scrollableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x + 114f, this.center.y),
duration = 100.milliseconds
@@ -384,8 +384,8 @@
Modifier
}
}
- findByTag(scrollableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(scrollableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x + 100, this.center.y),
duration = 100.milliseconds
@@ -547,8 +547,8 @@
}
}
}
- findByTag(scrollableBoxTag).doGesture {
- this.sendSwipe(
+ onNodeWithTag(scrollableBoxTag).performGesture {
+ this.swipe(
start = this.center,
end = Offset(this.center.x + 200f, this.center.y),
duration = 300.milliseconds
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ScrollerTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ScrollerTest.kt
index 615be76..a5578c4 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ScrollerTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ScrollerTest.kt
@@ -39,17 +39,17 @@
import androidx.ui.test.assertPixels
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.doScrollTo
-import androidx.ui.test.findByTag
-import androidx.ui.test.findByText
+import androidx.ui.test.performGesture
+import androidx.ui.test.performScrollTo
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onNodeWithText
import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.runOnUiThread
-import androidx.ui.test.sendClick
-import androidx.ui.test.sendSwipeDown
-import androidx.ui.test.sendSwipeLeft
-import androidx.ui.test.sendSwipeRight
-import androidx.ui.test.sendSwipeUp
+import androidx.ui.test.click
+import androidx.ui.test.swipeDown
+import androidx.ui.test.swipeLeft
+import androidx.ui.test.swipeRight
+import androidx.ui.test.swipeUp
import androidx.ui.unit.Dp
import androidx.ui.unit.IntSize
import androidx.ui.unit.dp
@@ -272,9 +272,9 @@
fun verticalScroller_scrollTo_scrollForward() {
createScrollableContent(isVertical = true)
- findByText("50")
+ onNodeWithText("50")
.assertIsNotDisplayed()
- .doScrollTo()
+ .performScrollTo()
.assertIsDisplayed()
}
@@ -282,9 +282,9 @@
fun horizontalScroller_scrollTo_scrollForward() {
createScrollableContent(isVertical = false)
- findByText("50")
+ onNodeWithText("50")
.assertIsNotDisplayed()
- .doScrollTo()
+ .performScrollTo()
.assertIsDisplayed()
}
@@ -299,9 +299,9 @@
)
)
- findByText("50")
+ onNodeWithText("50")
.assertIsNotDisplayed()
- .doScrollTo()
+ .performScrollTo()
.assertIsDisplayed()
}
@@ -316,9 +316,9 @@
)
)
- findByText("50")
+ onNodeWithText("50")
.assertIsNotDisplayed()
- .doScrollTo()
+ .performScrollTo()
.assertIsDisplayed()
}
@@ -326,14 +326,14 @@
fun verticalScroller_scrollTo_scrollBack() {
createScrollableContent(isVertical = true)
- findByText("50")
+ onNodeWithText("50")
.assertIsNotDisplayed()
- .doScrollTo()
+ .performScrollTo()
.assertIsDisplayed()
- findByText("20")
+ onNodeWithText("20")
.assertIsNotDisplayed()
- .doScrollTo()
+ .performScrollTo()
.assertIsDisplayed()
}
@@ -341,25 +341,25 @@
fun horizontalScroller_scrollTo_scrollBack() {
createScrollableContent(isVertical = false)
- findByText("50")
+ onNodeWithText("50")
.assertIsNotDisplayed()
- .doScrollTo()
+ .performScrollTo()
.assertIsDisplayed()
- findByText("20")
+ onNodeWithText("20")
.assertIsNotDisplayed()
- .doScrollTo()
+ .performScrollTo()
.assertIsDisplayed()
}
@Test
fun verticalScroller_swipeUp_swipeDown() {
- swipeScrollerAndBack(true, GestureScope::sendSwipeUp, GestureScope::sendSwipeDown)
+ swipeScrollerAndBack(true, GestureScope::swipeUp, GestureScope::swipeDown)
}
@Test
fun horizontalScroller_swipeLeft_swipeRight() {
- swipeScrollerAndBack(false, GestureScope::sendSwipeLeft, GestureScope::sendSwipeRight)
+ swipeScrollerAndBack(false, GestureScope::swipeLeft, GestureScope::swipeRight)
}
@Test
@@ -499,8 +499,8 @@
assertThat(scrollerPosition.isAnimating).isEqualTo(false)
}
- findByTag(scrollerTag)
- .doGesture { sendSwipeUp() }
+ onNodeWithTag(scrollerTag)
+ .performGesture { swipeUp() }
runOnIdleCompose {
clock.clockTimeMillis += 100
@@ -508,8 +508,8 @@
}
// TODO (matvei/jelle): this should be down, and not click to be 100% fair
- findByTag(scrollerTag)
- .doGesture { sendClick() }
+ onNodeWithTag(scrollerTag)
+ .performGesture { click() }
runOnIdleCompose {
assertThat(scrollerPosition.isAnimating).isEqualTo(false)
@@ -554,7 +554,7 @@
runOnIdleCompose {
clock.clockTimeMillis += 5000
}
- findByTag(scrollerTag).awaitScrollAnimation(scrollerPosition)
+ onNodeWithTag(scrollerTag).awaitScrollAnimation(scrollerPosition)
runOnIdleCompose {
assertThat(scrollerPosition.value).isEqualTo(assertValue)
}
@@ -577,14 +577,14 @@
assertThat(scrollerPosition.value).isEqualTo(0f)
}
- findByTag(scrollerTag)
- .doGesture { firstSwipe() }
+ onNodeWithTag(scrollerTag)
+ .performGesture { firstSwipe() }
runOnIdleCompose {
clock.clockTimeMillis += 5000
}
- findByTag(scrollerTag)
+ onNodeWithTag(scrollerTag)
.awaitScrollAnimation(scrollerPosition)
val scrolledValue = runOnIdleCompose {
@@ -592,14 +592,14 @@
}
assertThat(scrolledValue).isGreaterThan(0f)
- findByTag(scrollerTag)
- .doGesture { secondSwipe() }
+ onNodeWithTag(scrollerTag)
+ .performGesture { secondSwipe() }
runOnIdleCompose {
clock.clockTimeMillis += 5000
}
- findByTag(scrollerTag)
+ onNodeWithTag(scrollerTag)
.awaitScrollAnimation(scrollerPosition)
runOnIdleCompose {
@@ -676,7 +676,7 @@
height: Int = 40,
rowHeight: Int = 5
) {
- findByTag(scrollerTag)
+ onNodeWithTag(scrollerTag)
.captureToBitmap()
.assertPixels(expectedSize = IntSize(width, height)) { pos ->
val colorIndex = (offset + pos.y) / rowHeight
@@ -691,7 +691,7 @@
height: Int = 45,
columnWidth: Int = 5
) {
- findByTag(scrollerTag)
+ onNodeWithTag(scrollerTag)
.captureToBitmap()
.assertPixels(expectedSize = IntSize(width, height)) { pos ->
val colorIndex = (offset + pos.x) / columnWidth
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/SelectableTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/SelectableTest.kt
index 4d851fc..c5297ce 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/SelectableTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/SelectableTest.kt
@@ -30,16 +30,16 @@
import androidx.ui.test.assertIsUnselected
import androidx.ui.test.center
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.doPartialGesture
-import androidx.ui.test.find
-import androidx.ui.test.findAll
-import androidx.ui.test.findByText
-import androidx.ui.test.first
+import androidx.ui.test.performClick
+import androidx.ui.test.performPartialGesture
+import androidx.ui.test.onNode
+import androidx.ui.test.onAllNodes
+import androidx.ui.test.onNodeWithText
+import androidx.ui.test.onFirst
import androidx.ui.test.isInMutuallyExclusiveGroup
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendDown
-import androidx.ui.test.sendUp
+import androidx.ui.test.down
+import androidx.ui.test.up
import com.google.common.truth.Truth
import org.junit.Rule
import org.junit.Test
@@ -62,9 +62,9 @@
)
}
- findAll(isInMutuallyExclusiveGroup())
+ onAllNodes(isInMutuallyExclusiveGroup())
.assertCountEquals(1)
- .first()
+ .onFirst()
.assertIsInMutuallyExclusiveGroup()
.assertIsSelected()
}
@@ -82,11 +82,11 @@
)
}
- find(isInMutuallyExclusiveGroup())
+ onNode(isInMutuallyExclusiveGroup())
.assertIsUnselected()
- .doClick()
+ .performClick()
.assertIsSelected()
- .doClick()
+ .performClick()
.assertIsUnselected()
}
@@ -102,9 +102,9 @@
)
}
- find(isInMutuallyExclusiveGroup())
+ onNode(isInMutuallyExclusiveGroup())
.assertIsUnselected()
- .doClick()
+ .performClick()
.assertIsUnselected()
}
@@ -128,15 +128,15 @@
Truth.assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
}
- findByText("SelectableText")
- .doPartialGesture { sendDown(center) }
+ onNodeWithText("SelectableText")
+ .performPartialGesture { down(center) }
runOnIdleCompose {
Truth.assertThat(interactionState.value).contains(Interaction.Pressed)
}
- findByText("SelectableText")
- .doPartialGesture { sendUp() }
+ onNodeWithText("SelectableText")
+ .performPartialGesture { up() }
runOnIdleCompose {
Truth.assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
@@ -166,8 +166,8 @@
Truth.assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
}
- findByText("SelectableText")
- .doPartialGesture { sendDown(center) }
+ onNodeWithText("SelectableText")
+ .performPartialGesture { down(center) }
runOnIdleCompose {
Truth.assertThat(interactionState.value).contains(Interaction.Pressed)
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/SoftwareKeyboardTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/SoftwareKeyboardTest.kt
index 1eb2871..16fb63e 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/SoftwareKeyboardTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/SoftwareKeyboardTest.kt
@@ -25,8 +25,8 @@
import androidx.ui.input.TextInputService
import androidx.ui.layout.fillMaxSize
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.find
+import androidx.ui.test.performClick
+import androidx.ui.test.onNode
import androidx.ui.test.hasInputMethodsSupport
import androidx.ui.test.runOnIdleCompose
import androidx.ui.text.SoftwareKeyboardController
@@ -72,8 +72,8 @@
}
// Perform click to focus in.
- find(hasInputMethodsSupport())
- .doClick()
+ onNode(hasInputMethodsSupport())
+ .performClick()
runOnIdleCompose {
verify(onTextInputStarted, times(1)).invoke(any())
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldCursorTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldCursorTest.kt
index 155dd8c..b468f9c 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldCursorTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldCursorTest.kt
@@ -30,8 +30,8 @@
import androidx.ui.test.assertShape
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.find
+import androidx.ui.test.performClick
+import androidx.ui.test.onNode
import androidx.ui.test.hasInputMethodsSupport
import androidx.ui.test.waitForIdle
import androidx.ui.text.TextStyle
@@ -71,14 +71,14 @@
}
)
}
- find(hasInputMethodsSupport()).doClick()
+ onNode(hasInputMethodsSupport()).performClick()
assert(latch.await(1, TimeUnit.SECONDS))
waitForIdle()
composeTestRule.clockTestRule.advanceClock(100)
with(composeTestRule.density) {
- find(hasInputMethodsSupport())
+ onNode(hasInputMethodsSupport())
.captureToBitmap()
.assertCursor(2.dp, this)
}
@@ -108,7 +108,7 @@
}
}
- find(hasInputMethodsSupport()).doClick()
+ onNode(hasInputMethodsSupport()).performClick()
assert(latch.await(1, TimeUnit.SECONDS))
waitForIdle()
@@ -116,14 +116,14 @@
// cursor visible first 500 ms
composeTestRule.clockTestRule.advanceClock(100)
with(composeTestRule.density) {
- find(hasInputMethodsSupport())
+ onNode(hasInputMethodsSupport())
.captureToBitmap()
.assertCursor(2.dp, this)
}
// cursor invisible during next 500 ms
composeTestRule.clockTestRule.advanceClock(700)
- find(hasInputMethodsSupport())
+ onNode(hasInputMethodsSupport())
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldOnValueChangeTextFieldValueTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldOnValueChangeTextFieldValueTest.kt
index 33c26ee..d11e00c 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldOnValueChangeTextFieldValueTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldOnValueChangeTextFieldValueTest.kt
@@ -30,12 +30,12 @@
import androidx.ui.input.SetSelectionEditOp
import androidx.ui.input.TextInputService
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.find
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNode
import androidx.ui.test.hasInputMethodsSupport
import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.runOnUiThread
-import androidx.ui.test.sendClick
+import androidx.ui.test.click
import androidx.ui.text.TextRange
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockitokotlin2.any
@@ -90,8 +90,8 @@
}
// Perform click to focus in.
- find(hasInputMethodsSupport())
- .doGesture { sendClick(Offset(1f, 1f)) }
+ onNode(hasInputMethodsSupport())
+ .performGesture { click(Offset(1f, 1f)) }
runOnIdleCompose {
// Verify startInput is called and capture the callback.
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldTest.kt
index c009349..f841167 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldTest.kt
@@ -46,9 +46,9 @@
import androidx.ui.test.assertShape
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.find
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.onNode
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasImeAction
import androidx.ui.test.hasInputMethodsSupport
import androidx.ui.test.runOnIdleCompose
@@ -96,7 +96,7 @@
}
}
- find(hasInputMethodsSupport()).doClick()
+ onNode(hasInputMethodsSupport()).performClick()
runOnIdleCompose {
assertThat(focusModifier.focusState).isEqualTo(FocusState.Focused)
@@ -131,7 +131,7 @@
}
}
- find(hasInputMethodsSupport()).doClick()
+ onNode(hasInputMethodsSupport()).performClick()
var onEditCommandCallback: ((List<EditOperation>) -> Unit)? = null
runOnIdleCompose {
@@ -203,7 +203,7 @@
}
}
- find(hasInputMethodsSupport()).doClick()
+ onNode(hasInputMethodsSupport()).performClick()
var onEditCommandCallback: ((List<EditOperation>) -> Unit)? = null
runOnIdleCompose {
@@ -271,7 +271,7 @@
}
}
- find(hasInputMethodsSupport()).doClick()
+ onNode(hasInputMethodsSupport()).performClick()
var onEditCommandCallback: ((List<EditOperation>) -> Unit)? = null
runOnIdleCompose {
@@ -420,7 +420,7 @@
)
}
- find(hasInputMethodsSupport())
+ onNode(hasInputMethodsSupport())
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -441,7 +441,7 @@
)
}
- findByTag("textField")
+ onNodeWithTag("textField")
.assert(hasInputMethodsSupport())
.assert(hasImeAction(ImeAction.Unspecified))
}
@@ -456,7 +456,7 @@
)
}
- find(hasInputMethodsSupport())
+ onNode(hasInputMethodsSupport())
.assert(hasImeAction(ImeAction.Search))
}
}
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextTest.kt
index 143b4657..9b68464 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextTest.kt
@@ -22,7 +22,7 @@
import androidx.ui.graphics.Color
import androidx.ui.test.assertTextEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
import androidx.ui.text.TextStyle
import androidx.ui.text.font.FontStyle
@@ -232,6 +232,6 @@
}
}
- findByTag("text").assertTextEquals(TestText)
+ onNodeWithTag("text").assertTextEquals(TestText)
}
}
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ToggleableTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ToggleableTest.kt
index 6c7334c..8529f6a 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ToggleableTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ToggleableTest.kt
@@ -38,15 +38,15 @@
import androidx.ui.test.assertIsOn
import androidx.ui.test.center
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.doPartialGesture
-import androidx.ui.test.find
-import androidx.ui.test.findByTag
-import androidx.ui.test.findByText
+import androidx.ui.test.performClick
+import androidx.ui.test.performPartialGesture
+import androidx.ui.test.onNode
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onNodeWithText
import androidx.ui.test.isToggleable
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendDown
-import androidx.ui.test.sendUp
+import androidx.ui.test.down
+import androidx.ui.test.up
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -89,15 +89,15 @@
FoundationSemanticsProperties.ToggleableState, ToggleableState.Indeterminate
)
- findByTag("checkedToggleable")
+ onNodeWithTag("checkedToggleable")
.assertIsEnabled()
.assertIsOn()
.assertHasClickAction()
- findByTag("unCheckedToggleable")
+ onNodeWithTag("unCheckedToggleable")
.assertIsEnabled()
.assertIsOff()
.assertHasClickAction()
- findByTag("indeterminateToggleable")
+ onNodeWithTag("indeterminateToggleable")
.assertIsEnabled()
.assert(hasIndeterminateState())
.assertHasClickAction()
@@ -122,11 +122,11 @@
}
}
- findByTag("checkedToggleable")
+ onNodeWithTag("checkedToggleable")
.assertIsEnabled()
.assertIsOn()
.assertHasClickAction()
- findByTag("unCheckedToggleable")
+ onNodeWithTag("unCheckedToggleable")
.assertIsEnabled()
.assertIsOff()
.assertHasClickAction()
@@ -147,7 +147,7 @@
}
}
- find(isToggleable())
+ onNode(isToggleable())
.assertIsNotEnabled()
.assertHasNoClickAction()
}
@@ -168,8 +168,8 @@
}
}
- find(isToggleable())
- .doClick()
+ onNode(isToggleable())
+ .performClick()
runOnIdleCompose {
assertThat(checked).isEqualTo(false)
@@ -196,15 +196,15 @@
assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
}
- findByText("ToggleableText")
- .doPartialGesture { sendDown(center) }
+ onNodeWithText("ToggleableText")
+ .performPartialGesture { down(center) }
runOnIdleCompose {
assertThat(interactionState.value).contains(Interaction.Pressed)
}
- findByText("ToggleableText")
- .doPartialGesture { sendUp() }
+ onNodeWithText("ToggleableText")
+ .performPartialGesture { up() }
runOnIdleCompose {
assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
@@ -234,8 +234,8 @@
assertThat(interactionState.value).doesNotContain(Interaction.Pressed)
}
- findByText("ToggleableText")
- .doPartialGesture { sendDown(center) }
+ onNodeWithText("ToggleableText")
+ .performPartialGesture { down(center) }
runOnIdleCompose {
assertThat(interactionState.value).contains(Interaction.Pressed)
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ZoomableTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ZoomableTest.kt
index edd436b..658ab47 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ZoomableTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ZoomableTest.kt
@@ -27,11 +27,11 @@
import androidx.ui.test.AnimationClockTestRule
import androidx.ui.test.center
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.runOnUiThread
-import androidx.ui.test.sendPinch
+import androidx.ui.test.pinch
import androidx.ui.test.size
import androidx.ui.unit.dp
import androidx.ui.unit.toSize
@@ -64,13 +64,13 @@
setZoomableContent { Modifier.zoomable(state) }
- findByTag(TEST_TAG).doGesture {
+ onNodeWithTag(TEST_TAG).performGesture {
val leftStartX = center.x - 10
val leftEndX = size.toSize().width * EDGE_FUZZ_FACTOR
val rightStartX = center.x + 10
val rightEndX = size.toSize().width * (1 - EDGE_FUZZ_FACTOR)
- sendPinch(
+ pinch(
Offset(leftStartX, center.y),
Offset(leftEndX, center.y),
Offset(rightStartX, center.y),
@@ -95,13 +95,13 @@
setZoomableContent { Modifier.zoomable(state) }
- findByTag(TEST_TAG).doGesture {
+ onNodeWithTag(TEST_TAG).performGesture {
val leftStartX = size.toSize().width * EDGE_FUZZ_FACTOR
val leftEndX = center.x - 10
val rightStartX = size.toSize().width * (1 - EDGE_FUZZ_FACTOR)
val rightEndX = center.x + 10
- sendPinch(
+ pinch(
Offset(leftStartX, center.y),
Offset(leftEndX, center.y),
Offset(rightStartX, center.y),
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/lazy/LazyColumnItemsTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/lazy/LazyColumnItemsTest.kt
index 9b342ab..81739a0 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/lazy/LazyColumnItemsTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/lazy/LazyColumnItemsTest.kt
@@ -39,14 +39,14 @@
import androidx.ui.test.assertIsDisplayed
import androidx.ui.test.assertIsNotDisplayed
import androidx.ui.test.center
-import androidx.ui.test.children
+import androidx.ui.test.onChildren
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
-import androidx.ui.test.findByText
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onNodeWithText
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendSwipeUp
-import androidx.ui.test.sendSwipeWithVelocity
+import androidx.ui.test.swipeUp
+import androidx.ui.test.swipeWithVelocity
import androidx.ui.test.waitForIdle
import androidx.ui.unit.Density
import androidx.ui.unit.Dp
@@ -104,8 +104,8 @@
assertWithMessage("Additional composition occurred for no apparent reason")
.that(composed).isFalse()
- findByTag(LazyColumnItemsTag)
- .doGesture { sendSwipeUp() }
+ onNodeWithTag(LazyColumnItemsTag)
+ .performGesture { swipeUp() }
waitForIdle()
@@ -223,13 +223,13 @@
while (numItems >= 0) {
// Confirm the number of children to ensure there are no extra items
- findByTag(tag)
- .children()
+ onNodeWithTag(tag)
+ .onChildren()
.assertCountEquals(numItems)
// Confirm the children's content
for (i in 1..3) {
- findByText("$i").apply {
+ onNodeWithText("$i").apply {
if (i <= numItems) {
assertExists()
} else {
@@ -265,13 +265,13 @@
// Confirm the number of children to ensure there are no extra items
val numItems = data.size
- findByTag(tag)
- .children()
+ onNodeWithTag(tag)
+ .onChildren()
.assertCountEquals(numItems)
// Confirm the children's content
for (item in data) {
- findByText("$item").assertExists()
+ onNodeWithText("$item").assertExists()
}
}
}
@@ -299,10 +299,10 @@
}
}
- findByTag(LazyColumnItemsTag)
+ onNodeWithTag(LazyColumnItemsTag)
.scrollBy(y = 21.dp, density = composeTestRule.density)
- findByTag(thirdTag)
+ onNodeWithTag(thirdTag)
.assertExists()
.assertIsNotDisplayed()
@@ -312,23 +312,23 @@
waitForIdle()
- findByTag(LazyColumnItemsTag)
+ onNodeWithTag(LazyColumnItemsTag)
.scrollBy(y = 10.dp, density = composeTestRule.density)
- findByTag(thirdTag)
+ onNodeWithTag(thirdTag)
.assertIsDisplayed()
}
}
internal fun SemanticsNodeInteraction.scrollBy(x: Dp = 0.dp, y: Dp = 0.dp, density: Density) =
- doGesture {
+ performGesture {
with(density) {
val touchSlop = TouchSlop.toIntPx()
val xPx = x.toIntPx()
val yPx = y.toIntPx()
val offsetX = if (xPx > 0) xPx + touchSlop else if (xPx < 0) xPx - touchSlop else 0
val offsetY = if (yPx > 0) yPx + touchSlop else if (yPx < 0) xPx - touchSlop else 0
- sendSwipeWithVelocity(
+ swipeWithVelocity(
start = center,
end = Offset(center.x - offsetX, center.y - offsetY),
endVelocity = 0f
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/lazy/LazyRowItemsTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/lazy/LazyRowItemsTest.kt
index e306602..43dcdc2 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/lazy/LazyRowItemsTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/lazy/LazyRowItemsTest.kt
@@ -25,7 +25,7 @@
import androidx.ui.layout.preferredWidth
import androidx.ui.test.assertIsDisplayed
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.unit.dp
import org.junit.Rule
import org.junit.Test
@@ -53,16 +53,16 @@
}
}
- findByTag("1")
+ onNodeWithTag("1")
.assertIsDisplayed()
- findByTag("2")
+ onNodeWithTag("2")
.assertIsDisplayed()
- findByTag("3")
+ onNodeWithTag("3")
.assertDoesNotExist()
- findByTag("4")
+ onNodeWithTag("4")
.assertDoesNotExist()
}
@@ -78,19 +78,19 @@
}
}
- findByTag(LazyRowItemsTag)
+ onNodeWithTag(LazyRowItemsTag)
.scrollBy(x = 50.dp, density = composeTestRule.density)
- findByTag("1")
+ onNodeWithTag("1")
.assertIsDisplayed()
- findByTag("2")
+ onNodeWithTag("2")
.assertIsDisplayed()
- findByTag("3")
+ onNodeWithTag("3")
.assertIsDisplayed()
- findByTag("4")
+ onNodeWithTag("4")
.assertDoesNotExist()
}
@@ -106,16 +106,16 @@
}
}
- findByTag(LazyRowItemsTag)
+ onNodeWithTag(LazyRowItemsTag)
.scrollBy(x = 102.dp, density = composeTestRule.density)
- findByTag("1")
+ onNodeWithTag("1")
.assertDoesNotExist()
- findByTag("2")
+ onNodeWithTag("2")
.assertIsDisplayed()
- findByTag("3")
+ onNodeWithTag("3")
.assertIsDisplayed()
}
@@ -131,19 +131,19 @@
}
}
- findByTag(LazyRowItemsTag)
+ onNodeWithTag(LazyRowItemsTag)
.scrollBy(x = 150.dp, density = composeTestRule.density)
- findByTag("1")
+ onNodeWithTag("1")
.assertDoesNotExist()
- findByTag("2")
+ onNodeWithTag("2")
.assertIsDisplayed()
- findByTag("3")
+ onNodeWithTag("3")
.assertIsDisplayed()
- findByTag("4")
+ onNodeWithTag("4")
.assertIsDisplayed()
}
}
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/Clickable.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/Clickable.kt
index dacfdbe..95a2c2a 100644
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/Clickable.kt
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/Clickable.kt
@@ -26,7 +26,7 @@
import androidx.ui.core.gesture.pressIndicatorGestureFilter
import androidx.ui.core.gesture.tapGestureFilter
import androidx.ui.core.semantics.semantics
-import androidx.ui.semantics.enabled
+import androidx.ui.semantics.disabled
import androidx.ui.semantics.onClick
/**
@@ -58,16 +58,14 @@
onDoubleClick: (() -> Unit)? = null,
onClick: () -> Unit
) = composed {
- val semanticModifier = Modifier.semantics(
- mergeAllDescendants = true,
- properties = {
- this.enabled = enabled
- if (enabled) {
- // b/156468846: add long click semantics and double click if needed
- onClick(action = { onClick(); return@onClick true }, label = onClickLabel)
- }
+ val semanticModifier = Modifier.semantics(mergeAllDescendants = true) {
+ if (enabled) {
+ // b/156468846: add long click semantics and double click if needed
+ onClick(action = { onClick(); return@onClick true }, label = onClickLabel)
+ } else {
+ disabled()
}
- )
+ }
val interactionUpdate =
if (enabled) {
Modifier.pressIndicatorGestureFilter(
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/Dialog.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/Dialog.kt
index bbd548f..9763ec6 100644
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/Dialog.kt
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/Dialog.kt
@@ -77,7 +77,7 @@
dialog.setContent(composition) {
// TODO(b/159900354): draw a scrim and add margins around the Compose Dialog, and
// consume clicks so they can't pass through to the underlying UI
- Box(Modifier.semantics { this.dialog = true }, children = children)
+ Box(Modifier.semantics { this.dialog() }, children = children)
}
}
}
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/Scroller.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/Scroller.kt
index a4d59e0..2f50b6a 100644
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/Scroller.kt
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/Scroller.kt
@@ -44,7 +44,7 @@
import androidx.ui.layout.RowScope
import androidx.ui.savedinstancestate.Saver
import androidx.ui.savedinstancestate.rememberSavedInstanceState
-import androidx.ui.semantics.ScrollTo
+import androidx.ui.semantics.scrollBy
import kotlin.math.roundToInt
/**
@@ -289,13 +289,13 @@
.semantics {
if (isScrollable) {
// when b/156389287 is fixed, this should be proper scrollTo with reverse handling
- ScrollTo(action = { x, y ->
+ scrollBy(action = { x, y ->
if (isVertical) {
scrollerPosition.scrollBy(y)
} else {
scrollerPosition.scrollBy(x)
}
- return@ScrollTo true
+ return@scrollBy true
})
}
}
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Selectable.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Selectable.kt
index cac46d7..25d8ca6 100644
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Selectable.kt
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Selectable.kt
@@ -67,9 +67,9 @@
interactionState = interactionState,
indication = indication,
onClick = onClick
- ).semantics(properties = {
+ ).semantics {
this.inMutuallyExclusiveGroup = inMutuallyExclusiveGroup
this.selected = selected
this.accessibilityValue = if (selected) Strings.Selected else Strings.NotSelected
- })
+ }
}
\ No newline at end of file
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Toggleable.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Toggleable.kt
index 407f163..1511a42 100644
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Toggleable.kt
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Toggleable.kt
@@ -35,7 +35,7 @@
import androidx.ui.foundation.selection.ToggleableState.On
import androidx.ui.foundation.semantics.toggleableState
import androidx.ui.semantics.accessibilityValue
-import androidx.ui.semantics.enabled
+import androidx.ui.semantics.disabled
import androidx.ui.semantics.onClick
/**
@@ -99,23 +99,21 @@
onClick: () -> Unit
) = composed {
// TODO(pavlis): Handle multiple states for Semantics
- val semantics = Modifier.semantics(
- mergeAllDescendants = true,
- properties = {
- this.accessibilityValue = when (state) {
- // TODO(ryanmentley): These should be set by Checkbox, Switch, etc.
- On -> Strings.Checked
- Off -> Strings.Unchecked
- Indeterminate -> Strings.Indeterminate
- }
- this.toggleableState = state
- this.enabled = enabled
-
- if (enabled) {
- onClick(action = { onClick(); return@onClick true }, label = "Toggle")
- }
+ val semantics = Modifier.semantics(mergeAllDescendants = true) {
+ this.accessibilityValue = when (state) {
+ // TODO(ryanmentley): These should be set by Checkbox, Switch, etc.
+ On -> Strings.Checked
+ Off -> Strings.Unchecked
+ Indeterminate -> Strings.Indeterminate
}
- )
+ this.toggleableState = state
+
+ if (enabled) {
+ onClick(action = { onClick(); return@onClick true }, label = "Toggle")
+ } else {
+ disabled()
+ }
+ }
val interactionUpdate =
if (enabled) {
Modifier.pressIndicatorGestureFilter(
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/semantics/FoundationSemanticsProperties.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/semantics/FoundationSemanticsProperties.kt
index 0cb421f..e65cd13 100644
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/semantics/FoundationSemanticsProperties.kt
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/semantics/FoundationSemanticsProperties.kt
@@ -26,14 +26,6 @@
*/
object FoundationSemanticsProperties {
/**
- * Whether this element is in a group from which only a single item can be selected at any given
- * time (such as a radio group)
- *
- * @see SemanticsPropertyReceiver.inMutuallyExclusiveGroup
- */
- val InMutuallyExclusiveGroup = SemanticsPropertyKey<Boolean>("InMutuallyExclusiveGroup")
-
- /**
* Whether this element is selected (out of a list of possible selections).
* The presence of this property indicates that the element is selectable.
*
@@ -42,6 +34,17 @@
val Selected = SemanticsPropertyKey<Boolean>("Selected")
/**
+ * Whether this element is in a group from which only a single item can be selected at any given
+ * time (such as a radio group)
+ *
+ * The presence of this property indicates that the element is a member of
+ * a selectable group (exclusive or not).
+ *
+ * @see SemanticsPropertyReceiver.inMutuallyExclusiveGroup
+ */
+ val InMutuallyExclusiveGroup = SemanticsPropertyKey<Boolean>("InMutuallyExclusiveGroup")
+
+ /**
* The state of a toggleable component.
* The presence of this property indicates that the element is toggleable.
*
@@ -53,7 +56,7 @@
* Whether this element is a Dialog. Not to be confused with if this element is _part of_ a
* Dialog.
*/
- val IsDialog = SemanticsPropertyKey<Boolean>("IsDialog")
+ val IsDialog = SemanticsPropertyKey<Unit>("IsDialog")
}
/**
@@ -85,4 +88,6 @@
/**
* Whether this element is a Dialog. Not to be confused with if this element is _part of_ a Dialog.
*/
-var SemanticsPropertyReceiver.dialog by FoundationSemanticsProperties.IsDialog
+fun SemanticsPropertyReceiver.dialog() {
+ this[FoundationSemanticsProperties.IsDialog] = Unit
+}
diff --git a/ui/ui-graphics/src/commonMain/kotlin/androidx/ui/graphics/painter/Painter.kt b/ui/ui-graphics/src/commonMain/kotlin/androidx/ui/graphics/painter/Painter.kt
index ad05fab..177e964 100644
--- a/ui/ui-graphics/src/commonMain/kotlin/androidx/ui/graphics/painter/Painter.kt
+++ b/ui/ui-graphics/src/commonMain/kotlin/androidx/ui/graphics/painter/Painter.kt
@@ -197,7 +197,7 @@
right = this.size.width - size.width,
bottom = this.size.height - size.height) {
- if (alpha > 0.0f) {
+ if (alpha > 0.0f && size.width > 0 && size.height > 0) {
if (useLayer) {
val layerRect =
Rect.fromLTWH(0.0f, 0.0f, size.width, size.height)
diff --git a/ui/ui-internal-lint-checks/build.gradle b/ui/ui-internal-lint-checks/build.gradle
index 30d0ec9..070faad 100644
--- a/ui/ui-internal-lint-checks/build.gradle
+++ b/ui/ui-internal-lint-checks/build.gradle
@@ -44,10 +44,9 @@
}
androidx {
- name = "UI lint checks"
+ name = "Compose internal lint checks"
publish = Publish.NONE
toolingProject = true
- mavenGroup = LibraryGroups.UI
inceptionYear = "2019"
description = "Internal lint checks for Compose"
}
diff --git a/ui/ui-layout/integration-tests/layout-demos/build.gradle b/ui/ui-layout/integration-tests/layout-demos/build.gradle
index 56af918..10bbc5c 100644
--- a/ui/ui-layout/integration-tests/layout-demos/build.gradle
+++ b/ui/ui-layout/integration-tests/layout-demos/build.gradle
@@ -31,7 +31,7 @@
implementation(KOTLIN_STDLIB)
implementation project(":compose:runtime:runtime")
- implementation project(":ui:integration-tests:demos:common")
+ implementation project(":compose:integration-tests:demos:common")
implementation project(":compose:core:core")
implementation project(":compose:foundation:foundation-layout")
implementation project(":compose:foundation:foundation-layout:samples")
diff --git a/ui/ui-layout/src/androidAndroidTest/kotlin/androidx/ui/layout/test/LayoutOffsetTest.kt b/ui/ui-layout/src/androidAndroidTest/kotlin/androidx/ui/layout/test/LayoutOffsetTest.kt
index 212b057..dad5892 100644
--- a/ui/ui-layout/src/androidAndroidTest/kotlin/androidx/ui/layout/test/LayoutOffsetTest.kt
+++ b/ui/ui-layout/src/androidAndroidTest/kotlin/androidx/ui/layout/test/LayoutOffsetTest.kt
@@ -34,7 +34,7 @@
import androidx.ui.layout.size
import androidx.ui.layout.wrapContentSize
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
import androidx.ui.unit.dp
import org.junit.Assert
@@ -79,7 +79,7 @@
}
}
- findByTag("stack").assertExists()
+ onNodeWithTag("stack").assertExists()
runOnIdleCompose {
assertEquals(offsetX.toIntPx(), positionX)
assertEquals(offsetY.toIntPx(), positionY)
@@ -112,7 +112,7 @@
}
}
- findByTag("stack").assertExists()
+ onNodeWithTag("stack").assertExists()
runOnIdleCompose {
assertEquals(containerWidth.toIntPx() - offsetX.toIntPx() - boxSize, positionX)
assertEquals(offsetY.toIntPx(), positionY)
@@ -138,7 +138,7 @@
}
}
- findByTag("stack").assertExists()
+ onNodeWithTag("stack").assertExists()
runOnIdleCompose {
Assert.assertEquals(offsetX, positionX)
Assert.assertEquals(offsetY, positionY)
@@ -171,7 +171,7 @@
}
}
- findByTag("stack").assertExists()
+ onNodeWithTag("stack").assertExists()
runOnIdleCompose {
Assert.assertEquals(
containerWidth.toIntPx() - offsetX.roundToInt() - boxSize,
diff --git a/ui/ui-material/api/0.1.0-dev15.txt b/ui/ui-material/api/0.1.0-dev15.txt
index 289b9e3..6b26c47 100644
--- a/ui/ui-material/api/0.1.0-dev15.txt
+++ b/ui/ui-material/api/0.1.0-dev15.txt
@@ -19,6 +19,14 @@
method @androidx.compose.Composable public static void TopAppBar-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.AppBarKt.TopAppBarElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
}
+ public enum BottomDrawerState {
+ method public static androidx.ui.material.BottomDrawerState valueOf(String name) throws java.lang.IllegalArgumentException;
+ method public static androidx.ui.material.BottomDrawerState[] values();
+ enum_constant public static final androidx.ui.material.BottomDrawerState Closed;
+ enum_constant public static final androidx.ui.material.BottomDrawerState Expanded;
+ enum_constant public static final androidx.ui.material.BottomDrawerState Opened;
+ }
+
public final class BottomNavigationKt {
method @androidx.compose.Composable public static void BottomNavigation-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.BottomNavigationKt.BottomNavigationElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.Composable public static void BottomNavigationItem-dOPBtLY(kotlin.jvm.functions.Function0<kotlin.Unit> icon, kotlin.jvm.functions.Function0<kotlin.Unit> text = emptyContent(), boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onSelected, androidx.ui.core.Modifier modifier = Modifier, boolean alwaysShowLabels = true, long activeColor = contentColor(), long inactiveColor = EmphasisAmbient.current.medium.applyEmphasis(activeColor));
@@ -104,7 +112,7 @@
}
public final class DrawerKt {
- method @androidx.compose.Composable public static void BottomDrawerLayout-s-rmCOo(androidx.ui.material.DrawerState drawerState, kotlin.jvm.functions.Function1<? super androidx.ui.material.DrawerState,kotlin.Unit> onStateChange, boolean gesturesEnabled = true, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, kotlin.jvm.functions.Function0<kotlin.Unit> drawerContent, kotlin.jvm.functions.Function0<kotlin.Unit> bodyContent);
+ method @androidx.compose.Composable public static void BottomDrawerLayout-8vp1Knk(androidx.ui.material.BottomDrawerState drawerState, kotlin.jvm.functions.Function1<? super androidx.ui.material.BottomDrawerState,kotlin.Unit> onStateChange, boolean gesturesEnabled = true, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, kotlin.jvm.functions.Function0<kotlin.Unit> drawerContent, kotlin.jvm.functions.Function0<kotlin.Unit> bodyContent);
method @androidx.compose.Composable public static void ModalDrawerLayout-s-rmCOo(androidx.ui.material.DrawerState drawerState, kotlin.jvm.functions.Function1<? super androidx.ui.material.DrawerState,kotlin.Unit> onStateChange, boolean gesturesEnabled = true, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, kotlin.jvm.functions.Function0<kotlin.Unit> drawerContent, kotlin.jvm.functions.Function0<kotlin.Unit> bodyContent);
}
diff --git a/ui/ui-material/api/current.txt b/ui/ui-material/api/current.txt
index 289b9e3..6b26c47 100644
--- a/ui/ui-material/api/current.txt
+++ b/ui/ui-material/api/current.txt
@@ -19,6 +19,14 @@
method @androidx.compose.Composable public static void TopAppBar-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.AppBarKt.TopAppBarElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
}
+ public enum BottomDrawerState {
+ method public static androidx.ui.material.BottomDrawerState valueOf(String name) throws java.lang.IllegalArgumentException;
+ method public static androidx.ui.material.BottomDrawerState[] values();
+ enum_constant public static final androidx.ui.material.BottomDrawerState Closed;
+ enum_constant public static final androidx.ui.material.BottomDrawerState Expanded;
+ enum_constant public static final androidx.ui.material.BottomDrawerState Opened;
+ }
+
public final class BottomNavigationKt {
method @androidx.compose.Composable public static void BottomNavigation-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.BottomNavigationKt.BottomNavigationElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.Composable public static void BottomNavigationItem-dOPBtLY(kotlin.jvm.functions.Function0<kotlin.Unit> icon, kotlin.jvm.functions.Function0<kotlin.Unit> text = emptyContent(), boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onSelected, androidx.ui.core.Modifier modifier = Modifier, boolean alwaysShowLabels = true, long activeColor = contentColor(), long inactiveColor = EmphasisAmbient.current.medium.applyEmphasis(activeColor));
@@ -104,7 +112,7 @@
}
public final class DrawerKt {
- method @androidx.compose.Composable public static void BottomDrawerLayout-s-rmCOo(androidx.ui.material.DrawerState drawerState, kotlin.jvm.functions.Function1<? super androidx.ui.material.DrawerState,kotlin.Unit> onStateChange, boolean gesturesEnabled = true, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, kotlin.jvm.functions.Function0<kotlin.Unit> drawerContent, kotlin.jvm.functions.Function0<kotlin.Unit> bodyContent);
+ method @androidx.compose.Composable public static void BottomDrawerLayout-8vp1Knk(androidx.ui.material.BottomDrawerState drawerState, kotlin.jvm.functions.Function1<? super androidx.ui.material.BottomDrawerState,kotlin.Unit> onStateChange, boolean gesturesEnabled = true, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, kotlin.jvm.functions.Function0<kotlin.Unit> drawerContent, kotlin.jvm.functions.Function0<kotlin.Unit> bodyContent);
method @androidx.compose.Composable public static void ModalDrawerLayout-s-rmCOo(androidx.ui.material.DrawerState drawerState, kotlin.jvm.functions.Function1<? super androidx.ui.material.DrawerState,kotlin.Unit> onStateChange, boolean gesturesEnabled = true, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, kotlin.jvm.functions.Function0<kotlin.Unit> drawerContent, kotlin.jvm.functions.Function0<kotlin.Unit> bodyContent);
}
diff --git a/ui/ui-material/api/public_plus_experimental_0.1.0-dev15.txt b/ui/ui-material/api/public_plus_experimental_0.1.0-dev15.txt
index 289b9e3..6b26c47 100644
--- a/ui/ui-material/api/public_plus_experimental_0.1.0-dev15.txt
+++ b/ui/ui-material/api/public_plus_experimental_0.1.0-dev15.txt
@@ -19,6 +19,14 @@
method @androidx.compose.Composable public static void TopAppBar-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.AppBarKt.TopAppBarElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
}
+ public enum BottomDrawerState {
+ method public static androidx.ui.material.BottomDrawerState valueOf(String name) throws java.lang.IllegalArgumentException;
+ method public static androidx.ui.material.BottomDrawerState[] values();
+ enum_constant public static final androidx.ui.material.BottomDrawerState Closed;
+ enum_constant public static final androidx.ui.material.BottomDrawerState Expanded;
+ enum_constant public static final androidx.ui.material.BottomDrawerState Opened;
+ }
+
public final class BottomNavigationKt {
method @androidx.compose.Composable public static void BottomNavigation-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.BottomNavigationKt.BottomNavigationElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.Composable public static void BottomNavigationItem-dOPBtLY(kotlin.jvm.functions.Function0<kotlin.Unit> icon, kotlin.jvm.functions.Function0<kotlin.Unit> text = emptyContent(), boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onSelected, androidx.ui.core.Modifier modifier = Modifier, boolean alwaysShowLabels = true, long activeColor = contentColor(), long inactiveColor = EmphasisAmbient.current.medium.applyEmphasis(activeColor));
@@ -104,7 +112,7 @@
}
public final class DrawerKt {
- method @androidx.compose.Composable public static void BottomDrawerLayout-s-rmCOo(androidx.ui.material.DrawerState drawerState, kotlin.jvm.functions.Function1<? super androidx.ui.material.DrawerState,kotlin.Unit> onStateChange, boolean gesturesEnabled = true, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, kotlin.jvm.functions.Function0<kotlin.Unit> drawerContent, kotlin.jvm.functions.Function0<kotlin.Unit> bodyContent);
+ method @androidx.compose.Composable public static void BottomDrawerLayout-8vp1Knk(androidx.ui.material.BottomDrawerState drawerState, kotlin.jvm.functions.Function1<? super androidx.ui.material.BottomDrawerState,kotlin.Unit> onStateChange, boolean gesturesEnabled = true, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, kotlin.jvm.functions.Function0<kotlin.Unit> drawerContent, kotlin.jvm.functions.Function0<kotlin.Unit> bodyContent);
method @androidx.compose.Composable public static void ModalDrawerLayout-s-rmCOo(androidx.ui.material.DrawerState drawerState, kotlin.jvm.functions.Function1<? super androidx.ui.material.DrawerState,kotlin.Unit> onStateChange, boolean gesturesEnabled = true, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, kotlin.jvm.functions.Function0<kotlin.Unit> drawerContent, kotlin.jvm.functions.Function0<kotlin.Unit> bodyContent);
}
diff --git a/ui/ui-material/api/public_plus_experimental_current.txt b/ui/ui-material/api/public_plus_experimental_current.txt
index 289b9e3..6b26c47 100644
--- a/ui/ui-material/api/public_plus_experimental_current.txt
+++ b/ui/ui-material/api/public_plus_experimental_current.txt
@@ -19,6 +19,14 @@
method @androidx.compose.Composable public static void TopAppBar-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.AppBarKt.TopAppBarElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
}
+ public enum BottomDrawerState {
+ method public static androidx.ui.material.BottomDrawerState valueOf(String name) throws java.lang.IllegalArgumentException;
+ method public static androidx.ui.material.BottomDrawerState[] values();
+ enum_constant public static final androidx.ui.material.BottomDrawerState Closed;
+ enum_constant public static final androidx.ui.material.BottomDrawerState Expanded;
+ enum_constant public static final androidx.ui.material.BottomDrawerState Opened;
+ }
+
public final class BottomNavigationKt {
method @androidx.compose.Composable public static void BottomNavigation-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.BottomNavigationKt.BottomNavigationElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.Composable public static void BottomNavigationItem-dOPBtLY(kotlin.jvm.functions.Function0<kotlin.Unit> icon, kotlin.jvm.functions.Function0<kotlin.Unit> text = emptyContent(), boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onSelected, androidx.ui.core.Modifier modifier = Modifier, boolean alwaysShowLabels = true, long activeColor = contentColor(), long inactiveColor = EmphasisAmbient.current.medium.applyEmphasis(activeColor));
@@ -104,7 +112,7 @@
}
public final class DrawerKt {
- method @androidx.compose.Composable public static void BottomDrawerLayout-s-rmCOo(androidx.ui.material.DrawerState drawerState, kotlin.jvm.functions.Function1<? super androidx.ui.material.DrawerState,kotlin.Unit> onStateChange, boolean gesturesEnabled = true, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, kotlin.jvm.functions.Function0<kotlin.Unit> drawerContent, kotlin.jvm.functions.Function0<kotlin.Unit> bodyContent);
+ method @androidx.compose.Composable public static void BottomDrawerLayout-8vp1Knk(androidx.ui.material.BottomDrawerState drawerState, kotlin.jvm.functions.Function1<? super androidx.ui.material.BottomDrawerState,kotlin.Unit> onStateChange, boolean gesturesEnabled = true, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, kotlin.jvm.functions.Function0<kotlin.Unit> drawerContent, kotlin.jvm.functions.Function0<kotlin.Unit> bodyContent);
method @androidx.compose.Composable public static void ModalDrawerLayout-s-rmCOo(androidx.ui.material.DrawerState drawerState, kotlin.jvm.functions.Function1<? super androidx.ui.material.DrawerState,kotlin.Unit> onStateChange, boolean gesturesEnabled = true, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, kotlin.jvm.functions.Function0<kotlin.Unit> drawerContent, kotlin.jvm.functions.Function0<kotlin.Unit> bodyContent);
}
diff --git a/ui/ui-material/api/restricted_0.1.0-dev15.txt b/ui/ui-material/api/restricted_0.1.0-dev15.txt
index 381198f..dbfe1d3 100644
--- a/ui/ui-material/api/restricted_0.1.0-dev15.txt
+++ b/ui/ui-material/api/restricted_0.1.0-dev15.txt
@@ -19,6 +19,14 @@
method @androidx.compose.Composable public static void TopAppBar-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.AppBarKt.TopAppBarElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
}
+ public enum BottomDrawerState {
+ method public static androidx.ui.material.BottomDrawerState valueOf(String name) throws java.lang.IllegalArgumentException;
+ method public static androidx.ui.material.BottomDrawerState[] values();
+ enum_constant public static final androidx.ui.material.BottomDrawerState Closed;
+ enum_constant public static final androidx.ui.material.BottomDrawerState Expanded;
+ enum_constant public static final androidx.ui.material.BottomDrawerState Opened;
+ }
+
public final class BottomNavigationKt {
method @androidx.compose.Composable public static void BottomNavigation-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.BottomNavigationKt.BottomNavigationElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.Composable public static void BottomNavigationItem-dOPBtLY(kotlin.jvm.functions.Function0<kotlin.Unit> icon, kotlin.jvm.functions.Function0<kotlin.Unit> text = emptyContent(), boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onSelected, androidx.ui.core.Modifier modifier = Modifier, boolean alwaysShowLabels = true, long activeColor = contentColor(), long inactiveColor = EmphasisAmbient.current.medium.applyEmphasis(activeColor));
@@ -105,7 +113,7 @@
}
public final class DrawerKt {
- method @androidx.compose.Composable public static void BottomDrawerLayout-s-rmCOo(androidx.ui.material.DrawerState drawerState, kotlin.jvm.functions.Function1<? super androidx.ui.material.DrawerState,kotlin.Unit> onStateChange, boolean gesturesEnabled = true, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, kotlin.jvm.functions.Function0<kotlin.Unit> drawerContent, kotlin.jvm.functions.Function0<kotlin.Unit> bodyContent);
+ method @androidx.compose.Composable public static void BottomDrawerLayout-8vp1Knk(androidx.ui.material.BottomDrawerState drawerState, kotlin.jvm.functions.Function1<? super androidx.ui.material.BottomDrawerState,kotlin.Unit> onStateChange, boolean gesturesEnabled = true, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, kotlin.jvm.functions.Function0<kotlin.Unit> drawerContent, kotlin.jvm.functions.Function0<kotlin.Unit> bodyContent);
method @androidx.compose.Composable public static void ModalDrawerLayout-s-rmCOo(androidx.ui.material.DrawerState drawerState, kotlin.jvm.functions.Function1<? super androidx.ui.material.DrawerState,kotlin.Unit> onStateChange, boolean gesturesEnabled = true, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, kotlin.jvm.functions.Function0<kotlin.Unit> drawerContent, kotlin.jvm.functions.Function0<kotlin.Unit> bodyContent);
}
diff --git a/ui/ui-material/api/restricted_current.txt b/ui/ui-material/api/restricted_current.txt
index 381198f..dbfe1d3 100644
--- a/ui/ui-material/api/restricted_current.txt
+++ b/ui/ui-material/api/restricted_current.txt
@@ -19,6 +19,14 @@
method @androidx.compose.Composable public static void TopAppBar-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.AppBarKt.TopAppBarElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
}
+ public enum BottomDrawerState {
+ method public static androidx.ui.material.BottomDrawerState valueOf(String name) throws java.lang.IllegalArgumentException;
+ method public static androidx.ui.material.BottomDrawerState[] values();
+ enum_constant public static final androidx.ui.material.BottomDrawerState Closed;
+ enum_constant public static final androidx.ui.material.BottomDrawerState Expanded;
+ enum_constant public static final androidx.ui.material.BottomDrawerState Opened;
+ }
+
public final class BottomNavigationKt {
method @androidx.compose.Composable public static void BottomNavigation-oP-1cd0(androidx.ui.core.Modifier modifier = Modifier, long backgroundColor = MaterialTheme.colors.primarySurface, long contentColor = contentColorFor(backgroundColor), float elevation = androidx.ui.material.BottomNavigationKt.BottomNavigationElevation, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.Composable public static void BottomNavigationItem-dOPBtLY(kotlin.jvm.functions.Function0<kotlin.Unit> icon, kotlin.jvm.functions.Function0<kotlin.Unit> text = emptyContent(), boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onSelected, androidx.ui.core.Modifier modifier = Modifier, boolean alwaysShowLabels = true, long activeColor = contentColor(), long inactiveColor = EmphasisAmbient.current.medium.applyEmphasis(activeColor));
@@ -105,7 +113,7 @@
}
public final class DrawerKt {
- method @androidx.compose.Composable public static void BottomDrawerLayout-s-rmCOo(androidx.ui.material.DrawerState drawerState, kotlin.jvm.functions.Function1<? super androidx.ui.material.DrawerState,kotlin.Unit> onStateChange, boolean gesturesEnabled = true, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, kotlin.jvm.functions.Function0<kotlin.Unit> drawerContent, kotlin.jvm.functions.Function0<kotlin.Unit> bodyContent);
+ method @androidx.compose.Composable public static void BottomDrawerLayout-8vp1Knk(androidx.ui.material.BottomDrawerState drawerState, kotlin.jvm.functions.Function1<? super androidx.ui.material.BottomDrawerState,kotlin.Unit> onStateChange, boolean gesturesEnabled = true, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, kotlin.jvm.functions.Function0<kotlin.Unit> drawerContent, kotlin.jvm.functions.Function0<kotlin.Unit> bodyContent);
method @androidx.compose.Composable public static void ModalDrawerLayout-s-rmCOo(androidx.ui.material.DrawerState drawerState, kotlin.jvm.functions.Function1<? super androidx.ui.material.DrawerState,kotlin.Unit> onStateChange, boolean gesturesEnabled = true, androidx.ui.graphics.Shape drawerShape = large, float drawerElevation = DrawerConstants.DefaultElevation, kotlin.jvm.functions.Function0<kotlin.Unit> drawerContent, kotlin.jvm.functions.Function0<kotlin.Unit> bodyContent);
}
diff --git a/ui/ui-material/icons/extended/src/androidTest/java/androidx/ui/material/icons/test/IconComparisonTest.kt b/ui/ui-material/icons/extended/src/androidTest/java/androidx/ui/material/icons/test/IconComparisonTest.kt
index c5be28e..f4c91ea 100644
--- a/ui/ui-material/icons/extended/src/androidTest/java/androidx/ui/material/icons/test/IconComparisonTest.kt
+++ b/ui/ui-material/icons/extended/src/androidTest/java/androidx/ui/material/icons/test/IconComparisonTest.kt
@@ -41,7 +41,7 @@
import androidx.ui.res.vectorResource
import androidx.ui.test.android.AndroidComposeTestRule
import androidx.ui.test.captureToBitmap
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnUiThread
import androidx.ui.test.waitForIdle
import com.google.common.truth.Truth
@@ -114,8 +114,8 @@
assertVectorAssetsAreEqual(xmlVector!!, programmaticVector, iconName)
assertBitmapsAreEqual(
- findByTag(XmlTestTag).captureToBitmap(),
- findByTag(ProgrammaticTestTag).captureToBitmap(),
+ onNodeWithTag(XmlTestTag).captureToBitmap(),
+ onNodeWithTag(ProgrammaticTestTag).captureToBitmap(),
iconName
)
diff --git a/ui/ui-material/icons/generator/build.gradle b/ui/ui-material/icons/generator/build.gradle
index 2968f3a..286a7a6 100644
--- a/ui/ui-material/icons/generator/build.gradle
+++ b/ui/ui-material/icons/generator/build.gradle
@@ -44,7 +44,7 @@
publish = Publish.NONE
toolingProject = true
mavenVersion = LibraryVersions.UI
- mavenGroup = LibraryGroups.UI
+ mavenGroup = LibraryGroups.Compose.MATERIAL
inceptionYear = "2020"
description = "Generator module that parses XML drawables to generate programmatic " +
"representations of Material Icons."
diff --git a/ui/ui-material/integration-tests/material-demos/build.gradle b/ui/ui-material/integration-tests/material-demos/build.gradle
index 0bdb7c4..7bba715a 100644
--- a/ui/ui-material/integration-tests/material-demos/build.gradle
+++ b/ui/ui-material/integration-tests/material-demos/build.gradle
@@ -17,13 +17,13 @@
implementation(KOTLIN_STDLIB)
implementation project(":compose:runtime:runtime")
- implementation project(":ui:integration-tests:demos:common")
+ implementation project(":compose:integration-tests:demos:common")
implementation project(":compose:core:core")
implementation project(":compose:foundation:foundation")
implementation project(":compose:foundation:foundation-layout")
implementation project(":compose:material:material:samples")
implementation project(":compose:core:core-text")
- implementation project(":ui:ui-android-view")
+ implementation project(":compose:android-view:android-view")
implementation project(":compose:material:material")
}
@@ -38,8 +38,6 @@
androidx {
name = "Compose Material Demos"
publish = Publish.NONE
- mavenVersion = LibraryVersions.UI
- mavenGroup = LibraryGroups.UI
inceptionYear = "2019"
description = "This is a project for Material demos."
}
diff --git a/ui/ui-material/integration-tests/material-studies/build.gradle b/ui/ui-material/integration-tests/material-studies/build.gradle
index 016e93e..c78f3c4 100644
--- a/ui/ui-material/integration-tests/material-studies/build.gradle
+++ b/ui/ui-material/integration-tests/material-studies/build.gradle
@@ -35,7 +35,7 @@
implementation(KOTLIN_STDLIB)
implementation project(":compose:runtime:runtime")
- implementation project(":ui:integration-tests:demos:common")
+ implementation project(":compose:integration-tests:demos:common")
implementation project(":compose:core:core")
implementation project(":compose:foundation:foundation")
implementation project(":compose:foundation:foundation-layout")
diff --git a/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/DrawerSamples.kt b/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/DrawerSamples.kt
index 51431bb..f49012c 100644
--- a/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/DrawerSamples.kt
+++ b/ui/ui-material/samples/src/main/java/androidx/ui/material/samples/DrawerSamples.kt
@@ -29,6 +29,7 @@
import androidx.ui.layout.fillMaxSize
import androidx.ui.layout.preferredHeight
import androidx.ui.material.BottomDrawerLayout
+import androidx.ui.material.BottomDrawerState
import androidx.ui.material.Button
import androidx.ui.material.DrawerState
import androidx.ui.material.ModalDrawerLayout
@@ -39,36 +40,52 @@
fun ModalDrawerSample() {
val (state, onStateChange) = state { DrawerState.Closed }
val appContentText =
- if (state == DrawerState.Closed) ">>> Pull to open >>>" else "<<< Swipe to close <<<"
+ if (state == DrawerState.Closed) {
+ ">>> Pull to open >>>"
+ } else {
+ "<<< Swipe to close <<<"
+ }
ModalDrawerLayout(
drawerState = state,
onStateChange = onStateChange,
- drawerContent = { YourDrawerContent(onStateChange) },
- bodyContent = { YourAppContent(appContentText, onStateChange) }
+ drawerContent = {
+ YourDrawerContent(onClose = { onStateChange(DrawerState.Closed) })
+ },
+ bodyContent = {
+ YourAppContent(appContentText, onOpen = { onStateChange(DrawerState.Opened) })
+ }
)
}
@Sampled
@Composable
fun BottomDrawerSample() {
- val (state, onStateChange) = state { DrawerState.Closed }
+ val (state, onStateChange) = state { BottomDrawerState.Closed }
val appContentText =
- if (state == DrawerState.Closed) "▲▲▲ Pull to open ▲▲▲" else "▼▼▼ Drag down to close ▼▼▼"
+ if (state == BottomDrawerState.Closed) {
+ "▲▲▲ Pull to open ▲▲▲"
+ } else {
+ "▼▼▼ Drag down to close ▼▼▼"
+ }
BottomDrawerLayout(
drawerState = state,
onStateChange = onStateChange,
- drawerContent = { YourDrawerContent(onStateChange) },
- bodyContent = { YourAppContent(appContentText, onStateChange) }
+ drawerContent = {
+ YourDrawerContent(onClose = { onStateChange(BottomDrawerState.Closed) })
+ },
+ bodyContent = {
+ YourAppContent(appContentText, onOpen = { onStateChange(BottomDrawerState.Opened) })
+ }
)
}
@Composable
-private fun YourDrawerContent(onStateChange: (DrawerState) -> Unit) {
+private fun YourDrawerContent(onClose: () -> Unit) {
Box(Modifier.fillMaxSize(), gravity = ContentGravity.Center) {
Column(Modifier.fillMaxHeight()) {
Text(text = "Drawer Content")
Spacer(Modifier.preferredHeight(20.dp))
- Button(onClick = { onStateChange(DrawerState.Closed) }) {
+ Button(onClick = onClose) {
Text("Close Drawer")
}
}
@@ -76,11 +93,11 @@
}
@Composable
-private fun YourAppContent(text: String, onDrawerStateChange: (DrawerState) -> Unit) {
+private fun YourAppContent(text: String, onOpen: () -> Unit) {
Column(Modifier.fillMaxHeight()) {
Text(text = text)
Spacer(Modifier.preferredHeight(20.dp))
- Button(onClick = { onDrawerStateChange(DrawerState.Opened) }) {
+ Button(onClick = onOpen) {
Text("Click to open")
}
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/AppBarTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/AppBarTest.kt
index a3a3c71..dc4f5ac 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/AppBarTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/AppBarTest.kt
@@ -31,8 +31,8 @@
import androidx.ui.test.assertLeftPositionInRootIsEqualTo
import androidx.ui.test.assertTopPositionInRootIsEqualTo
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
-import androidx.ui.test.findByText
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onNodeWithText
import androidx.ui.test.getBoundsInRoot
import androidx.ui.text.TextStyle
import androidx.ui.unit.Dp
@@ -70,7 +70,7 @@
composeTestRule.setMaterialContent {
TopAppBar(title = { Text(title) })
}
- findByText(title).assertIsDisplayed()
+ onNodeWithText(title).assertIsDisplayed()
}
@Test
@@ -91,25 +91,25 @@
}
}
- val appBarBounds = findByTag("bar").getBoundsInRoot()
- val titleBounds = findByTag("title").getBoundsInRoot()
+ val appBarBounds = onNodeWithTag("bar").getBoundsInRoot()
+ val titleBounds = onNodeWithTag("title").getBoundsInRoot()
val appBarBottomEdgeY = appBarBounds.top + appBarBounds.height
- findByTag("navigationIcon")
+ onNodeWithTag("navigationIcon")
// Navigation icon should be 4.dp from the start
.assertLeftPositionInRootIsEqualTo(AppBarStartAndEndPadding)
// Navigation icon should be 4.dp from the bottom
.assertTopPositionInRootIsEqualTo(
appBarBottomEdgeY - AppBarStartAndEndPadding - FakeIconSize)
- findByTag("title")
+ onNodeWithTag("title")
// Title should be 72.dp from the start
// 4.dp padding for the whole app bar + 68.dp inset
.assertLeftPositionInRootIsEqualTo(4.dp + 68.dp)
// Title should be vertically centered
.assertTopPositionInRootIsEqualTo((appBarBounds.height - titleBounds.height) / 2)
- findByTag("action")
+ onNodeWithTag("action")
// Action should be placed at the end
.assertLeftPositionInRootIsEqualTo(expectedActionPosition(appBarBounds.width))
// Action should be 4.dp from the bottom
@@ -132,14 +132,14 @@
}
}
- val appBarBounds = findByTag("bar").getBoundsInRoot()
+ val appBarBounds = onNodeWithTag("bar").getBoundsInRoot()
- findByTag("title")
+ onNodeWithTag("title")
// Title should now be placed 16.dp from the start, as there is no navigation icon
// 4.dp padding for the whole app bar + 12.dp inset
.assertLeftPositionInRootIsEqualTo(4.dp + 12.dp)
- findByTag("action")
+ onNodeWithTag("action")
// Action should still be placed at the end
.assertLeftPositionInRootIsEqualTo(expectedActionPosition(appBarBounds.width))
}
@@ -181,10 +181,10 @@
}
}
- val appBarBounds = findByTag("bar").getBoundsInRoot()
+ val appBarBounds = onNodeWithTag("bar").getBoundsInRoot()
val appBarBottomEdgeY = appBarBounds.top + appBarBounds.height
- findByTag("icon")
+ onNodeWithTag("icon")
// Child icon should be 4.dp from the start
.assertLeftPositionInRootIsEqualTo(AppBarStartAndEndPadding)
// Child icon should be 4.dp from the bottom
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/BottomNavigationTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/BottomNavigationTest.kt
index 359cbd3..8e0f172 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/BottomNavigationTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/BottomNavigationTest.kt
@@ -36,10 +36,10 @@
import androidx.ui.test.assertLeftPositionInRootIsEqualTo
import androidx.ui.test.assertTopPositionInRootIsEqualTo
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.findAll
-import androidx.ui.test.findByTag
-import androidx.ui.test.findByText
+import androidx.ui.test.performClick
+import androidx.ui.test.onAllNodes
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onNodeWithText
import androidx.ui.test.getBoundsInRoot
import androidx.ui.test.isInMutuallyExclusiveGroup
import androidx.ui.unit.dp
@@ -133,16 +133,16 @@
}
}
- val itemBounds = findByTag("item").getBoundsInRoot()
- val iconBounds = findByTag("icon", useUnmergedTree = true).getBoundsInRoot()
- val textBounds = findByText("ItemText").getBoundsInRoot()
+ val itemBounds = onNodeWithTag("item").getBoundsInRoot()
+ val iconBounds = onNodeWithTag("icon", useUnmergedTree = true).getBoundsInRoot()
+ val textBounds = onNodeWithText("ItemText").getBoundsInRoot()
// Distance from the bottom to the text baseline and from the text baseline to the
// bottom of the icon
val textBaseline = 12.dp
// Relative position of the baseline to the top of text
- val relativeTextBaseline = findByText("ItemText").getLastBaselinePosition()
+ val relativeTextBaseline = onNodeWithText("ItemText").getLastBaselinePosition()
// Absolute y position of the text baseline
val absoluteTextBaseline = textBounds.top + relativeTextBaseline
@@ -150,7 +150,7 @@
// Text baseline should be 12.dp from the bottom of the item
absoluteTextBaseline.assertIsEqualTo(itemBottom - textBaseline)
- findByTag("icon", useUnmergedTree = true)
+ onNodeWithTag("icon", useUnmergedTree = true)
// The icon should be centered in the item
.assertLeftPositionInRootIsEqualTo((itemBounds.width - iconBounds.width) / 2)
// The bottom of the icon is 12.dp above the text baseline
@@ -182,12 +182,12 @@
// The text should not be placed, since the item is not selected and alwaysShowLabels
// is false
- findByText("ItemText", useUnmergedTree = true).assertIsNotDisplayed()
+ onNodeWithText("ItemText", useUnmergedTree = true).assertIsNotDisplayed()
- val itemBounds = findByTag("item").getBoundsInRoot()
- val iconBounds = findByTag("icon", useUnmergedTree = true).getBoundsInRoot()
+ val itemBounds = onNodeWithTag("item").getBoundsInRoot()
+ val iconBounds = onNodeWithTag("icon", useUnmergedTree = true).getBoundsInRoot()
- findByTag("icon", useUnmergedTree = true)
+ onNodeWithTag("icon", useUnmergedTree = true)
.assertLeftPositionInRootIsEqualTo((itemBounds.width - iconBounds.width) / 2)
.assertTopPositionInRootIsEqualTo((itemBounds.height - iconBounds.height) / 2)
}
@@ -212,11 +212,11 @@
}
}
- val itemBounds = findByTag("item").getBoundsInRoot()
- val iconBounds = findByTag("icon", useUnmergedTree = true).getBoundsInRoot()
+ val itemBounds = onNodeWithTag("item").getBoundsInRoot()
+ val iconBounds = onNodeWithTag("icon", useUnmergedTree = true).getBoundsInRoot()
// The icon should be centered in the item, as there is no text placeable provided
- findByTag("icon", useUnmergedTree = true)
+ onNodeWithTag("icon", useUnmergedTree = true)
.assertLeftPositionInRootIsEqualTo((itemBounds.width - iconBounds.width) / 2)
.assertTopPositionInRootIsEqualTo((itemBounds.height - iconBounds.height) / 2)
}
@@ -228,7 +228,7 @@
}
// Find all items and ensure there are 3
- findAll(isInMutuallyExclusiveGroup())
+ onAllNodes(isInMutuallyExclusiveGroup())
.assertCountEquals(3)
// Ensure semantics match for selected state of the items
.apply {
@@ -238,7 +238,7 @@
}
// Click the last item
.apply {
- get(2).doClick()
+ get(2).performClick()
}
.apply {
get(0).assertIsUnselected()
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonScreenshotTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonScreenshotTest.kt
index 6901f48..5da9d7e 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonScreenshotTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonScreenshotTest.kt
@@ -28,13 +28,13 @@
import androidx.ui.test.captureToBitmap
import androidx.ui.test.center
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doPartialGesture
-import androidx.ui.test.find
-import androidx.ui.test.findByText
-import androidx.ui.test.findRoot
+import androidx.ui.test.performPartialGesture
+import androidx.ui.test.onNode
+import androidx.ui.test.onNodeWithText
import androidx.ui.unit.dp
import androidx.ui.test.hasClickAction
-import androidx.ui.test.sendDown
+import androidx.ui.test.down
+import androidx.ui.test.onRoot
import androidx.ui.test.waitForIdle
import org.junit.Rule
import org.junit.Test
@@ -60,7 +60,7 @@
}
}
- find(hasClickAction())
+ onNode(hasClickAction())
.captureToBitmap()
.assertAgainstGolden(screenshotRule, "button_default")
}
@@ -73,7 +73,7 @@
}
}
- findByText("Button")
+ onNodeWithText("Button")
.captureToBitmap()
.assertAgainstGolden(screenshotRule, "button_disabled")
}
@@ -89,14 +89,14 @@
composeTestRule.clockTestRule.pauseClock()
// Start ripple
- find(hasClickAction())
- .doPartialGesture { sendDown(center) }
+ onNode(hasClickAction())
+ .performPartialGesture { down(center) }
// Let ripple propagate
waitForIdle()
composeTestRule.clockTestRule.advanceClock(50)
- findRoot()
+ onRoot()
.captureToBitmap()
.assertAgainstGolden(screenshotRule, "button_ripple")
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt
index 5556d88..d4572b5 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt
@@ -64,10 +64,10 @@
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.find
-import androidx.ui.test.findByTag
-import androidx.ui.test.findByText
+import androidx.ui.test.performClick
+import androidx.ui.test.onNode
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onNodeWithText
import androidx.ui.test.hasClickAction
import androidx.ui.test.runOnIdleCompose
import androidx.ui.unit.Dp
@@ -101,7 +101,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.assertIsEnabled()
}
@@ -115,7 +115,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.assertIsNotEnabled()
}
@@ -135,8 +135,8 @@
// TODO(b/129400818): this actually finds the text, not the button as
// merge semantics aren't implemented yet
- findByText(text)
- .doClick()
+ onNodeWithText(text)
+ .performClick()
runOnIdleCompose {
assertThat(counter).isEqualTo(1)
@@ -157,11 +157,11 @@
}
}
}
- findByTag(tag)
+ onNodeWithTag(tag)
// Confirm the button starts off enabled, with a click action
.assertHasClickAction()
.assertIsEnabled()
- .doClick()
+ .performClick()
// Then confirm it's disabled with no click action after clicking it
.assertHasNoClickAction()
.assertIsNotEnabled()
@@ -190,16 +190,16 @@
}
}
- findByTag(button1Tag)
- .doClick()
+ onNodeWithTag(button1Tag)
+ .performClick()
runOnIdleCompose {
assertThat(button1Counter).isEqualTo(1)
assertThat(button2Counter).isEqualTo(0)
}
- findByTag(button2Tag)
- .doClick()
+ onNodeWithTag(button2Tag)
+ .performClick()
runOnIdleCompose {
assertThat(button1Counter).isEqualTo(1)
@@ -220,7 +220,7 @@
}
}
- find(hasClickAction())
+ onNode(hasClickAction())
.assertHeightIsEqualTo(36.dp)
}
@@ -235,7 +235,7 @@
}
}
- find(hasClickAction())
+ onNode(hasClickAction())
.assertHeightIsAtLeast(37.dp)
}
@@ -303,7 +303,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -377,7 +377,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -410,7 +410,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -440,7 +440,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -467,7 +467,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -558,7 +558,7 @@
fun zOrderingBasedOnElevationIsApplied() {
composeTestRule.setMaterialContent {
Stack(
- Modifier.semantics(mergeAllDescendants = true)
+ Modifier.semantics(mergeAllDescendants = true) {}
.testTag("stack")
.preferredSize(10.dp, 10.dp)
) {
@@ -581,7 +581,7 @@
}
}
- findByTag("stack")
+ onNodeWithTag("stack")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -600,7 +600,7 @@
}
}
- findByTag("button")
+ onNodeWithTag("button")
.assertWidthIsEqualTo(20.dp)
.assertHeightIsEqualTo(15.dp)
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/CardTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/CardTest.kt
index 6c9e136..5f17c0a 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/CardTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/CardTest.kt
@@ -31,7 +31,7 @@
import androidx.ui.test.assertShape
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.unit.dp
import org.junit.Rule
import org.junit.Test
@@ -57,7 +57,7 @@
cardColor = MaterialTheme.colors.surface
Providers(ShapesAmbient provides Shapes(medium = shape)) {
Card(modifier = Modifier
- .semantics(mergeAllDescendants = true)
+ .semantics(mergeAllDescendants = true) {}
.testTag("card"),
elevation = 0.dp
) {
@@ -68,7 +68,7 @@
}
}
- findByTag("card")
+ onNodeWithTag("card")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxScreenshotTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxScreenshotTest.kt
index f10d795..2cda410 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxScreenshotTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxScreenshotTest.kt
@@ -23,7 +23,6 @@
import androidx.test.screenshot.assertAgainstGolden
import androidx.ui.core.Alignment
import androidx.ui.core.Modifier
-import androidx.ui.core.semantics.semantics
import androidx.ui.core.testTag
import androidx.ui.foundation.Box
import androidx.ui.foundation.selection.ToggleableState
@@ -31,12 +30,12 @@
import androidx.ui.test.captureToBitmap
import androidx.ui.test.center
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.doPartialGesture
-import androidx.ui.test.find
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.performPartialGesture
+import androidx.ui.test.onNode
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.isToggleable
-import androidx.ui.test.sendDown
+import androidx.ui.test.down
import androidx.ui.test.waitForIdle
import org.junit.Rule
import org.junit.Test
@@ -63,7 +62,7 @@
@Test
fun checkBoxTest_checked() {
composeTestRule.setMaterialContent {
- Box(wrap.semantics().testTag(wrapperTestTag)) {
+ Box(wrap.testTag(wrapperTestTag)) {
Checkbox(checked = true, onCheckedChange = { })
}
}
@@ -73,7 +72,7 @@
@Test
fun checkBoxTest_unchecked() {
composeTestRule.setMaterialContent {
- Box(wrap.semantics().testTag(wrapperTestTag)) {
+ Box(wrap.testTag(wrapperTestTag)) {
Checkbox(modifier = wrap, checked = false, onCheckedChange = { })
}
}
@@ -83,12 +82,12 @@
@Test
fun checkBoxTest_pressed() {
composeTestRule.setMaterialContent {
- Box(wrap.semantics().testTag(wrapperTestTag)) {
+ Box(wrap.testTag(wrapperTestTag)) {
Checkbox(modifier = wrap, checked = false, onCheckedChange = { })
}
}
- findByTag(wrapperTestTag).doPartialGesture {
- sendDown(center)
+ onNodeWithTag(wrapperTestTag).performPartialGesture {
+ down(center)
}
assertToggeableAgainstGolden("checkbox_pressed")
}
@@ -96,7 +95,7 @@
@Test
fun checkBoxTest_indeterminate() {
composeTestRule.setMaterialContent {
- Box(wrap.semantics().testTag(wrapperTestTag)) {
+ Box(wrap.testTag(wrapperTestTag)) {
TriStateCheckbox(
state = ToggleableState.Indeterminate,
modifier = wrap,
@@ -109,7 +108,7 @@
@Test
fun checkBoxTest_disabled_checked() {
composeTestRule.setMaterialContent {
- Box(wrap.semantics().testTag(wrapperTestTag)) {
+ Box(wrap.testTag(wrapperTestTag)) {
Checkbox(modifier = wrap, checked = true, enabled = false, onCheckedChange = { })
}
}
@@ -119,7 +118,7 @@
@Test
fun checkBoxTest_disabled_unchecked() {
composeTestRule.setMaterialContent {
- Box(wrap.semantics().testTag(wrapperTestTag)) {
+ Box(wrap.testTag(wrapperTestTag)) {
Checkbox(modifier = wrap, checked = false, enabled = false, onCheckedChange = { })
}
}
@@ -129,7 +128,7 @@
@Test
fun checkBoxTest_disabled_indeterminate() {
composeTestRule.setMaterialContent {
- Box(wrap.semantics().testTag(wrapperTestTag)) {
+ Box(wrap.testTag(wrapperTestTag)) {
TriStateCheckbox(
state = ToggleableState.Indeterminate,
enabled = false,
@@ -144,7 +143,7 @@
fun checkBoxTest_unchecked_animateToChecked() {
composeTestRule.setMaterialContent {
val isChecked = state { false }
- Box(wrap.semantics().testTag(wrapperTestTag)) {
+ Box(wrap.testTag(wrapperTestTag)) {
Checkbox(
modifier = wrap,
checked = isChecked.value,
@@ -155,8 +154,8 @@
composeTestRule.clockTestRule.pauseClock()
- find(isToggleable())
- .doClick()
+ onNode(isToggleable())
+ .performClick()
waitForIdle()
@@ -169,7 +168,7 @@
fun checkBoxTest_checked_animateToUnchecked() {
composeTestRule.setMaterialContent {
val isChecked = state { true }
- Box(wrap.semantics().testTag(wrapperTestTag)) {
+ Box(wrap.testTag(wrapperTestTag)) {
Checkbox(
modifier = wrap,
checked = isChecked.value,
@@ -180,8 +179,8 @@
composeTestRule.clockTestRule.pauseClock()
- find(isToggleable())
- .doClick()
+ onNode(isToggleable())
+ .performClick()
waitForIdle()
@@ -192,7 +191,7 @@
private fun assertToggeableAgainstGolden(goldenName: String) {
// TODO: replace with find(isToggeable()) after b/157687898 is fixed
- findByTag(wrapperTestTag)
+ onNodeWithTag(wrapperTestTag)
.captureToBitmap()
.assertAgainstGolden(screenshotRule, goldenName)
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxUiTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxUiTest.kt
index 41c052f..04ad106 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxUiTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxUiTest.kt
@@ -31,8 +31,8 @@
import androidx.ui.test.assertIsOn
import androidx.ui.test.assertValueEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.onNodeWithTag
import androidx.ui.unit.dp
import org.junit.Rule
import org.junit.Test
@@ -57,12 +57,12 @@
}
}
- findByTag("checkboxUnchecked")
+ onNodeWithTag("checkboxUnchecked")
.assertIsEnabled()
.assertIsOff()
.assertValueEquals(Strings.Unchecked)
- findByTag("checkboxChecked")
+ onNodeWithTag("checkboxChecked")
.assertIsEnabled()
.assertIsOn()
.assertValueEquals(Strings.Checked)
@@ -75,9 +75,9 @@
Checkbox(checked, onCheckedChange, modifier = Modifier.testTag(defaultTag))
}
- findByTag(defaultTag)
+ onNodeWithTag(defaultTag)
.assertIsOff()
- .doClick()
+ .performClick()
.assertIsOn()
}
@@ -88,11 +88,11 @@
Checkbox(checked, onCheckedChange, modifier = Modifier.testTag(defaultTag))
}
- findByTag(defaultTag)
+ onNodeWithTag(defaultTag)
.assertIsOff()
- .doClick()
+ .performClick()
.assertIsOn()
- .doClick()
+ .performClick()
.assertIsOff()
}
@@ -104,7 +104,7 @@
Checkbox(checked, {}, enabled = false, modifier = Modifier.testTag(defaultTag))
}
- findByTag(defaultTag)
+ onNodeWithTag(defaultTag)
.assertHasNoClickAction()
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerScreenshotTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerScreenshotTest.kt
index 5a21b05..e402322 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerScreenshotTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerScreenshotTest.kt
@@ -30,7 +30,7 @@
import androidx.ui.test.ComposeTestRule
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.unit.dp
import org.junit.Rule
import org.junit.Test
@@ -48,7 +48,7 @@
@get:Rule
val screenshotRule = AndroidXScreenshotTestRule(GOLDEN_MATERIAL)
- private fun ComposeTestRule.setBottomDrawer(drawerState: DrawerState) {
+ private fun ComposeTestRule.setBottomDrawer(drawerState: BottomDrawerState) {
setMaterialContent {
Box(Modifier.size(10.dp, 100.dp).testTag("container")) {
BottomDrawerLayout(
@@ -76,7 +76,7 @@
@Test
fun bottomDrawer_closed() {
- composeTestRule.setBottomDrawer(DrawerState.Closed)
+ composeTestRule.setBottomDrawer(BottomDrawerState.Closed)
assertScreenshotAgainstGolden("bottomDrawer_closed")
}
@@ -88,7 +88,7 @@
@Test
fun bottomDrawer_opened() {
- composeTestRule.setBottomDrawer(DrawerState.Opened)
+ composeTestRule.setBottomDrawer(BottomDrawerState.Opened)
assertScreenshotAgainstGolden("bottomDrawer_opened")
}
@@ -99,7 +99,7 @@
}
private fun assertScreenshotAgainstGolden(goldenName: String) {
- findByTag("container")
+ onNodeWithTag("container")
.captureToBitmap()
.assertAgainstGolden(screenshotRule, goldenName)
}
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 510382b..47c2ec9 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
@@ -31,21 +31,24 @@
import androidx.ui.graphics.Color
import androidx.ui.layout.fillMaxSize
import androidx.ui.layout.rtl
+import androidx.ui.test.GestureScope
import androidx.ui.test.assertIsEqualTo
import androidx.ui.test.assertLeftPositionInRootIsEqualTo
import androidx.ui.test.assertTopPositionInRootIsEqualTo
import androidx.ui.test.assertWidthIsEqualTo
+import androidx.ui.test.center
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.globalBounds
import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.runOnUiThread
-import androidx.ui.test.sendClick
-import androidx.ui.test.sendSwipeDown
-import androidx.ui.test.sendSwipeLeft
-import androidx.ui.test.sendSwipeRight
-import androidx.ui.test.sendSwipeUp
+import androidx.ui.test.click
+import androidx.ui.test.swipe
+import androidx.ui.test.swipeDown
+import androidx.ui.test.swipeLeft
+import androidx.ui.test.swipeRight
+import androidx.ui.test.swipeUp
import androidx.ui.unit.dp
import androidx.ui.unit.height
import androidx.ui.unit.width
@@ -74,7 +77,7 @@
}, bodyContent = emptyContent())
}
- findByTag("content")
+ onNodeWithTag("content")
.assertLeftPositionInRootIsEqualTo(0.dp)
}
@@ -103,14 +106,14 @@
}, bodyContent = emptyContent())
}
- findByTag("content")
+ onNodeWithTag("content")
.assertWidthIsEqualTo(rootWidth() - 56.dp)
}
@Test
fun bottomDrawer_testOffset_whenOpened() {
composeTestRule.setMaterialContent {
- BottomDrawerLayout(DrawerState.Opened, {}, drawerContent = {
+ BottomDrawerLayout(BottomDrawerState.Opened, {}, drawerContent = {
Box(Modifier.fillMaxSize().testTag("content"))
}, bodyContent = emptyContent())
}
@@ -118,7 +121,7 @@
val width = rootWidth()
val height = rootHeight()
val expectedHeight = if (width > height) 0.dp else (height / 2)
- findByTag("content")
+ onNodeWithTag("content")
.assertTopPositionInRootIsEqualTo(expectedHeight)
}
@@ -126,7 +129,7 @@
fun bottomDrawer_testOffset_whenClosed() {
var position: Offset? = null
composeTestRule.setMaterialContent {
- BottomDrawerLayout(DrawerState.Closed, {}, drawerContent = {
+ BottomDrawerLayout(BottomDrawerState.Closed, {}, drawerContent = {
Box(Modifier.fillMaxSize().onPositioned { coords: LayoutCoordinates ->
position = coords.localToRoot(Offset.Zero)
})
@@ -210,7 +213,7 @@
}
// Click in the middle of the drawer (which is the middle of the body)
- findByTag("Drawer").doGesture { sendClick() }
+ onNodeWithTag("Drawer").performGesture { click() }
runOnIdleCompose {
assertThat(drawerClicks).isEqualTo(0)
@@ -221,10 +224,10 @@
sleep(100) // TODO(147586311): remove this sleep when opening the drawer triggers a wait
// Click on the left-center pixel of the drawer
- findByTag("Drawer").doGesture {
+ onNodeWithTag("Drawer").performGesture {
val left = 1.0f
val centerY = (globalBounds.height / 2)
- sendClick(Offset(left, centerY))
+ click(Offset(left, centerY))
}
runOnIdleCompose {
@@ -240,7 +243,7 @@
var openedHeight: Int? = null
var openedLatch: CountDownLatch? = null
var closedLatch: CountDownLatch? = CountDownLatch(1)
- val drawerState = mutableStateOf(DrawerState.Closed)
+ val drawerState = mutableStateOf(BottomDrawerState.Closed)
composeTestRule.setMaterialContent {
BottomDrawerLayout(drawerState.value, { drawerState.value = it },
drawerContent = {
@@ -269,7 +272,7 @@
// When the drawer state is set to Opened
openedLatch = CountDownLatch(1)
runOnIdleCompose {
- drawerState.value = DrawerState.Opened
+ drawerState.value = BottomDrawerState.Opened
}
// Then the drawer should be opened
assertThat(openedLatch.await(5, TimeUnit.SECONDS)).isTrue()
@@ -277,7 +280,7 @@
// When the drawer state is set to Closed
closedLatch = CountDownLatch(1)
runOnIdleCompose {
- drawerState.value = DrawerState.Closed
+ drawerState.value = BottomDrawerState.Closed
}
// Then the drawer should be closed
assertThat(closedLatch.await(5, TimeUnit.SECONDS)).isTrue()
@@ -287,7 +290,7 @@
fun bottomDrawer_bodyContent_clickable() {
var drawerClicks = 0
var bodyClicks = 0
- val drawerState = mutableStateOf(DrawerState.Closed)
+ val drawerState = mutableStateOf(BottomDrawerState.Closed)
composeTestRule.setMaterialContent {
// emulate click on the screen
BottomDrawerLayout(drawerState.value, { drawerState.value = it },
@@ -306,7 +309,7 @@
}
// Click in the middle of the drawer (which is the middle of the body)
- findByTag("Drawer").doGesture { sendClick() }
+ onNodeWithTag("Drawer").performGesture { click() }
runOnIdleCompose {
assertThat(drawerClicks).isEqualTo(0)
@@ -314,16 +317,16 @@
}
runOnUiThread {
- drawerState.value = DrawerState.Opened
+ drawerState.value = BottomDrawerState.Opened
}
sleep(100) // TODO(147586311): remove this sleep when opening the drawer triggers a wait
// Click on the bottom-center pixel of the drawer
- findByTag("Drawer").doGesture {
+ onNodeWithTag("Drawer").performGesture {
val bounds = globalBounds
val centerX = bounds.width / 2
val bottom = bounds.height - 1.0f
- sendClick(Offset(centerX, bottom))
+ click(Offset(centerX, bottom))
}
assertThat(drawerClicks).isEqualTo(1)
@@ -346,15 +349,15 @@
}
}
- findByTag("Drawer")
- .doGesture { sendSwipeRight() }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeRight() }
runOnIdleCompose {
assertThat(drawerState.value).isEqualTo(DrawerState.Opened)
}
- findByTag("Drawer")
- .doGesture { sendSwipeLeft() }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeLeft() }
runOnIdleCompose {
assertThat(drawerState.value).isEqualTo(DrawerState.Closed)
@@ -377,15 +380,15 @@
}
}
- findByTag("Drawer")
- .doGesture { sendSwipeLeft() }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeLeft() }
runOnIdleCompose {
assertThat(drawerState.value).isEqualTo(DrawerState.Opened)
}
- findByTag("Drawer")
- .doGesture { sendSwipeRight() }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeRight() }
runOnIdleCompose {
assertThat(drawerState.value).isEqualTo(DrawerState.Closed)
@@ -394,7 +397,7 @@
@Test
fun bottomDrawer_openBySwipe() {
- val drawerState = mutableStateOf(DrawerState.Closed)
+ val drawerState = mutableStateOf(BottomDrawerState.Closed)
composeTestRule.setMaterialContent {
// emulate click on the screen
Box(Modifier.testTag("Drawer")) {
@@ -408,18 +411,100 @@
}
}
- findByTag("Drawer")
- .doGesture { sendSwipeUp() }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeUp() }
runOnIdleCompose {
- assertThat(drawerState.value).isEqualTo(DrawerState.Opened)
+ assertThat(drawerState.value).isEqualTo(BottomDrawerState.Expanded)
}
- findByTag("Drawer")
- .doGesture { sendSwipeDown() }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeDown() }
runOnIdleCompose {
- assertThat(drawerState.value).isEqualTo(DrawerState.Closed)
+ assertThat(drawerState.value).isEqualTo(BottomDrawerState.Closed)
}
}
+
+ @Test
+ fun bottomDrawer_openBySwipe_thresholds() {
+ val drawerState = mutableStateOf(BottomDrawerState.Closed)
+ composeTestRule.setMaterialContent {
+ // emulate click on the screen
+ Box(Modifier.testTag("Drawer")) {
+ BottomDrawerLayout(drawerState.value, { drawerState.value = it },
+ drawerContent = {
+ Box(Modifier.fillMaxSize().drawBackground(Color.Magenta))
+ },
+ bodyContent = {
+ Box(Modifier.fillMaxSize().drawBackground(Color.Red))
+ })
+ }
+ }
+ val threshold = with (composeTestRule.density) { BottomDrawerThreshold.toPx() }
+
+ onNodeWithTag("Drawer")
+ .performGesture { swipeUpBy(threshold / 2) }
+
+ runOnIdleCompose {
+ assertThat(drawerState.value).isEqualTo(BottomDrawerState.Closed)
+ }
+
+ onNodeWithTag("Drawer")
+ .performGesture { swipeUpBy(threshold) }
+
+ runOnIdleCompose {
+ assertThat(drawerState.value).isEqualTo(BottomDrawerState.Opened)
+ }
+
+ onNodeWithTag("Drawer")
+ .performGesture { swipeUpBy(threshold / 2) }
+
+ runOnIdleCompose {
+ assertThat(drawerState.value).isEqualTo(BottomDrawerState.Opened)
+ }
+
+ onNodeWithTag("Drawer")
+ .performGesture { swipeUpBy(threshold) }
+
+ runOnIdleCompose {
+ assertThat(drawerState.value).isEqualTo(BottomDrawerState.Expanded)
+ }
+
+ onNodeWithTag("Drawer")
+ .performGesture { swipeDownBy(threshold / 2) }
+
+ runOnIdleCompose {
+ assertThat(drawerState.value).isEqualTo(BottomDrawerState.Expanded)
+ }
+
+ onNodeWithTag("Drawer")
+ .performGesture { swipeDownBy(threshold) }
+
+ runOnIdleCompose {
+ assertThat(drawerState.value).isEqualTo(BottomDrawerState.Opened)
+ }
+
+ onNodeWithTag("Drawer")
+ .performGesture { swipeDownBy(threshold / 2) }
+
+ runOnIdleCompose {
+ assertThat(drawerState.value).isEqualTo(BottomDrawerState.Opened)
+ }
+
+ onNodeWithTag("Drawer")
+ .performGesture { swipeDownBy(threshold) }
+
+ runOnIdleCompose {
+ assertThat(drawerState.value).isEqualTo(BottomDrawerState.Closed)
+ }
+ }
+
+ private fun GestureScope.swipeUpBy(offset: Float) {
+ swipe(center, center.copy(y = center.y - offset))
+ }
+
+ private fun GestureScope.swipeDownBy(offset: Float) {
+ swipe(center, center.copy(y = center.y + offset))
+ }
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ElevationOverlayTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ElevationOverlayTest.kt
index 203aec8..e04243b 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ElevationOverlayTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ElevationOverlayTest.kt
@@ -27,7 +27,7 @@
import androidx.ui.test.assertPixels
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.unit.Dp
import androidx.ui.unit.IntSize
import androidx.ui.unit.dp
@@ -70,7 +70,7 @@
fun correctElevationOverlayInDarkTheme() {
setupSurfaceForTesting(elevation!!, darkColorPalette())
- findByTag(Tag)
+ onNodeWithTag(Tag)
.captureToBitmap()
.assertPixels(SurfaceSize) {
expectedOverlayColor
@@ -84,7 +84,7 @@
// No overlay should be applied in light theme
val expectedSurfaceColor = Color.White
- findByTag(Tag)
+ onNodeWithTag(Tag)
.captureToBitmap()
.assertPixels(SurfaceSize) {
expectedSurfaceColor
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/FloatingActionButtonTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/FloatingActionButtonTest.kt
index 99fcc38..75a32e6 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/FloatingActionButtonTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/FloatingActionButtonTest.kt
@@ -41,9 +41,9 @@
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.findByTag
-import androidx.ui.test.findByText
+import androidx.ui.test.performClick
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onNodeWithText
import androidx.ui.test.runOnIdleCompose
import androidx.ui.unit.center
import androidx.ui.unit.dp
@@ -72,7 +72,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.assertIsEnabled()
}
@@ -88,8 +88,8 @@
}
}
- findByText(text)
- .doClick()
+ onNodeWithText(text)
+ .performClick()
runOnIdleCompose {
assertThat(counter).isEqualTo(1)
@@ -118,7 +118,7 @@
)
}
- findByTag("FAB")
+ onNodeWithTag("FAB")
.assertHeightIsEqualTo(48.dp)
.assertWidthIsAtLeast(48.dp)
}
@@ -133,7 +133,7 @@
)
}
- findByTag("FAB")
+ onNodeWithTag("FAB")
.assertWidthIsEqualTo(48.dp)
.assertHeightIsEqualTo(48.dp)
}
@@ -161,7 +161,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -194,7 +194,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/IconButtonTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/IconButtonTest.kt
index 60256a7..84ace1d 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/IconButtonTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/IconButtonTest.kt
@@ -30,9 +30,9 @@
import androidx.ui.test.assertTopPositionInRootIsEqualTo
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.find
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.onNode
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.isToggleable
import androidx.ui.unit.dp
import org.junit.Rule
@@ -76,7 +76,7 @@
}
// Icon should be centered inside the IconButton
- findByTag("icon", useUnmergedTree = true)
+ onNodeWithTag("icon", useUnmergedTree = true)
.assertLeftPositionInRootIsEqualTo(24.dp / 2)
.assertTopPositionInRootIsEqualTo(24.dp / 2)
}
@@ -97,7 +97,7 @@
}
// Icon should be centered inside the IconButton
- findByTag("icon", useUnmergedTree = true)
+ onNodeWithTag("icon", useUnmergedTree = true)
.assertLeftPositionInRootIsEqualTo((48.dp - width) / 2)
.assertTopPositionInRootIsEqualTo((48.dp - height) / 2)
}
@@ -129,7 +129,7 @@
}
// Icon should be centered inside the IconButton
- findByTag("icon", useUnmergedTree = true)
+ onNodeWithTag("icon", useUnmergedTree = true)
.assertLeftPositionInRootIsEqualTo(24.dp / 2)
.assertTopPositionInRootIsEqualTo(24.dp / 2)
}
@@ -149,7 +149,7 @@
}
// Icon should be centered inside the IconButton
- findByTag("icon", useUnmergedTree = true)
+ onNodeWithTag("icon", useUnmergedTree = true)
.assertLeftPositionInRootIsEqualTo((48.dp - width) / 2)
.assertTopPositionInRootIsEqualTo((48.dp - height) / 2)
}
@@ -159,9 +159,9 @@
composeTestRule.setMaterialContent {
IconToggleButtonSample()
}
- find(isToggleable()).apply {
+ onNode(isToggleable()).apply {
assertIsOff()
- doClick()
+ performClick()
assertIsOn()
}
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/MaterialTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/MaterialTest.kt
index b9cf4aa..64d21ff 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/MaterialTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/MaterialTest.kt
@@ -29,8 +29,8 @@
import androidx.ui.test.assertHeightIsEqualTo
import androidx.ui.test.assertIsEqualTo
import androidx.ui.test.assertWidthIsEqualTo
-import androidx.ui.test.findByTag
-import androidx.ui.test.findRoot
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onRoot
import androidx.ui.test.getAlignmentLinePosition
import androidx.ui.test.runOnIdleCompose
import androidx.ui.text.FirstBaseline
@@ -77,7 +77,7 @@
}
fun rootWidth(): Dp {
- val nodeInteraction = findRoot()
+ val nodeInteraction = onRoot()
val node = nodeInteraction.fetchSemanticsNode("Failed to get screen width")
@OptIn(ExperimentalLayoutNodeApi::class)
val owner = node.componentNode.owner as AndroidOwner
@@ -88,7 +88,7 @@
}
fun rootHeight(): Dp {
- val nodeInteraction = findRoot()
+ val nodeInteraction = onRoot()
val node = nodeInteraction.fetchSemanticsNode("Failed to get screen height")
@OptIn(ExperimentalLayoutNodeApi::class)
val owner = node.componentNode.owner as AndroidOwner
@@ -121,5 +121,5 @@
}
}
- return findByTag("containerForSizeAssertion")
+ return onNodeWithTag("containerForSizeAssertion")
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt
index ffbe7fd..7af020c 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt
@@ -34,10 +34,10 @@
import androidx.ui.layout.preferredSize
import androidx.ui.layout.size
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.find
-import androidx.ui.test.findByTag
-import androidx.ui.test.hasAnyDescendantThat
+import androidx.ui.test.performClick
+import androidx.ui.test.onNode
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.hasAnyDescendant
import androidx.ui.test.hasTestTag
import androidx.ui.test.isPopup
import androidx.ui.test.runOnIdleCompose
@@ -78,22 +78,22 @@
}
}
}
- findByTag("MenuContent").assertDoesNotExist()
+ onNodeWithTag("MenuContent").assertDoesNotExist()
runOnIdleCompose { expanded = true }
waitForIdle()
composeTestRule.clockTestRule.advanceClock(InTransitionDuration.toLong())
- findByTag("MenuContent").assertExists()
+ onNodeWithTag("MenuContent").assertExists()
runOnIdleCompose { expanded = false }
waitForIdle()
composeTestRule.clockTestRule.advanceClock(OutTransitionDuration.toLong())
- findByTag("MenuContent").assertDoesNotExist()
+ onNodeWithTag("MenuContent").assertDoesNotExist()
runOnIdleCompose { expanded = true }
waitForIdle()
composeTestRule.clockTestRule.advanceClock(InTransitionDuration.toLong())
- findByTag("MenuContent").assertExists()
+ onNodeWithTag("MenuContent").assertExists()
}
@Test
@@ -113,11 +113,11 @@
}
}
- findByTag("MenuContent1").assertExists()
- findByTag("MenuContent2").assertExists()
- val node = find(
- isPopup() and hasAnyDescendantThat(hasTestTag("MenuContent1")) and
- hasAnyDescendantThat(hasTestTag("MenuContent2"))
+ onNodeWithTag("MenuContent1").assertExists()
+ onNodeWithTag("MenuContent2").assertExists()
+ val node = onNode(
+ isPopup() and hasAnyDescendant(hasTestTag("MenuContent1")) and
+ hasAnyDescendant(hasTestTag("MenuContent2"))
).assertExists().fetchSemanticsNode()
with(composeTestRule.density) {
assertThat(node.size.width).isEqualTo(130 + MenuElevationInset.toIntPx() * 2)
@@ -316,7 +316,7 @@
}
}
- findByTag("MenuItem").doClick()
+ onNodeWithTag("MenuItem").performClick()
runOnIdleCompose {
assertThat(clicked).isTrue()
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ProgressIndicatorTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ProgressIndicatorTest.kt
index 095ad0e..d000aff 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ProgressIndicatorTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ProgressIndicatorTest.kt
@@ -27,7 +27,7 @@
import androidx.ui.test.assertValueEquals
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnUiThread
import androidx.ui.unit.dp
import org.junit.Ignore
@@ -56,7 +56,7 @@
LinearProgressIndicator(modifier = Modifier.testTag(tag), progress = progress.value)
}
- findByTag(tag)
+ onNodeWithTag(tag)
.assertIsDisplayed()
.assertValueEquals("0 percent")
.assertRangeInfoEquals(AccessibilityRangeInfo(0f, 0f..1f))
@@ -65,7 +65,7 @@
progress.value = 0.5f
}
- findByTag(tag)
+ onNodeWithTag(tag)
.assertIsDisplayed()
.assertValueEquals("50 percent")
.assertRangeInfoEquals(AccessibilityRangeInfo(0.5f, 0f..1f))
@@ -91,7 +91,7 @@
LinearProgressIndicator(modifier = Modifier.testTag(tag))
}
- findByTag(tag)
+ onNodeWithTag(tag)
.assertValueEquals(Strings.InProgress)
}
@@ -119,7 +119,7 @@
)
}
- findByTag(tag)
+ onNodeWithTag(tag)
.assertIsDisplayed()
.assertValueEquals("0 percent")
.assertRangeInfoEquals(AccessibilityRangeInfo(0f, 0f..1f))
@@ -128,7 +128,7 @@
progress.value = 0.5f
}
- findByTag(tag)
+ onNodeWithTag(tag)
.assertIsDisplayed()
.assertValueEquals("50 percent")
.assertRangeInfoEquals(AccessibilityRangeInfo(0.5f, 0f..1f))
@@ -153,7 +153,7 @@
CircularProgressIndicator(modifier = Modifier.testTag(tag))
}
- findByTag(tag)
+ onNodeWithTag(tag)
.assertValueEquals(Strings.InProgress)
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonScreenshotTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonScreenshotTest.kt
index 104ae67..d774c3f 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonScreenshotTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonScreenshotTest.kt
@@ -24,19 +24,18 @@
import androidx.test.screenshot.assertAgainstGolden
import androidx.ui.core.Alignment
import androidx.ui.core.Modifier
-import androidx.ui.core.semantics.semantics
import androidx.ui.core.testTag
import androidx.ui.foundation.Box
import androidx.ui.layout.wrapContentSize
import androidx.ui.test.captureToBitmap
import androidx.ui.test.center
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.doPartialGesture
-import androidx.ui.test.find
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.performPartialGesture
+import androidx.ui.test.onNode
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.isInMutuallyExclusiveGroup
-import androidx.ui.test.sendDown
+import androidx.ui.test.down
import androidx.ui.test.waitForIdle
import org.junit.Rule
import org.junit.Test
@@ -63,7 +62,7 @@
@Test
fun radioButtonTest_selected() {
composeTestRule.setMaterialContent {
- Box(wrap.semantics().testTag(wrapperTestTag)) {
+ Box(wrap.testTag(wrapperTestTag)) {
RadioButton(selected = true, onClick = {})
}
}
@@ -73,7 +72,7 @@
@Test
fun radioButtonTest_notSelected() {
composeTestRule.setMaterialContent {
- Box(wrap.semantics().testTag(wrapperTestTag)) {
+ Box(wrap.testTag(wrapperTestTag)) {
RadioButton(selected = false, onClick = {})
}
}
@@ -83,12 +82,12 @@
@Test
fun radioButtonTest_pressed() {
composeTestRule.setMaterialContent {
- Box(wrap.semantics().testTag(wrapperTestTag)) {
+ Box(wrap.testTag(wrapperTestTag)) {
RadioButton(selected = false, onClick = {})
}
}
- findByTag(wrapperTestTag).doPartialGesture {
- sendDown(center)
+ onNodeWithTag(wrapperTestTag).performPartialGesture {
+ down(center)
}
assertSelectableAgainstGolden("radioButton_pressed")
}
@@ -96,7 +95,7 @@
@Test
fun radioButtonTest_disabled_selected() {
composeTestRule.setMaterialContent {
- Box(wrap.semantics().testTag(wrapperTestTag)) {
+ Box(wrap.testTag(wrapperTestTag)) {
RadioButton(selected = true, onClick = {}, enabled = false)
}
}
@@ -106,7 +105,7 @@
@Test
fun radioButtonTest_disabled_notSelected() {
composeTestRule.setMaterialContent {
- Box(wrap.semantics().testTag(wrapperTestTag)) {
+ Box(wrap.testTag(wrapperTestTag)) {
RadioButton(selected = false, onClick = {}, enabled = false)
}
}
@@ -117,7 +116,7 @@
fun radioButton_notSelected_animateToSelected() {
composeTestRule.setMaterialContent {
val isSelected = state { false }
- Box(wrap.semantics().testTag(wrapperTestTag)) {
+ Box(wrap.testTag(wrapperTestTag)) {
RadioButton(
selected = isSelected.value,
onClick = { isSelected.value = !isSelected.value }
@@ -127,8 +126,8 @@
composeTestRule.clockTestRule.pauseClock()
- find(isInMutuallyExclusiveGroup())
- .doClick()
+ onNode(isInMutuallyExclusiveGroup())
+ .performClick()
waitForIdle()
@@ -141,7 +140,7 @@
fun radioButton_selected_animateToNotSelected() {
composeTestRule.setMaterialContent {
val isSelected = state { true }
- Box(wrap.semantics().testTag(wrapperTestTag)) {
+ Box(wrap.testTag(wrapperTestTag)) {
RadioButton(
selected = isSelected.value,
onClick = { isSelected.value = !isSelected.value }
@@ -151,8 +150,8 @@
composeTestRule.clockTestRule.pauseClock()
- find(isInMutuallyExclusiveGroup())
- .doClick()
+ onNode(isInMutuallyExclusiveGroup())
+ .performClick()
waitForIdle()
@@ -163,7 +162,7 @@
private fun assertSelectableAgainstGolden(goldenName: String) {
// TODO: replace with find(isInMutuallyExclusiveGroup()) after b/157687898 is fixed
- findByTag(wrapperTestTag)
+ onNodeWithTag(wrapperTestTag)
.captureToBitmap()
.assertAgainstGolden(screenshotRule, goldenName)
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonTest.kt
index cd48273..0f5f167 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonTest.kt
@@ -28,8 +28,8 @@
import androidx.ui.test.assertIsUnselected
import androidx.ui.test.assertValueEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.onNodeWithTag
import androidx.ui.unit.dp
import org.junit.Rule
import org.junit.Test
@@ -75,9 +75,9 @@
}
}
- findByTag(itemOne).assertHasSelectedSemantics()
- findByTag(itemTwo).assertHasUnSelectedSemantics()
- findByTag(itemThree).assertHasUnSelectedSemantics()
+ onNodeWithTag(itemOne).assertHasSelectedSemantics()
+ onNodeWithTag(itemTwo).assertHasUnSelectedSemantics()
+ onNodeWithTag(itemThree).assertHasUnSelectedSemantics()
}
@Test
@@ -96,15 +96,15 @@
}
}
- findByTag(itemOne)
+ onNodeWithTag(itemOne)
.assertHasSelectedSemantics()
- .doClick()
+ .performClick()
.assertHasSelectedSemantics()
- findByTag(itemTwo)
+ onNodeWithTag(itemTwo)
.assertHasUnSelectedSemantics()
- findByTag(itemThree)
+ onNodeWithTag(itemThree)
.assertHasUnSelectedSemantics()
}
@@ -122,15 +122,15 @@
}
}
}
- findByTag(itemTwo)
+ onNodeWithTag(itemTwo)
.assertHasUnSelectedSemantics()
- .doClick()
+ .performClick()
.assertHasSelectedSemantics()
- findByTag(itemOne)
+ onNodeWithTag(itemOne)
.assertHasUnSelectedSemantics()
- findByTag(itemThree)
+ onNodeWithTag(itemThree)
.assertHasUnSelectedSemantics()
}
@@ -150,23 +150,23 @@
}
}
- findByTag(itemTwo)
+ onNodeWithTag(itemTwo)
.assertHasUnSelectedSemantics()
- .doClick()
+ .performClick()
.assertHasSelectedSemantics()
- findByTag(itemOne)
+ onNodeWithTag(itemOne)
.assertHasUnSelectedSemantics()
- findByTag(itemThree)
+ onNodeWithTag(itemThree)
.assertHasUnSelectedSemantics()
- .doClick()
+ .performClick()
.assertHasSelectedSemantics()
- findByTag(itemOne)
+ onNodeWithTag(itemOne)
.assertHasUnSelectedSemantics()
- findByTag(itemTwo)
+ onNodeWithTag(itemTwo)
.assertHasUnSelectedSemantics()
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
index 3c55c35..764f4f7 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
@@ -46,12 +46,12 @@
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.runOnUiThread
-import androidx.ui.test.sendSwipeLeft
-import androidx.ui.test.sendSwipeRight
+import androidx.ui.test.swipeLeft
+import androidx.ui.test.swipeRight
import androidx.ui.unit.IntSize
import androidx.ui.unit.dp
import androidx.ui.unit.toSize
@@ -200,12 +200,12 @@
}
}
assertThat(drawerChildPosition.x).isLessThan(0f)
- findByTag(scaffoldTag).doGesture {
- sendSwipeRight()
+ onNodeWithTag(scaffoldTag).performGesture {
+ swipeRight()
}
assertThat(drawerChildPosition.x).isLessThan(0f)
- findByTag(scaffoldTag).doGesture {
- sendSwipeLeft()
+ onNodeWithTag(scaffoldTag).performGesture {
+ swipeLeft()
}
assertThat(drawerChildPosition.x).isLessThan(0f)
@@ -213,12 +213,12 @@
scaffoldState.isDrawerGesturesEnabled = true
}
- findByTag(scaffoldTag).doGesture {
- sendSwipeRight()
+ onNodeWithTag(scaffoldTag).performGesture {
+ swipeRight()
}
assertThat(drawerChildPosition.x).isEqualTo(0f)
- findByTag(scaffoldTag).doGesture {
- sendSwipeLeft()
+ onNodeWithTag(scaffoldTag).performGesture {
+ swipeLeft()
}
assertThat(drawerChildPosition.x).isLessThan(0f)
}
@@ -347,7 +347,7 @@
Stack(
Modifier
.size(10.dp, 20.dp)
- .semantics(mergeAllDescendants = true)
+ .semantics(mergeAllDescendants = true) {}
.testTag("Scaffold")
) {
Scaffold(
@@ -367,7 +367,7 @@
}
}
- findByTag("Scaffold")
+ onNodeWithTag("Scaffold")
.captureToBitmap().apply {
// asserts the appbar(top half part) has the shadow
val yPos = height / 2 + 2
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SliderTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/SliderTest.kt
index 4fc7d44..732e0ea 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/SliderTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/SliderTest.kt
@@ -39,15 +39,15 @@
import androidx.ui.test.centerX
import androidx.ui.test.centerY
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doPartialGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performPartialGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.left
import androidx.ui.test.right
import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.runOnUiThread
-import androidx.ui.test.sendDown
-import androidx.ui.test.sendMoveBy
-import androidx.ui.test.sendUp
+import androidx.ui.test.down
+import androidx.ui.test.moveBy
+import androidx.ui.test.up
import androidx.ui.unit.dp
import com.google.common.truth.Truth
import org.junit.Assert.assertEquals
@@ -83,11 +83,11 @@
runOnIdleCompose {
state.value = 2f
}
- findByTag(tag).assertValueEquals("100 percent")
+ onNodeWithTag(tag).assertValueEquals("100 percent")
runOnIdleCompose {
state.value = -123145f
}
- findByTag(tag).assertValueEquals("0 percent")
+ onNodeWithTag(tag).assertValueEquals("0 percent")
}
@Test(expected = IllegalArgumentException::class)
@@ -107,14 +107,14 @@
onValueChange = { state.value = it })
}
- findByTag(tag)
+ onNodeWithTag(tag)
.assertValueEquals("0 percent")
runOnUiThread {
state.value = 0.5f
}
- findByTag(tag)
+ onNodeWithTag(tag)
.assertValueEquals("50 percent")
}
@@ -137,11 +137,11 @@
var expected = 0f
- findByTag(tag)
- .doPartialGesture {
- sendDown(center)
- sendMoveBy(Offset(100f, 0f))
- sendUp()
+ onNodeWithTag(tag)
+ .performPartialGesture {
+ down(center)
+ moveBy(Offset(100f, 0f))
+ up()
expected = calculateFraction(left, right, centerX + 100)
}
runOnIdleCompose {
@@ -168,10 +168,10 @@
var expected = 0f
- findByTag(tag)
- .doPartialGesture {
- sendDown(Offset(centerX + 50, centerY))
- sendUp()
+ onNodeWithTag(tag)
+ .performPartialGesture {
+ down(Offset(centerX + 50, centerY))
+ up()
expected = calculateFraction(left, right, centerX + 50)
}
runOnIdleCompose {
@@ -198,11 +198,11 @@
var expected = 0f
- findByTag(tag)
- .doPartialGesture {
- sendDown(center)
- sendMoveBy(Offset(100f, 0f))
- sendUp()
+ onNodeWithTag(tag)
+ .performPartialGesture {
+ down(center)
+ moveBy(Offset(100f, 0f))
+ up()
// subtract here as we're in rtl and going in the opposite direction
expected = calculateFraction(left, right, centerX - 100)
}
@@ -230,10 +230,10 @@
var expected = 0f
- findByTag(tag)
- .doPartialGesture {
- sendDown(Offset(centerX + 50, centerY))
- sendUp()
+ onNodeWithTag(tag)
+ .performPartialGesture {
+ down(Offset(centerX + 50, centerY))
+ up()
expected = calculateFraction(left, right, centerX - 50)
}
runOnIdleCompose {
@@ -273,7 +273,7 @@
)
}
- findByTag(sliderTag).captureToBitmap().apply {
+ onNodeWithTag(sliderTag).captureToBitmap().apply {
assertNotEquals(0, thumbStrokeWidth)
assertNotEquals(0, thumbPx)
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt
index d91be77..3d17c81 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt
@@ -37,9 +37,9 @@
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.findByTag
-import androidx.ui.test.findByText
+import androidx.ui.test.performClick
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onNodeWithText
import androidx.ui.test.getAlignmentLinePosition
import androidx.ui.test.getBoundsInRoot
import androidx.ui.text.FirstBaseline
@@ -77,13 +77,13 @@
}
}
- findByText("Message")
+ onNodeWithText("Message")
.assertExists()
assertThat(clicked).isFalse()
- findByText("UNDO")
- .doClick()
+ onNodeWithText("UNDO")
+ .performClick()
assertThat(clicked).isTrue()
}
@@ -102,13 +102,13 @@
.assertWidthIsEqualTo(300.dp)
.assertHeightIsEqualTo(48.dp)
- val firstBaseLine = findByText("Message").getAlignmentLinePosition(FirstBaseline)
- val lastBaseLine = findByText("Message").getAlignmentLinePosition(LastBaseline)
+ val firstBaseLine = onNodeWithText("Message").getAlignmentLinePosition(FirstBaseline)
+ val lastBaseLine = onNodeWithText("Message").getAlignmentLinePosition(LastBaseline)
firstBaseLine.assertIsNotEqualTo(0.dp, "first baseline")
firstBaseLine.assertIsEqualTo(lastBaseLine, "first baseline")
val snackBounds = snackbar.getBoundsInRoot()
- val textBounds = findByText("Message").getBoundsInRoot()
+ val textBounds = onNodeWithText("Message").getBoundsInRoot()
val textTopOffset = textBounds.top - snackBounds.top
val textBottomOffset = textBounds.top - snackBounds.top
@@ -129,13 +129,13 @@
}
.assertWidthIsEqualTo(300.dp)
- val firstBaseLine = findByText("Message").getAlignmentLinePosition(FirstBaseline)
- val lastBaseLine = findByText("Message").getAlignmentLinePosition(LastBaseline)
+ val firstBaseLine = onNodeWithText("Message").getAlignmentLinePosition(FirstBaseline)
+ val lastBaseLine = onNodeWithText("Message").getAlignmentLinePosition(LastBaseline)
firstBaseLine.assertIsNotEqualTo(0.dp, "first baseline")
firstBaseLine.assertIsEqualTo(lastBaseLine, "first baseline")
val snackBounds = snackbar.getBoundsInRoot()
- val textBounds = findByText("Message").getBoundsInRoot()
+ val textBounds = onNodeWithText("Message").getBoundsInRoot()
val textTopOffset = textBounds.top - snackBounds.top
val textBottomOffset = textBounds.top - snackBounds.top
@@ -165,14 +165,14 @@
.assertWidthIsEqualTo(300.dp)
.assertHeightIsEqualTo(48.dp)
- val textBaseLine = findByText("Message").getAlignmentLinePosition(FirstBaseline)
- val buttonBaseLine = findByTag("button").getAlignmentLinePosition(FirstBaseline)
+ val textBaseLine = onNodeWithText("Message").getAlignmentLinePosition(FirstBaseline)
+ val buttonBaseLine = onNodeWithTag("button").getAlignmentLinePosition(FirstBaseline)
textBaseLine.assertIsNotEqualTo(0.dp, "text baseline")
buttonBaseLine.assertIsNotEqualTo(0.dp, "button baseline")
val snackBounds = snackbar.getBoundsInRoot()
- val textBounds = findByText("Message").getBoundsInRoot()
- val buttonBounds = findByText("Undo").getBoundsInRoot()
+ val textBounds = onNodeWithText("Message").getBoundsInRoot()
+ val buttonBounds = onNodeWithText("Undo").getBoundsInRoot()
val buttonTopOffset = buttonBounds.top - snackBounds.top
val textTopOffset = textBounds.top - snackBounds.top
@@ -203,14 +203,14 @@
)
}
- val textBaseLine = findByText("Message").getAlignmentLinePosition(FirstBaseline)
- val buttonBaseLine = findByTag("button").getAlignmentLinePosition(FirstBaseline)
+ val textBaseLine = onNodeWithText("Message").getAlignmentLinePosition(FirstBaseline)
+ val buttonBaseLine = onNodeWithTag("button").getAlignmentLinePosition(FirstBaseline)
textBaseLine.assertIsNotEqualTo(0.dp, "text baseline")
buttonBaseLine.assertIsNotEqualTo(0.dp, "button baseline")
val snackBounds = snackbar.getBoundsInRoot()
- val textBounds = findByText("Message").getBoundsInRoot()
- val buttonBounds = findByText("Undo").getBoundsInRoot()
+ val textBounds = onNodeWithText("Message").getBoundsInRoot()
+ val buttonBounds = onNodeWithText("Undo").getBoundsInRoot()
val buttonTopOffset = buttonBounds.top - snackBounds.top
val textTopOffset = textBounds.top - snackBounds.top
@@ -234,15 +234,15 @@
.assertWidthIsEqualTo(300.dp)
.assertHeightIsEqualTo(68.dp)
- val firstBaseline = findByTag("text").getFirstBaselinePosition()
- val lastBaseline = findByTag("text").getLastBaselinePosition()
+ val firstBaseline = onNodeWithTag("text").getFirstBaselinePosition()
+ val lastBaseline = onNodeWithTag("text").getLastBaselinePosition()
firstBaseline.assertIsNotEqualTo(0.dp, "first baseline")
lastBaseline.assertIsNotEqualTo(0.dp, "last baseline")
firstBaseline.assertIsNotEqualTo(lastBaseline, "first baseline")
val snackBounds = snackbar.getBoundsInRoot()
- val textBounds = findByTag("text").getBoundsInRoot()
+ val textBounds = onNodeWithTag("text").getBoundsInRoot()
val textTopOffset = textBounds.top - snackBounds.top
val textBottomOffset = textBounds.top - snackBounds.top
@@ -272,17 +272,17 @@
.assertWidthIsEqualTo(300.dp)
.assertHeightIsEqualTo(68.dp)
- val textFirstBaseLine = findByTag("text").getFirstBaselinePosition()
- val textLastBaseLine = findByTag("text").getLastBaselinePosition()
+ val textFirstBaseLine = onNodeWithTag("text").getFirstBaselinePosition()
+ val textLastBaseLine = onNodeWithTag("text").getLastBaselinePosition()
textFirstBaseLine.assertIsNotEqualTo(0.dp, "first baseline")
textLastBaseLine.assertIsNotEqualTo(0.dp, "last baseline")
textFirstBaseLine.assertIsNotEqualTo(textLastBaseLine, "first baseline")
- findByTag("text")
+ onNodeWithTag("text")
.assertTopPositionInRootIsEqualTo(30.dp - textFirstBaseLine)
- val buttonBounds = findByTag("button").getBoundsInRoot()
+ val buttonBounds = onNodeWithTag("button").getBoundsInRoot()
val snackBounds = snackbar.getBoundsInRoot()
val buttonCenter = buttonBounds.top + (buttonBounds.height / 2)
@@ -310,15 +310,15 @@
)
}
- val textFirstBaseLine = findByText("Message").getFirstBaselinePosition()
- val textLastBaseLine = findByText("Message").getLastBaselinePosition()
- val textBounds = findByText("Message").getBoundsInRoot()
- val buttonBounds = findByTag("button").getBoundsInRoot()
+ val textFirstBaseLine = onNodeWithText("Message").getFirstBaselinePosition()
+ val textLastBaseLine = onNodeWithText("Message").getLastBaselinePosition()
+ val textBounds = onNodeWithText("Message").getBoundsInRoot()
+ val buttonBounds = onNodeWithTag("button").getBoundsInRoot()
- findByText("Message")
+ onNodeWithText("Message")
.assertTopPositionInRootIsEqualTo(30.dp - textFirstBaseLine)
- findByTag("button")
+ onNodeWithTag("button")
.assertTopPositionInRootIsEqualTo(18.dp + textBounds.top + textLastBaseLine)
snackbar
@@ -341,7 +341,7 @@
.compositeOver(background)
Providers(ShapesAmbient provides Shapes(medium = shape)) {
Snackbar(modifier = Modifier
- .semantics(mergeAllDescendants = true)
+ .semantics(mergeAllDescendants = true) {}
.testTag("snackbar"),
text = { Text("") }
)
@@ -349,7 +349,7 @@
}
}
- findByTag("snackbar")
+ onNodeWithTag("snackbar")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceTest.kt
index 22af85e..f10e94b 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceTest.kt
@@ -33,7 +33,7 @@
import androidx.ui.test.assertShape
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.unit.dp
import org.junit.Rule
import org.junit.Test
@@ -53,7 +53,7 @@
composeTestRule.setMaterialContent {
Stack(Modifier
.preferredSize(10.dp, 10.dp)
- .semantics(mergeAllDescendants = true)
+ .semantics(mergeAllDescendants = true) {}
.testTag("stack")) {
Surface(color = Color.Yellow, elevation = 2.dp) {
Box(Modifier.fillMaxSize())
@@ -64,7 +64,7 @@
}
}
- findByTag("stack")
+ onNodeWithTag("stack")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -80,7 +80,7 @@
composeTestRule.setMaterialContent {
Stack(Modifier
.preferredSize(10.dp, 10.dp)
- .semantics(mergeAllDescendants = true)
+ .semantics(mergeAllDescendants = true) {}
.testTag("stack")) {
Surface(color = Color.Yellow) {
Box(Modifier.fillMaxSize())
@@ -91,7 +91,7 @@
}
}
- findByTag("stack")
+ onNodeWithTag("stack")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -107,7 +107,7 @@
composeTestRule.setMaterialContent {
Stack(Modifier
.preferredSize(10.dp, 10.dp)
- .semantics(mergeAllDescendants = true)
+ .semantics(mergeAllDescendants = true) {}
.testTag("stack")) {
Box(Modifier.fillMaxSize().drawBackground(Color.Green).zIndex(3f))
Surface(color = Color.Yellow, elevation = 2.dp) {
@@ -116,7 +116,7 @@
}
}
- findByTag("stack")
+ onNodeWithTag("stack")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -132,7 +132,7 @@
composeTestRule.setMaterialContent {
Stack(Modifier
.preferredSize(10.dp, 10.dp)
- .semantics(mergeAllDescendants = true)
+ .semantics(mergeAllDescendants = true) {}
.testTag("stack")) {
Box(Modifier.fillMaxSize().drawBackground(Color.Green).zIndex(1f))
Surface(color = Color.Yellow, elevation = 2.dp) {
@@ -141,7 +141,7 @@
}
}
- findByTag("stack")
+ onNodeWithTag("stack")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchScreenshotTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchScreenshotTest.kt
index 2170258..17401b2 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchScreenshotTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchScreenshotTest.kt
@@ -32,12 +32,12 @@
import androidx.ui.test.captureToBitmap
import androidx.ui.test.center
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.doPartialGesture
-import androidx.ui.test.find
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.performPartialGesture
+import androidx.ui.test.onNode
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.isToggleable
-import androidx.ui.test.sendDown
+import androidx.ui.test.down
import androidx.ui.test.waitForIdle
import org.junit.Rule
import org.junit.Test
@@ -121,8 +121,8 @@
}
}
- findByTag(wrapperTestTag).doPartialGesture {
- sendDown(center)
+ onNodeWithTag(wrapperTestTag).performPartialGesture {
+ down(center)
}
assertToggeableAgainstGolden("switch_pressed")
}
@@ -161,8 +161,8 @@
composeTestRule.clockTestRule.pauseClock()
- find(isToggleable())
- .doClick()
+ onNode(isToggleable())
+ .performClick()
waitForIdle()
@@ -185,8 +185,8 @@
composeTestRule.clockTestRule.pauseClock()
- find(isToggleable())
- .doClick()
+ onNode(isToggleable())
+ .performClick()
waitForIdle()
@@ -197,7 +197,7 @@
private fun assertToggeableAgainstGolden(goldenName: String) {
// TODO: replace with find(isToggeable()) after b/157687898 is fixed
- findByTag(wrapperTestTag)
+ onNodeWithTag(wrapperTestTag)
.captureToBitmap()
.assertAgainstGolden(screenshotRule, goldenName)
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchTest.kt
index 19f3247..0419d2b 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchTest.kt
@@ -33,12 +33,12 @@
import androidx.ui.test.assertValueEquals
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendSwipeLeft
-import androidx.ui.test.sendSwipeRight
+import androidx.ui.test.swipeLeft
+import androidx.ui.test.swipeRight
import androidx.ui.unit.dp
import com.google.common.truth.Truth
import org.junit.Rule
@@ -68,11 +68,11 @@
}
}
- findByTag("checked")
+ onNodeWithTag("checked")
.assertIsEnabled()
.assertIsOn()
.assertValueEquals(Strings.Checked)
- findByTag("unchecked")
+ onNodeWithTag("unchecked")
.assertIsEnabled()
.assertIsOff()
.assertValueEquals(Strings.Unchecked)
@@ -92,9 +92,9 @@
)
}
}
- findByTag(defaultSwitchTag)
+ onNodeWithTag(defaultSwitchTag)
.assertIsOff()
- .doClick()
+ .performClick()
.assertIsOn()
}
@@ -112,11 +112,11 @@
)
}
}
- findByTag(defaultSwitchTag)
+ onNodeWithTag(defaultSwitchTag)
.assertIsOff()
- .doClick()
+ .performClick()
.assertIsOn()
- .doClick()
+ .performClick()
.assertIsOff()
}
@@ -131,7 +131,7 @@
enabled = false
)
}
- findByTag(defaultSwitchTag)
+ onNodeWithTag(defaultSwitchTag)
.assertHasNoClickAction()
}
@@ -160,15 +160,15 @@
}
}
- findByTag(defaultSwitchTag)
- .doGesture { sendSwipeRight() }
+ onNodeWithTag(defaultSwitchTag)
+ .performGesture { swipeRight() }
runOnIdleCompose {
Truth.assertThat(state.value).isEqualTo(true)
}
- findByTag(defaultSwitchTag)
- .doGesture { sendSwipeLeft() }
+ onNodeWithTag(defaultSwitchTag)
+ .performGesture { swipeLeft() }
runOnIdleCompose {
Truth.assertThat(state.value).isEqualTo(false)
@@ -190,15 +190,15 @@
}
}
- findByTag(defaultSwitchTag)
- .doGesture { sendSwipeLeft() }
+ onNodeWithTag(defaultSwitchTag)
+ .performGesture { swipeLeft() }
runOnIdleCompose {
Truth.assertThat(state.value).isEqualTo(true)
}
- findByTag(defaultSwitchTag)
- .doGesture { sendSwipeRight() }
+ onNodeWithTag(defaultSwitchTag)
+ .performGesture { swipeRight() }
runOnIdleCompose {
Truth.assertThat(state.value).isEqualTo(false)
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt
index 27958ae..be7c851 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt
@@ -40,9 +40,9 @@
import androidx.ui.test.assertIsUnselected
import androidx.ui.test.assertPositionInRootIsEqualTo
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.findAll
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.onAllNodes
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.getBoundsInRoot
import androidx.ui.test.isInMutuallyExclusiveGroup
import androidx.ui.unit.dp
@@ -133,20 +133,20 @@
}
}
- val tabRowBounds = findByTag("tabRow").getBoundsInRoot()
+ val tabRowBounds = onNodeWithTag("tabRow").getBoundsInRoot()
- findByTag("indicator")
+ onNodeWithTag("indicator")
.assertPositionInRootIsEqualTo(
expectedLeft = 0.dp,
expectedTop = tabRowBounds.height - indicatorHeight
)
// Click the second tab
- findAll(isInMutuallyExclusiveGroup())[1].doClick()
+ onAllNodes(isInMutuallyExclusiveGroup())[1].performClick()
// Indicator should now be placed in the bottom left of the second tab, so its x coordinate
// should be in the middle of the TabRow
- findByTag("indicator")
+ onNodeWithTag("indicator")
.assertPositionInRootIsEqualTo(
expectedLeft = (tabRowBounds.width / 2),
expectedTop = tabRowBounds.height - indicatorHeight
@@ -180,9 +180,9 @@
val indicatorHeight = 2.dp
val expectedBaselineDistance = expectedBaseline + indicatorHeight
- val tabRowBounds = findByTag("tabRow").getBoundsInRoot()
- val textBounds = findByTag("text").getBoundsInRoot()
- val textBaselinePos = findByTag("text").getLastBaselinePosition()
+ val tabRowBounds = onNodeWithTag("tabRow").getBoundsInRoot()
+ val textBounds = onNodeWithTag("text").getBoundsInRoot()
+ val textBaselinePos = onNodeWithTag("text").getLastBaselinePosition()
val baselinePositionY = textBounds.top + textBaselinePos
val expectedPositionY = tabRowBounds.height - expectedBaselineDistance
@@ -217,9 +217,9 @@
val indicatorHeight = 2.dp
val expectedBaselineDistance = expectedBaseline + indicatorHeight
- val tabRowBounds = findByTag("tabRow").getBoundsInRoot()
- val textBounds = findByTag("text").getBoundsInRoot()
- val textBaselinePos = findByTag("text").getLastBaselinePosition()
+ val tabRowBounds = onNodeWithTag("tabRow").getBoundsInRoot()
+ val textBounds = onNodeWithTag("text").getBoundsInRoot()
+ val textBaselinePos = onNodeWithTag("text").getLastBaselinePosition()
val baselinePositionY = textBounds.top + textBaselinePos
val expectedPositionY = tabRowBounds.height - expectedBaselineDistance
@@ -252,9 +252,9 @@
val expectedBaseline = 10.dp
val indicatorHeight = 2.dp
- val tabRowBounds = findByTag("tabRow").getBoundsInRoot()
- val textBounds = findByTag("text").getBoundsInRoot()
- val textBaselinePos = findByTag("text").getLastBaselinePosition()
+ val tabRowBounds = onNodeWithTag("tabRow").getBoundsInRoot()
+ val textBounds = onNodeWithTag("text").getBoundsInRoot()
+ val textBaselinePos = onNodeWithTag("text").getLastBaselinePosition()
val expectedBaselineDistance = expectedBaseline + indicatorHeight
@@ -301,10 +301,10 @@
}
}
- val tabRowBounds = findByTag("tabRow").getBoundsInRoot()
+ val tabRowBounds = onNodeWithTag("tabRow").getBoundsInRoot()
// Indicator should be placed in the bottom left of the first tab
- findByTag("indicator")
+ onNodeWithTag("indicator")
.assertPositionInRootIsEqualTo(
// Tabs in a scrollable tab row are offset 52.dp from each end
expectedLeft = scrollableTabRowOffset,
@@ -312,11 +312,11 @@
)
// Click the second tab
- findAll(isInMutuallyExclusiveGroup())[1].doClick()
+ onAllNodes(isInMutuallyExclusiveGroup())[1].performClick()
// Indicator should now be placed in the bottom left of the second tab, so its x coordinate
// should be in the middle of the TabRow
- findByTag("indicator")
+ onNodeWithTag("indicator")
.assertPositionInRootIsEqualTo(
expectedLeft = scrollableTabRowOffset + minimumTabWidth,
expectedTop = tabRowBounds.height - indicatorHeight
@@ -331,7 +331,7 @@
}
// Only the first tab should be selected
- findAll(isInMutuallyExclusiveGroup())
+ onAllNodes(isInMutuallyExclusiveGroup())
.assertCountEquals(3)
.apply {
get(0).assertIsSelected()
@@ -348,7 +348,7 @@
}
// Only the first tab should be selected
- findAll(isInMutuallyExclusiveGroup())
+ onAllNodes(isInMutuallyExclusiveGroup())
.assertCountEquals(3)
.apply {
get(0).assertIsSelected()
@@ -357,10 +357,10 @@
}
// Click the last tab
- findAll(isInMutuallyExclusiveGroup())[2].doClick()
+ onAllNodes(isInMutuallyExclusiveGroup())[2].performClick()
// Now only the last tab should be selected
- findAll(isInMutuallyExclusiveGroup())
+ onAllNodes(isInMutuallyExclusiveGroup())
.assertCountEquals(3)
.apply {
get(0).assertIsUnselected()
@@ -377,7 +377,7 @@
}
// Only the first tab should be selected
- findAll(isInMutuallyExclusiveGroup())
+ onAllNodes(isInMutuallyExclusiveGroup())
.assertCountEquals(10)
.apply {
get(0).assertIsSelected()
@@ -395,7 +395,7 @@
}
// Only the first tab should be selected
- findAll(isInMutuallyExclusiveGroup())
+ onAllNodes(isInMutuallyExclusiveGroup())
.assertCountEquals(10)
.apply {
get(0).assertIsSelected()
@@ -405,10 +405,10 @@
}
// Click the second tab
- findAll(isInMutuallyExclusiveGroup())[1].doClick()
+ onAllNodes(isInMutuallyExclusiveGroup())[1].performClick()
// Now only the second tab should be selected
- findAll(isInMutuallyExclusiveGroup())
+ onAllNodes(isInMutuallyExclusiveGroup())
.assertCountEquals(10)
.apply {
get(0).assertIsUnselected()
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ripple/RippleIndicationTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ripple/RippleIndicationTest.kt
index d52810d..770953b 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ripple/RippleIndicationTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ripple/RippleIndicationTest.kt
@@ -51,7 +51,7 @@
import androidx.ui.test.ComposeTestRule
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnUiThread
import androidx.ui.test.waitForIdle
import androidx.ui.unit.dp
@@ -529,7 +529,7 @@
interactionState.addInteraction(Interaction.Pressed, Offset(10f, 10f))
}
- with(findByTag(Tag)) {
+ with(onNodeWithTag(Tag)) {
val centerPixel = captureToBitmap()
.run {
getPixel(width / 2, height / 2)
@@ -548,7 +548,7 @@
rippleTheme = createRippleTheme(newColor, newAlpha)
}
- with(findByTag(Tag)) {
+ with(onNodeWithTag(Tag)) {
val centerPixel = captureToBitmap()
.run {
getPixel(width / 2, height / 2)
@@ -594,7 +594,7 @@
composeTestRule.clockTestRule.advanceClock(50)
// Capture and compare screenshots
- findByTag(Tag)
+ onNodeWithTag(Tag)
.captureToBitmap()
.assertAgainstGolden(screenshotRule, goldenIdentifier)
@@ -604,7 +604,7 @@
waitForIdle()
// Compare expected and actual pixel color
- val centerPixel = findByTag(Tag)
+ val centerPixel = onNodeWithTag(Tag)
.captureToBitmap()
.run {
getPixel(width / 2, height / 2)
@@ -623,7 +623,7 @@
*/
@Composable
private fun RippleBox(interactionState: InteractionState, rippleIndication: RippleIndication) {
- Box(Modifier.semantics(mergeAllDescendants = true).testTag(Tag)) {
+ Box(Modifier.semantics(mergeAllDescendants = true) {}.testTag(Tag)) {
Surface(
Modifier.padding(25.dp),
color = RippleBoxBackgroundColor, shape = RoundedCornerShape(20)
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/FilledTextFieldTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/FilledTextFieldTest.kt
index ad0d24d..85ad37b 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/FilledTextFieldTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/FilledTextFieldTest.kt
@@ -55,12 +55,12 @@
import androidx.ui.test.assertShape
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.doGesture
-import androidx.ui.test.doSendImeAction
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendClick
+import androidx.ui.test.click
+import androidx.ui.test.performImeAction
import androidx.ui.test.waitForIdle
import androidx.ui.text.FirstBaseline
import androidx.ui.text.SoftwareKeyboardController
@@ -136,14 +136,14 @@
}
}
- findByTag(textField1Tag).doClick()
+ onNodeWithTag(textField1Tag).performClick()
runOnIdleCompose {
assertThat(textField1Focused).isTrue()
assertThat(textField2Focused).isFalse()
}
- findByTag(textField2Tag).doClick()
+ onNodeWithTag(textField2Tag).performClick()
runOnIdleCompose {
assertThat(textField1Focused).isFalse()
@@ -167,8 +167,8 @@
}
// Click on (2, 2) which is Surface area and outside input area
- findByTag(TextfieldTag).doGesture {
- sendClick(Offset(2f, 2f))
+ onNodeWithTag(TextfieldTag).performGesture {
+ click(Offset(2f, 2f))
}
testRule.runOnIdleComposeWithDensity {
@@ -465,7 +465,7 @@
}
// click to focus
- findByTag(TextfieldTag).doClick()
+ onNodeWithTag(TextfieldTag).performClick()
}
@Test
@@ -677,7 +677,7 @@
)
}
- findByTag(TextfieldTag)
+ onNodeWithTag(TextfieldTag)
.captureToBitmap()
.assertShape(
density = testRule.density,
@@ -714,7 +714,7 @@
val expectedColor = Color.Blue.copy(alpha = 0.12f).compositeOver(Color.White)
- findByTag(TextfieldTag)
+ onNodeWithTag(TextfieldTag)
.captureToBitmap()
.assertShape(
density = testRule.density,
@@ -725,10 +725,10 @@
shapeOverlapPixelCount = with(testRule.density) { 1.dp.toPx() }
)
- findByTag(TextfieldTag).doClick()
+ onNodeWithTag(TextfieldTag).performClick()
assert(latch.await(1, TimeUnit.SECONDS))
- findByTag(TextfieldTag)
+ onNodeWithTag(TextfieldTag)
.captureToBitmap()
.assertShape(
density = testRule.density,
@@ -757,8 +757,8 @@
}
assertThat(controller).isNull()
- findByTag(TextfieldTag)
- .doClick()
+ onNodeWithTag(TextfieldTag)
+ .performClick()
runOnIdleCompose {
assertThat(controller).isNotNull()
@@ -783,8 +783,8 @@
}
assertThat(controller).isNull()
- findByTag(TextfieldTag)
- .doSendImeAction()
+ onNodeWithTag(TextfieldTag)
+ .performImeAction()
runOnIdleCompose {
assertThat(controller).isNotNull()
@@ -792,7 +792,7 @@
}
private fun clickAndAdvanceClock(tag: String, time: Long) {
- findByTag(tag).doClick()
+ onNodeWithTag(tag).performClick()
waitForIdle()
testRule.clockTestRule.pauseClock()
testRule.clockTestRule.advanceClock(time)
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/OutlinedTextFieldTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/OutlinedTextFieldTest.kt
index b728ad7..6137d4c 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/OutlinedTextFieldTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/OutlinedTextFieldTest.kt
@@ -50,12 +50,12 @@
import androidx.ui.test.assertShape
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.doGesture
-import androidx.ui.test.doSendImeAction
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendClick
+import androidx.ui.test.click
+import androidx.ui.test.performImeAction
import androidx.ui.test.waitForIdle
import androidx.ui.text.SoftwareKeyboardController
import androidx.ui.unit.IntSize
@@ -112,14 +112,14 @@
}
}
- findByTag(textField1Tag).doClick()
+ onNodeWithTag(textField1Tag).performClick()
runOnIdleCompose {
assertThat(textField1Focused).isTrue()
assertThat(textField2Focused).isFalse()
}
- findByTag(textField2Tag).doClick()
+ onNodeWithTag(textField2Tag).performClick()
runOnIdleCompose {
assertThat(textField1Focused).isFalse()
@@ -143,8 +143,8 @@
}
// Click on (2, 2) which is a background area and outside input area
- findByTag(TextfieldTag).doGesture {
- sendClick(Offset(2f, 2f))
+ onNodeWithTag(TextfieldTag).performGesture {
+ click(Offset(2f, 2f))
}
testRule.runOnIdleComposeWithDensity {
@@ -388,7 +388,7 @@
}
// click to focus
- findByTag(TextfieldTag).doClick()
+ onNodeWithTag(TextfieldTag).performClick()
}
@Test
@@ -593,7 +593,7 @@
}
}
- findByTag(TextfieldTag)
+ onNodeWithTag(TextfieldTag)
.captureToBitmap()
.assertShape(
density = testRule.density,
@@ -622,8 +622,8 @@
}
assertThat(controller).isNull()
- findByTag(TextfieldTag)
- .doClick()
+ onNodeWithTag(TextfieldTag)
+ .performClick()
runOnIdleCompose {
assertThat(controller).isNotNull()
@@ -648,8 +648,8 @@
}
assertThat(controller).isNull()
- findByTag(TextfieldTag)
- .doSendImeAction()
+ onNodeWithTag(TextfieldTag)
+ .performImeAction()
runOnIdleCompose {
assertThat(controller).isNotNull()
@@ -657,7 +657,7 @@
}
private fun clickAndAdvanceClock(tag: String, time: Long) {
- findByTag(tag).doClick()
+ onNodeWithTag(tag).performClick()
waitForIdle()
testRule.clockTestRule.pauseClock()
testRule.clockTestRule.advanceClock(time)
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldScreenshotTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldScreenshotTest.kt
index 38893bc..7389518 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldScreenshotTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldScreenshotTest.kt
@@ -33,8 +33,8 @@
import androidx.ui.material.setMaterialContent
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.performClick
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -56,7 +56,7 @@
@Test
fun outlinedTextField_withInput() {
composeTestRule.setMaterialContent {
- Box(Modifier.semantics(mergeAllDescendants = true).testTag(TextFieldTag)) {
+ Box(Modifier.semantics(mergeAllDescendants = true) {}.testTag(TextFieldTag)) {
OutlinedTextField(
value = "Text",
onValueChange = {},
@@ -71,7 +71,7 @@
@Test
fun outlinedTextField_notFocused() {
composeTestRule.setMaterialContent {
- Box(Modifier.semantics(mergeAllDescendants = true).testTag(TextFieldTag)) {
+ Box(Modifier.semantics(mergeAllDescendants = true) {}.testTag(TextFieldTag)) {
OutlinedTextField(
value = "",
onValueChange = {},
@@ -86,7 +86,7 @@
@Test
fun outlinedTextField_focused() {
composeTestRule.setMaterialContent {
- Box(Modifier.semantics(mergeAllDescendants = true).testTag(TextFieldTag)) {
+ Box(Modifier.semantics(mergeAllDescendants = true) {}.testTag(TextFieldTag)) {
OutlinedTextField(
value = "",
onValueChange = {},
@@ -95,8 +95,8 @@
}
}
- findByTag(TextFieldTag)
- .doClick()
+ onNodeWithTag(TextFieldTag)
+ .performClick()
assertAgainstGolden("outlined_textField_focused")
}
@@ -104,7 +104,7 @@
@Test
fun outlinedTextField_focused_rtl() {
composeTestRule.setMaterialContent {
- Box(Modifier.semantics(mergeAllDescendants = true).testTag(TextFieldTag).rtl) {
+ Box(Modifier.semantics(mergeAllDescendants = true) {}.testTag(TextFieldTag).rtl) {
OutlinedTextField(
value = "",
onValueChange = {},
@@ -113,8 +113,8 @@
}
}
- findByTag(TextFieldTag)
- .doClick()
+ onNodeWithTag(TextFieldTag)
+ .performClick()
assertAgainstGolden("outlined_textField_focused_rtl")
}
@@ -122,7 +122,7 @@
@Test
fun filledTextField_withInput() {
composeTestRule.setMaterialContent {
- Box(Modifier.semantics(mergeAllDescendants = true).testTag(TextFieldTag)) {
+ Box(Modifier.semantics(mergeAllDescendants = true) {}.testTag(TextFieldTag)) {
FilledTextField(
value = "Text",
onValueChange = {},
@@ -137,7 +137,7 @@
@Test
fun filledTextField_notFocused() {
composeTestRule.setMaterialContent {
- Box(Modifier.semantics(mergeAllDescendants = true).testTag(TextFieldTag)) {
+ Box(Modifier.semantics(mergeAllDescendants = true) {}.testTag(TextFieldTag)) {
FilledTextField(
value = "",
onValueChange = {},
@@ -152,7 +152,7 @@
@Test
fun filledTextField_focused() {
composeTestRule.setMaterialContent {
- Box(Modifier.semantics(mergeAllDescendants = true).testTag(TextFieldTag)) {
+ Box(Modifier.semantics(mergeAllDescendants = true) {}.testTag(TextFieldTag)) {
FilledTextField(
value = "",
onValueChange = {},
@@ -161,8 +161,8 @@
}
}
- findByTag(TextFieldTag)
- .doClick()
+ onNodeWithTag(TextFieldTag)
+ .performClick()
assertAgainstGolden("filled_textField_focused")
}
@@ -170,7 +170,7 @@
@Test
fun filledTextField_focused_rtl() {
composeTestRule.setMaterialContent {
- Box(Modifier.semantics(mergeAllDescendants = true).testTag(TextFieldTag).rtl) {
+ Box(Modifier.semantics(mergeAllDescendants = true) {}.testTag(TextFieldTag).rtl) {
FilledTextField(
value = "",
onValueChange = {},
@@ -179,14 +179,14 @@
}
}
- findByTag(TextFieldTag)
- .doClick()
+ onNodeWithTag(TextFieldTag)
+ .performClick()
assertAgainstGolden("filled_textField_focused_rtl")
}
private fun assertAgainstGolden(goldenIdentifier: String) {
- findByTag(TextFieldTag)
+ onNodeWithTag(TextFieldTag)
.captureToBitmap()
.assertAgainstGolden(screenshotRule, goldenIdentifier)
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldTest.kt
index 0e9c6a5..7283d7e 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldTest.kt
@@ -35,11 +35,11 @@
import androidx.ui.test.assertPixels
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendSwipeDown
-import androidx.ui.test.sendSwipeUp
+import androidx.ui.test.swipeDown
+import androidx.ui.test.swipeUp
import androidx.ui.unit.IntSize
import androidx.ui.unit.dp
import com.google.common.truth.Truth.assertThat
@@ -140,7 +140,7 @@
runOnIdleCompose {}
- findByTag(TextfieldTag)
+ onNodeWithTag(TextfieldTag)
.captureToBitmap()
.assertPixels(expectedSize = IntSize(parentSize, parentSize)) { position ->
if (position.x > textFieldSize && position.y > textFieldSize) Color.White else null
@@ -169,16 +169,16 @@
assertThat(scrollerPosition.current).isEqualTo(0f)
}
- findByTag(TextfieldTag)
- .doGesture { sendSwipeDown() }
+ onNodeWithTag(TextfieldTag)
+ .performGesture { swipeDown() }
val firstSwipePosition = runOnIdleCompose {
scrollerPosition.current
}
assertThat(firstSwipePosition).isGreaterThan(0f)
- findByTag(TextfieldTag)
- .doGesture { sendSwipeUp() }
+ onNodeWithTag(TextfieldTag)
+ .performGesture { swipeUp() }
runOnIdleCompose {
assertThat(scrollerPosition.current).isLessThan(firstSwipePosition)
}
@@ -206,8 +206,8 @@
}
}
- findByTag(TextfieldTag)
- .doGesture { sendSwipeDown() }
+ onNodeWithTag(TextfieldTag)
+ .performGesture { swipeDown() }
val swipePosition = runOnIdleCompose {
scrollerPosition.current
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/AppBar.kt b/ui/ui-material/src/main/java/androidx/ui/material/AppBar.kt
index 7d8312c..5fd57c9 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/AppBar.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/AppBar.kt
@@ -17,7 +17,6 @@
import androidx.compose.Composable
import androidx.ui.core.Modifier
-import androidx.ui.core.semantics.semantics
import androidx.ui.foundation.ContentGravity
import androidx.ui.foundation.ProvideTextStyle
import androidx.ui.foundation.shape.corner.CircleShape
@@ -93,7 +92,7 @@
}
Row(
- Modifier.fillMaxHeight().weight(1f).semantics(),
+ Modifier.fillMaxHeight().weight(1f),
verticalGravity = ContentGravity.CenterVertically
) {
ProvideTextStyle(value = MaterialTheme.typography.h6) {
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Drawer.kt b/ui/ui-material/src/main/java/androidx/ui/material/Drawer.kt
index 2f4b01c..7b9d87e 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/Drawer.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/Drawer.kt
@@ -35,13 +35,14 @@
import androidx.ui.layout.offsetPx
import androidx.ui.layout.padding
import androidx.ui.layout.preferredSizeIn
+import androidx.ui.material.internal.fixedThresholds
import androidx.ui.material.internal.stateDraggable
import androidx.ui.unit.Dp
import androidx.ui.unit.dp
import androidx.ui.util.lerp
/**
- * Possible states of the drawer
+ * Possible states of the [ModalDrawerLayout]
*/
enum class DrawerState {
/**
@@ -51,8 +52,25 @@
/**
* Constant to indicate the state of the drawer when it's opened
*/
+ Opened
+}
+
+/**
+ * Possible states of the [BottomDrawerLayout]
+ */
+enum class BottomDrawerState {
+ /**
+ * Constant to indicate the state of the bottom drawer when it's closed
+ */
+ Closed,
+ /**
+ * Constant to indicate the state of the bottom drawer when it's opened
+ */
Opened,
- // Expanded
+ /**
+ * Constant to indicate the state of the bottom drawer when it's fully expanded
+ */
+ Expanded
}
/**
@@ -117,9 +135,11 @@
Stack {
bodyContent()
}
- Scrim(drawerState, onStateChange, fraction = {
- calculateFraction(minValue, maxValue, drawerPosition.value)
- })
+ Scrim(
+ opened = drawerState == DrawerState.Opened,
+ onClose = { onStateChange(DrawerState.Closed) },
+ fraction = { calculateFraction(minValue, maxValue, drawerPosition.value) }
+ )
DrawerContent(
drawerPosition, dpConstraints, drawerShape, drawerElevation, drawerContent
)
@@ -155,8 +175,8 @@
*/
@Composable
fun BottomDrawerLayout(
- drawerState: DrawerState,
- onStateChange: (DrawerState) -> Unit,
+ drawerState: BottomDrawerState,
+ onStateChange: (BottomDrawerState) -> Unit,
gesturesEnabled: Boolean = true,
drawerShape: Shape = MaterialTheme.shapes.large,
drawerElevation: Dp = DrawerConstants.DefaultElevation,
@@ -183,20 +203,25 @@
)
val anchors =
if (isLandscape) {
- listOf(maxValue to DrawerState.Closed, minValue to DrawerState.Opened)
+ listOf(
+ maxValue to BottomDrawerState.Closed,
+ minValue to BottomDrawerState.Opened
+ )
} else {
listOf(
- maxValue to DrawerState.Closed,
- openedValue to DrawerState.Opened,
- minValue to DrawerState.Opened
+ maxValue to BottomDrawerState.Closed,
+ openedValue to BottomDrawerState.Opened,
+ minValue to BottomDrawerState.Expanded
)
}
val drawerPosition = state { maxValue }
+ val offset = with(DensityAmbient.current) { BottomDrawerThreshold.toPx() }
Stack(
Modifier.stateDraggable(
state = drawerState,
onStateChange = onStateChange,
anchorsToState = anchors,
+ thresholds = fixedThresholds(offset),
animationSpec = AnimationSpec,
dragDirection = DragDirection.Vertical,
minValue = minValue,
@@ -208,10 +233,14 @@
Stack {
bodyContent()
}
- Scrim(drawerState, onStateChange, fraction = {
- // as we scroll "from height to 0" , need to reverse fraction
- 1 - calculateFraction(openedValue, maxValue, drawerPosition.value)
- })
+ Scrim(
+ opened = drawerState == BottomDrawerState.Opened,
+ onClose = { onStateChange(BottomDrawerState.Closed) },
+ fraction = {
+ // as we scroll "from height to 0" , need to reverse fraction
+ 1 - calculateFraction(openedValue, maxValue, drawerPosition.value)
+ }
+ )
BottomDrawerContent(
drawerPosition, dpConstraints, drawerShape, drawerElevation, drawerContent
)
@@ -275,13 +304,13 @@
@Composable
private fun Scrim(
- state: DrawerState,
- onStateChange: (DrawerState) -> Unit,
+ opened: Boolean,
+ onClose: () -> Unit,
fraction: () -> Float
) {
val color = MaterialTheme.colors.onSurface
- val dismissDrawer = if (state == DrawerState.Opened) {
- Modifier.tapGestureFilter { _ -> onStateChange(DrawerState.Closed) }
+ val dismissDrawer = if (opened) {
+ Modifier.tapGestureFilter { onClose() }
} else {
Modifier
}
@@ -303,3 +332,4 @@
private val AnimationSpec = SpringSpec<Float>(stiffness = DrawerStiffness)
internal const val BottomDrawerOpenFraction = 0.5f
+internal val BottomDrawerThreshold = 56.dp
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/TextFieldImpl.kt b/ui/ui-material/src/main/java/androidx/ui/material/TextFieldImpl.kt
index c4de0f0..ec83e8e 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/TextFieldImpl.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/TextFieldImpl.kt
@@ -48,7 +48,6 @@
import androidx.ui.core.focus.FocusState
import androidx.ui.core.focus.focusState
import androidx.ui.core.offset
-import androidx.ui.core.semantics.semantics
import androidx.ui.foundation.ContentColorAmbient
import androidx.ui.foundation.ProvideTextStyle
import androidx.ui.foundation.TextField
@@ -166,7 +165,6 @@
}
val textFieldModifier = modifier
- .semantics(mergeAllDescendants = true)
.clickable(indication = RippleIndication(bounded = false)) {
focusModifier.requestFocus()
keyboardController.value?.showSoftwareKeyboard()
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/internal/StateDraggable.kt b/ui/ui-material/src/main/java/androidx/ui/material/internal/StateDraggable.kt
index ebe8b9f..8f6f731 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/internal/StateDraggable.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/internal/StateDraggable.kt
@@ -20,7 +20,10 @@
import androidx.animation.AnimationClockObservable
import androidx.animation.AnimationEndReason
import androidx.animation.AnimationSpec
+import androidx.animation.ExponentialDecay
import androidx.animation.Spring
+import androidx.animation.TargetAnimation
+import androidx.annotation.FloatRange
import androidx.compose.onCommit
import androidx.compose.remember
import androidx.compose.state
@@ -29,11 +32,13 @@
import androidx.ui.core.Modifier
import androidx.ui.core.composed
import androidx.ui.foundation.InteractionState
-import androidx.ui.foundation.animation.AnchorsFlingConfig
+import androidx.ui.foundation.animation.FlingConfig
import androidx.ui.foundation.animation.fling
import androidx.ui.foundation.gestures.DragDirection
import androidx.ui.foundation.gestures.draggable
import androidx.ui.util.fastFirstOrNull
+import androidx.ui.util.lerp
+import kotlin.math.sign
/**
* Enable automatic drag and animation between predefined states.
@@ -57,6 +62,9 @@
* @param animationSpec animation which will be used for animations
* @param dragDirection direction in which drag should be happening.
* Either [DragDirection.Vertical] or [DragDirection.Horizontal]
+ * @param thresholds the thresholds between anchors that determine which anchor to fling to when
+ * dragging stops, represented as a lambda that takes a pair of anchors and returns a value
+ * between them (note that the order of the anchors matters as it indicates the drag direction)
* @param enabled whether or not this Draggable is enabled and should consume events
* @param minValue lower bound for draggable value in this component
* @param maxValue upper bound for draggable value in this component
@@ -69,6 +77,7 @@
anchorsToState: List<Pair<Float, T>>,
animationSpec: AnimationSpec<Float>,
dragDirection: DragDirection,
+ thresholds: (Float, Float) -> Float = fractionalThresholds(0.5f),
enabled: Boolean = true,
minValue: Float = Float.MIN_VALUE,
maxValue: Float = Float.MAX_VALUE,
@@ -79,8 +88,9 @@
val anchors = remember(anchorsToState) { anchorsToState.map { it.first } }
val currentValue = anchorsToState.fastFirstOrNull { it.second == state }!!.first
- val flingConfig =
- AnchorsFlingConfig(anchors, animationSpec, onAnimationEnd = { reason, finalValue, _ ->
+ val flingConfig = FlingConfig(
+ decayAnimation = ExponentialDecay(),
+ onAnimationEnd = { reason, finalValue, _ ->
if (reason != AnimationEndReason.Interrupted) {
val newState = anchorsToState.firstOrNull { it.first == finalValue }?.second
if (newState != null && newState != state) {
@@ -88,7 +98,41 @@
forceAnimationCheck.value = !forceAnimationCheck.value
}
}
- })
+ },
+ adjustTarget = { target ->
+ // Find the two anchors the target lies between.
+ val a = anchors.filter { it <= target }.max()
+ val b = anchors.filter { it >= target }.min()
+ // Compute which anchor to fling to.
+ val adjusted: Float =
+ if (a == null && b == null) {
+ // There are no anchors, so return the target unchanged.
+ target
+ } else if (a == null) {
+ // The target lies below the anchors, so return the first anchor (b).
+ b!!
+ } else if (b == null) {
+ // The target lies above the anchors, so return the last anchor (b).
+ a
+ } else if (a == b) {
+ // The target is equal to one of the anchors, so return the target unchanged.
+ target
+ } else {
+ // The target lies strictly between the two anchors a and b.
+ // Compute the threshold between a and b based on the drag direction.
+ val threshold = if (currentValue <= a) {
+ thresholds(a, b)
+ } else {
+ thresholds(b, a)
+ }
+ require(threshold >= a && threshold <= b) {
+ "Invalid threshold $threshold between anchors $a and $b."
+ }
+ if (target < threshold) a else b
+ }
+ TargetAnimation(adjusted, animationSpec)
+ }
+ )
val clock = AnimationClockAmbient.current.asDisposableClock()
val position = remember(clock) {
onNewValue(currentValue)
@@ -116,6 +160,19 @@
)
}
+/**
+ * Fixed anchors thresholds. Each threshold will be at an [offset] away from the first anchor.
+ */
+internal fun fixedThresholds(offset: Float): (Float, Float) -> Float =
+ { fromAnchor, toAnchor -> fromAnchor + offset * sign(toAnchor - fromAnchor) }
+
+/**
+ * Fractional thresholds. Each threshold will be at a [fraction] of the way between the two anchors.
+ */
+internal fun fractionalThresholds(
+ @FloatRange(from = 0.0, to = 1.0) fraction: Float
+): (Float, Float) -> Float = { fromAnchor, toAnchor -> lerp(fromAnchor, toAnchor, fraction) }
+
private class NotificationBasedAnimatedFloat(
initial: Float,
clock: AnimationClockObservable,
diff --git a/ui/ui-test-font/build.gradle b/ui/ui-test-font/build.gradle
index 0bd8692..f51a4aa 100644
--- a/ui/ui-test-font/build.gradle
+++ b/ui/ui-test-font/build.gradle
@@ -25,10 +25,10 @@
}
androidx {
- name = "AndroidX UI Test Font resources"
+ name = "Compose Test Font resources"
publish = Publish.NONE
mavenVersion = LibraryVersions.UI
- mavenGroup = LibraryGroups.UI
+ mavenGroup = LibraryGroups.Compose.CORE
inceptionYear = "2020"
description = "Fonts designed for testing text capabilities"
}
diff --git a/ui/ui-test/api/0.1.0-dev15.txt b/ui/ui-test/api/0.1.0-dev15.txt
index 7104f4a..e992fff 100644
--- a/ui/ui-test/api/0.1.0-dev15.txt
+++ b/ui/ui-test/api/0.1.0-dev15.txt
@@ -2,12 +2,18 @@
package androidx.ui.test {
public final class ActionsKt {
- method public static <T extends kotlin.Function<? extends java.lang.Boolean>> void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<T>> key, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> invocation);
- method public static void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> key);
- method public static androidx.ui.test.SemanticsNodeInteraction doClick(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction doGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.GestureScope,kotlin.Unit> block);
- method public static androidx.ui.test.SemanticsNodeInteraction doPartialGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.PartialGestureScope,kotlin.Unit> block);
- method public static androidx.ui.test.SemanticsNodeInteraction doScrollTo(androidx.ui.test.SemanticsNodeInteraction);
+ method @Deprecated public static <T extends kotlin.Function<? extends java.lang.Boolean>> void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<T>> key, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> invocation);
+ method @Deprecated public static void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> key);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doClick(androidx.ui.test.SemanticsNodeInteraction);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.GestureScope,kotlin.Unit> block);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doPartialGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.PartialGestureScope,kotlin.Unit> block);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doScrollTo(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction performClick(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction performGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.GestureScope,kotlin.Unit> block);
+ method public static androidx.ui.test.SemanticsNodeInteraction performPartialGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.PartialGestureScope,kotlin.Unit> block);
+ method public static androidx.ui.test.SemanticsNodeInteraction performScrollTo(androidx.ui.test.SemanticsNodeInteraction);
+ method public static <T extends kotlin.Function<? extends java.lang.Boolean>> void performSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<T>> key, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> invocation);
+ method public static void performSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> key);
}
public final class AnimationClockTestRule implements org.junit.rules.TestRule {
@@ -160,17 +166,17 @@
}
public final class FiltersKt {
- method public static androidx.ui.test.SemanticsMatcher hasAnyAncestorThat(androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsMatcher hasAnyChildThat(androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsMatcher hasAnyDescendantThat(androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsMatcher hasAnySiblingThat(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnyAncestor(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnyChild(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnyDescendant(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnySibling(androidx.ui.test.SemanticsMatcher matcher);
method public static androidx.ui.test.SemanticsMatcher hasClickAction();
method public static androidx.ui.test.SemanticsMatcher hasImeAction(androidx.ui.input.ImeAction actionType);
method public static androidx.ui.test.SemanticsMatcher hasInputMethodsSupport();
method public static androidx.ui.test.SemanticsMatcher hasLabel(String label, boolean ignoreCase = false);
method public static androidx.ui.test.SemanticsMatcher hasNoClickAction();
method public static androidx.ui.test.SemanticsMatcher hasNoScrollAction();
- method public static androidx.ui.test.SemanticsMatcher hasParentThat(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasParent(androidx.ui.test.SemanticsMatcher matcher);
method public static androidx.ui.test.SemanticsMatcher hasRangeInfo(androidx.ui.semantics.AccessibilityRangeInfo rangeInfo);
method public static androidx.ui.test.SemanticsMatcher hasScrollAction();
method public static androidx.ui.test.SemanticsMatcher hasSubstring(String substring, boolean ignoreCase = false);
@@ -194,22 +200,37 @@
}
public final class FindersKt {
- method public static androidx.ui.test.SemanticsNodeInteraction find(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAll(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByTag(String testTag, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findBySubstring(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findByTag(String testTag, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findRoot(boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction find(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAll(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByTag(String testTag, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findBySubstring(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findByTag(String testTag, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findRoot(boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodes(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodesWithLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodesWithTag(String testTag, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodesWithText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNode(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithSubstring(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithTag(String testTag, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onRoot(boolean useUnmergedTree = false);
}
public final class GestureScope extends androidx.ui.test.BaseGestureScope {
}
public final class GestureScopeKt {
+ method public static void cancel(androidx.ui.test.PartialGestureScope);
+ method public static void click(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center);
+ method public static void doubleClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration delay = androidx.ui.test.GestureScopeKt.doubleClickDelay);
+ method public static void down(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method public static void down(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
method public static inline float getBottom(androidx.ui.test.BaseGestureScope);
method public static androidx.ui.geometry.Offset getBottomCenter(androidx.ui.test.BaseGestureScope);
method public static androidx.ui.geometry.Offset getBottomLeft(androidx.ui.test.BaseGestureScope);
@@ -230,32 +251,46 @@
method public static androidx.ui.geometry.Offset getTopRight(androidx.ui.test.BaseGestureScope);
method public static inline int getWidth(androidx.ui.test.BaseGestureScope);
method public static androidx.ui.geometry.Offset localToGlobal(androidx.ui.test.BaseGestureScope, androidx.ui.geometry.Offset position);
+ method public static void longClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration duration = androidx.ui.core.gesture.ConstantsKt.LongPressTimeout + 100.milliseconds);
+ method public static void move(androidx.ui.test.PartialGestureScope);
+ method public static void moveBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
+ method public static void moveBy(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset delta);
method public static void movePointerBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
method public static void movePointerTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method public static void moveTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method public static void moveTo(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
method public static androidx.ui.geometry.Offset percentOffset(androidx.ui.test.BaseGestureScope, @FloatRange(from=-1.0, to=1.0) float x = 0f, @FloatRange(from=-1.0, to=1.0) float y = 0f);
- method public static void sendCancel(androidx.ui.test.PartialGestureScope);
- method public static void sendClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center);
- method public static void sendDoubleClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration delay = androidx.ui.test.GestureScopeKt.doubleClickDelay);
- method public static void sendDown(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
- method public static void sendDown(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
- method public static void sendLongClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration duration = androidx.ui.core.gesture.ConstantsKt.LongPressTimeout + 100.milliseconds);
- method public static void sendMove(androidx.ui.test.PartialGestureScope);
- method public static void sendMoveBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
- method public static void sendMoveBy(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset delta);
- method public static void sendMoveTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
- method public static void sendMoveTo(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
- method public static void sendPinch(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start0, androidx.ui.geometry.Offset end0, androidx.ui.geometry.Offset start1, androidx.ui.geometry.Offset end1, androidx.ui.unit.Duration duration = 400.milliseconds);
- method public static void sendSwipe(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, androidx.ui.unit.Duration duration = 200.milliseconds);
- method public static void sendSwipeDown(androidx.ui.test.GestureScope);
- method public static void sendSwipeLeft(androidx.ui.test.GestureScope);
- method public static void sendSwipeRight(androidx.ui.test.GestureScope);
- method public static void sendSwipeUp(androidx.ui.test.GestureScope);
- method public static void sendSwipeWithVelocity(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, @FloatRange(from=0.0) float endVelocity, androidx.ui.unit.Duration duration = 200.milliseconds);
- method public static void sendUp(androidx.ui.test.PartialGestureScope, int pointerId = 0);
+ method public static void pinch(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start0, androidx.ui.geometry.Offset end0, androidx.ui.geometry.Offset start1, androidx.ui.geometry.Offset end1, androidx.ui.unit.Duration duration = 400.milliseconds);
+ method @Deprecated public static void sendCancel(androidx.ui.test.PartialGestureScope);
+ method @Deprecated public static void sendClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center);
+ method @Deprecated public static void sendDoubleClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration delay = androidx.ui.test.GestureScopeKt.doubleClickDelay);
+ method @Deprecated public static void sendDown(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendDown(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendLongClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration duration = androidx.ui.core.gesture.ConstantsKt.LongPressTimeout + 100.milliseconds);
+ method @Deprecated public static void sendMove(androidx.ui.test.PartialGestureScope);
+ method @Deprecated public static void sendMoveBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
+ method @Deprecated public static void sendMoveBy(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset delta);
+ method @Deprecated public static void sendMoveTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendMoveTo(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendPinch(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start0, androidx.ui.geometry.Offset end0, androidx.ui.geometry.Offset start1, androidx.ui.geometry.Offset end1, androidx.ui.unit.Duration duration = 400.milliseconds);
+ method @Deprecated public static void sendSwipe(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method @Deprecated public static void sendSwipeDown(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeLeft(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeRight(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeUp(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeWithVelocity(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, @FloatRange(from=0.0) float endVelocity, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method @Deprecated public static void sendUp(androidx.ui.test.PartialGestureScope, int pointerId = 0);
+ method public static void swipe(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method public static void swipeDown(androidx.ui.test.GestureScope);
+ method public static void swipeLeft(androidx.ui.test.GestureScope);
+ method public static void swipeRight(androidx.ui.test.GestureScope);
+ method public static void swipeUp(androidx.ui.test.GestureScope);
+ method public static void swipeWithVelocity(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, @FloatRange(from=0.0) float endVelocity, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method public static void up(androidx.ui.test.PartialGestureScope, int pointerId = 0);
}
public final class KeyInputHelpersKt {
- method public static boolean doSendKeyEvent(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.core.keyinput.KeyEvent2 keyEvent);
+ method public static boolean performKeyPress(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.core.keyinput.KeyEvent2 keyEvent);
}
public final class OutputKt {
@@ -275,17 +310,17 @@
}
public final class SelectorsKt {
- method public static androidx.ui.test.SemanticsNodeInteractionCollection ancestors(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction child(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction childAt(androidx.ui.test.SemanticsNodeInteraction, int index);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection children(androidx.ui.test.SemanticsNodeInteraction);
method public static androidx.ui.test.SemanticsNodeInteractionCollection filter(androidx.ui.test.SemanticsNodeInteractionCollection, androidx.ui.test.SemanticsMatcher matcher);
method public static androidx.ui.test.SemanticsNodeInteraction filterToOne(androidx.ui.test.SemanticsNodeInteractionCollection, androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsNodeInteraction first(androidx.ui.test.SemanticsNodeInteractionCollection);
- method public static androidx.ui.test.SemanticsNodeInteraction last(androidx.ui.test.SemanticsNodeInteractionCollection);
- method public static androidx.ui.test.SemanticsNodeInteraction parent(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction sibling(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection siblings(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAncestors(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onChild(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onChildAt(androidx.ui.test.SemanticsNodeInteraction, int index);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onChildren(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onFirst(androidx.ui.test.SemanticsNodeInteractionCollection);
+ method public static androidx.ui.test.SemanticsNodeInteraction onLast(androidx.ui.test.SemanticsNodeInteractionCollection);
+ method public static androidx.ui.test.SemanticsNodeInteraction onParent(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onSibling(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onSiblings(androidx.ui.test.SemanticsNodeInteraction);
}
public final class SemanticsMatcher {
@@ -349,10 +384,14 @@
}
public final class TextActionsKt {
- method public static void doClearText(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
- method public static void doReplaceText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
- method public static void doSendImeAction(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
- method public static void doSendText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doClearText(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doReplaceText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doSendImeAction(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doSendText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method public static void performImeAction(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method public static void performTextClearance(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method public static void performTextInput(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method public static void performTextReplacement(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
}
}
diff --git a/ui/ui-test/api/current.txt b/ui/ui-test/api/current.txt
index 7104f4a..e992fff 100644
--- a/ui/ui-test/api/current.txt
+++ b/ui/ui-test/api/current.txt
@@ -2,12 +2,18 @@
package androidx.ui.test {
public final class ActionsKt {
- method public static <T extends kotlin.Function<? extends java.lang.Boolean>> void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<T>> key, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> invocation);
- method public static void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> key);
- method public static androidx.ui.test.SemanticsNodeInteraction doClick(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction doGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.GestureScope,kotlin.Unit> block);
- method public static androidx.ui.test.SemanticsNodeInteraction doPartialGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.PartialGestureScope,kotlin.Unit> block);
- method public static androidx.ui.test.SemanticsNodeInteraction doScrollTo(androidx.ui.test.SemanticsNodeInteraction);
+ method @Deprecated public static <T extends kotlin.Function<? extends java.lang.Boolean>> void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<T>> key, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> invocation);
+ method @Deprecated public static void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> key);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doClick(androidx.ui.test.SemanticsNodeInteraction);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.GestureScope,kotlin.Unit> block);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doPartialGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.PartialGestureScope,kotlin.Unit> block);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doScrollTo(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction performClick(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction performGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.GestureScope,kotlin.Unit> block);
+ method public static androidx.ui.test.SemanticsNodeInteraction performPartialGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.PartialGestureScope,kotlin.Unit> block);
+ method public static androidx.ui.test.SemanticsNodeInteraction performScrollTo(androidx.ui.test.SemanticsNodeInteraction);
+ method public static <T extends kotlin.Function<? extends java.lang.Boolean>> void performSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<T>> key, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> invocation);
+ method public static void performSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> key);
}
public final class AnimationClockTestRule implements org.junit.rules.TestRule {
@@ -160,17 +166,17 @@
}
public final class FiltersKt {
- method public static androidx.ui.test.SemanticsMatcher hasAnyAncestorThat(androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsMatcher hasAnyChildThat(androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsMatcher hasAnyDescendantThat(androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsMatcher hasAnySiblingThat(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnyAncestor(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnyChild(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnyDescendant(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnySibling(androidx.ui.test.SemanticsMatcher matcher);
method public static androidx.ui.test.SemanticsMatcher hasClickAction();
method public static androidx.ui.test.SemanticsMatcher hasImeAction(androidx.ui.input.ImeAction actionType);
method public static androidx.ui.test.SemanticsMatcher hasInputMethodsSupport();
method public static androidx.ui.test.SemanticsMatcher hasLabel(String label, boolean ignoreCase = false);
method public static androidx.ui.test.SemanticsMatcher hasNoClickAction();
method public static androidx.ui.test.SemanticsMatcher hasNoScrollAction();
- method public static androidx.ui.test.SemanticsMatcher hasParentThat(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasParent(androidx.ui.test.SemanticsMatcher matcher);
method public static androidx.ui.test.SemanticsMatcher hasRangeInfo(androidx.ui.semantics.AccessibilityRangeInfo rangeInfo);
method public static androidx.ui.test.SemanticsMatcher hasScrollAction();
method public static androidx.ui.test.SemanticsMatcher hasSubstring(String substring, boolean ignoreCase = false);
@@ -194,22 +200,37 @@
}
public final class FindersKt {
- method public static androidx.ui.test.SemanticsNodeInteraction find(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAll(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByTag(String testTag, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findBySubstring(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findByTag(String testTag, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findRoot(boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction find(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAll(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByTag(String testTag, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findBySubstring(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findByTag(String testTag, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findRoot(boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodes(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodesWithLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodesWithTag(String testTag, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodesWithText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNode(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithSubstring(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithTag(String testTag, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onRoot(boolean useUnmergedTree = false);
}
public final class GestureScope extends androidx.ui.test.BaseGestureScope {
}
public final class GestureScopeKt {
+ method public static void cancel(androidx.ui.test.PartialGestureScope);
+ method public static void click(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center);
+ method public static void doubleClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration delay = androidx.ui.test.GestureScopeKt.doubleClickDelay);
+ method public static void down(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method public static void down(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
method public static inline float getBottom(androidx.ui.test.BaseGestureScope);
method public static androidx.ui.geometry.Offset getBottomCenter(androidx.ui.test.BaseGestureScope);
method public static androidx.ui.geometry.Offset getBottomLeft(androidx.ui.test.BaseGestureScope);
@@ -230,32 +251,46 @@
method public static androidx.ui.geometry.Offset getTopRight(androidx.ui.test.BaseGestureScope);
method public static inline int getWidth(androidx.ui.test.BaseGestureScope);
method public static androidx.ui.geometry.Offset localToGlobal(androidx.ui.test.BaseGestureScope, androidx.ui.geometry.Offset position);
+ method public static void longClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration duration = androidx.ui.core.gesture.ConstantsKt.LongPressTimeout + 100.milliseconds);
+ method public static void move(androidx.ui.test.PartialGestureScope);
+ method public static void moveBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
+ method public static void moveBy(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset delta);
method public static void movePointerBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
method public static void movePointerTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method public static void moveTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method public static void moveTo(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
method public static androidx.ui.geometry.Offset percentOffset(androidx.ui.test.BaseGestureScope, @FloatRange(from=-1.0, to=1.0) float x = 0f, @FloatRange(from=-1.0, to=1.0) float y = 0f);
- method public static void sendCancel(androidx.ui.test.PartialGestureScope);
- method public static void sendClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center);
- method public static void sendDoubleClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration delay = androidx.ui.test.GestureScopeKt.doubleClickDelay);
- method public static void sendDown(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
- method public static void sendDown(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
- method public static void sendLongClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration duration = androidx.ui.core.gesture.ConstantsKt.LongPressTimeout + 100.milliseconds);
- method public static void sendMove(androidx.ui.test.PartialGestureScope);
- method public static void sendMoveBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
- method public static void sendMoveBy(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset delta);
- method public static void sendMoveTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
- method public static void sendMoveTo(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
- method public static void sendPinch(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start0, androidx.ui.geometry.Offset end0, androidx.ui.geometry.Offset start1, androidx.ui.geometry.Offset end1, androidx.ui.unit.Duration duration = 400.milliseconds);
- method public static void sendSwipe(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, androidx.ui.unit.Duration duration = 200.milliseconds);
- method public static void sendSwipeDown(androidx.ui.test.GestureScope);
- method public static void sendSwipeLeft(androidx.ui.test.GestureScope);
- method public static void sendSwipeRight(androidx.ui.test.GestureScope);
- method public static void sendSwipeUp(androidx.ui.test.GestureScope);
- method public static void sendSwipeWithVelocity(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, @FloatRange(from=0.0) float endVelocity, androidx.ui.unit.Duration duration = 200.milliseconds);
- method public static void sendUp(androidx.ui.test.PartialGestureScope, int pointerId = 0);
+ method public static void pinch(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start0, androidx.ui.geometry.Offset end0, androidx.ui.geometry.Offset start1, androidx.ui.geometry.Offset end1, androidx.ui.unit.Duration duration = 400.milliseconds);
+ method @Deprecated public static void sendCancel(androidx.ui.test.PartialGestureScope);
+ method @Deprecated public static void sendClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center);
+ method @Deprecated public static void sendDoubleClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration delay = androidx.ui.test.GestureScopeKt.doubleClickDelay);
+ method @Deprecated public static void sendDown(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendDown(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendLongClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration duration = androidx.ui.core.gesture.ConstantsKt.LongPressTimeout + 100.milliseconds);
+ method @Deprecated public static void sendMove(androidx.ui.test.PartialGestureScope);
+ method @Deprecated public static void sendMoveBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
+ method @Deprecated public static void sendMoveBy(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset delta);
+ method @Deprecated public static void sendMoveTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendMoveTo(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendPinch(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start0, androidx.ui.geometry.Offset end0, androidx.ui.geometry.Offset start1, androidx.ui.geometry.Offset end1, androidx.ui.unit.Duration duration = 400.milliseconds);
+ method @Deprecated public static void sendSwipe(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method @Deprecated public static void sendSwipeDown(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeLeft(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeRight(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeUp(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeWithVelocity(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, @FloatRange(from=0.0) float endVelocity, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method @Deprecated public static void sendUp(androidx.ui.test.PartialGestureScope, int pointerId = 0);
+ method public static void swipe(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method public static void swipeDown(androidx.ui.test.GestureScope);
+ method public static void swipeLeft(androidx.ui.test.GestureScope);
+ method public static void swipeRight(androidx.ui.test.GestureScope);
+ method public static void swipeUp(androidx.ui.test.GestureScope);
+ method public static void swipeWithVelocity(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, @FloatRange(from=0.0) float endVelocity, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method public static void up(androidx.ui.test.PartialGestureScope, int pointerId = 0);
}
public final class KeyInputHelpersKt {
- method public static boolean doSendKeyEvent(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.core.keyinput.KeyEvent2 keyEvent);
+ method public static boolean performKeyPress(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.core.keyinput.KeyEvent2 keyEvent);
}
public final class OutputKt {
@@ -275,17 +310,17 @@
}
public final class SelectorsKt {
- method public static androidx.ui.test.SemanticsNodeInteractionCollection ancestors(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction child(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction childAt(androidx.ui.test.SemanticsNodeInteraction, int index);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection children(androidx.ui.test.SemanticsNodeInteraction);
method public static androidx.ui.test.SemanticsNodeInteractionCollection filter(androidx.ui.test.SemanticsNodeInteractionCollection, androidx.ui.test.SemanticsMatcher matcher);
method public static androidx.ui.test.SemanticsNodeInteraction filterToOne(androidx.ui.test.SemanticsNodeInteractionCollection, androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsNodeInteraction first(androidx.ui.test.SemanticsNodeInteractionCollection);
- method public static androidx.ui.test.SemanticsNodeInteraction last(androidx.ui.test.SemanticsNodeInteractionCollection);
- method public static androidx.ui.test.SemanticsNodeInteraction parent(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction sibling(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection siblings(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAncestors(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onChild(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onChildAt(androidx.ui.test.SemanticsNodeInteraction, int index);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onChildren(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onFirst(androidx.ui.test.SemanticsNodeInteractionCollection);
+ method public static androidx.ui.test.SemanticsNodeInteraction onLast(androidx.ui.test.SemanticsNodeInteractionCollection);
+ method public static androidx.ui.test.SemanticsNodeInteraction onParent(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onSibling(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onSiblings(androidx.ui.test.SemanticsNodeInteraction);
}
public final class SemanticsMatcher {
@@ -349,10 +384,14 @@
}
public final class TextActionsKt {
- method public static void doClearText(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
- method public static void doReplaceText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
- method public static void doSendImeAction(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
- method public static void doSendText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doClearText(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doReplaceText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doSendImeAction(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doSendText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method public static void performImeAction(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method public static void performTextClearance(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method public static void performTextInput(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method public static void performTextReplacement(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
}
}
diff --git a/ui/ui-test/api/public_plus_experimental_0.1.0-dev15.txt b/ui/ui-test/api/public_plus_experimental_0.1.0-dev15.txt
index 7104f4a..e992fff 100644
--- a/ui/ui-test/api/public_plus_experimental_0.1.0-dev15.txt
+++ b/ui/ui-test/api/public_plus_experimental_0.1.0-dev15.txt
@@ -2,12 +2,18 @@
package androidx.ui.test {
public final class ActionsKt {
- method public static <T extends kotlin.Function<? extends java.lang.Boolean>> void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<T>> key, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> invocation);
- method public static void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> key);
- method public static androidx.ui.test.SemanticsNodeInteraction doClick(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction doGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.GestureScope,kotlin.Unit> block);
- method public static androidx.ui.test.SemanticsNodeInteraction doPartialGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.PartialGestureScope,kotlin.Unit> block);
- method public static androidx.ui.test.SemanticsNodeInteraction doScrollTo(androidx.ui.test.SemanticsNodeInteraction);
+ method @Deprecated public static <T extends kotlin.Function<? extends java.lang.Boolean>> void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<T>> key, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> invocation);
+ method @Deprecated public static void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> key);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doClick(androidx.ui.test.SemanticsNodeInteraction);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.GestureScope,kotlin.Unit> block);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doPartialGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.PartialGestureScope,kotlin.Unit> block);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doScrollTo(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction performClick(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction performGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.GestureScope,kotlin.Unit> block);
+ method public static androidx.ui.test.SemanticsNodeInteraction performPartialGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.PartialGestureScope,kotlin.Unit> block);
+ method public static androidx.ui.test.SemanticsNodeInteraction performScrollTo(androidx.ui.test.SemanticsNodeInteraction);
+ method public static <T extends kotlin.Function<? extends java.lang.Boolean>> void performSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<T>> key, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> invocation);
+ method public static void performSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> key);
}
public final class AnimationClockTestRule implements org.junit.rules.TestRule {
@@ -160,17 +166,17 @@
}
public final class FiltersKt {
- method public static androidx.ui.test.SemanticsMatcher hasAnyAncestorThat(androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsMatcher hasAnyChildThat(androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsMatcher hasAnyDescendantThat(androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsMatcher hasAnySiblingThat(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnyAncestor(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnyChild(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnyDescendant(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnySibling(androidx.ui.test.SemanticsMatcher matcher);
method public static androidx.ui.test.SemanticsMatcher hasClickAction();
method public static androidx.ui.test.SemanticsMatcher hasImeAction(androidx.ui.input.ImeAction actionType);
method public static androidx.ui.test.SemanticsMatcher hasInputMethodsSupport();
method public static androidx.ui.test.SemanticsMatcher hasLabel(String label, boolean ignoreCase = false);
method public static androidx.ui.test.SemanticsMatcher hasNoClickAction();
method public static androidx.ui.test.SemanticsMatcher hasNoScrollAction();
- method public static androidx.ui.test.SemanticsMatcher hasParentThat(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasParent(androidx.ui.test.SemanticsMatcher matcher);
method public static androidx.ui.test.SemanticsMatcher hasRangeInfo(androidx.ui.semantics.AccessibilityRangeInfo rangeInfo);
method public static androidx.ui.test.SemanticsMatcher hasScrollAction();
method public static androidx.ui.test.SemanticsMatcher hasSubstring(String substring, boolean ignoreCase = false);
@@ -194,22 +200,37 @@
}
public final class FindersKt {
- method public static androidx.ui.test.SemanticsNodeInteraction find(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAll(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByTag(String testTag, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findBySubstring(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findByTag(String testTag, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findRoot(boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction find(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAll(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByTag(String testTag, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findBySubstring(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findByTag(String testTag, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findRoot(boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodes(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodesWithLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodesWithTag(String testTag, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodesWithText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNode(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithSubstring(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithTag(String testTag, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onRoot(boolean useUnmergedTree = false);
}
public final class GestureScope extends androidx.ui.test.BaseGestureScope {
}
public final class GestureScopeKt {
+ method public static void cancel(androidx.ui.test.PartialGestureScope);
+ method public static void click(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center);
+ method public static void doubleClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration delay = androidx.ui.test.GestureScopeKt.doubleClickDelay);
+ method public static void down(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method public static void down(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
method public static inline float getBottom(androidx.ui.test.BaseGestureScope);
method public static androidx.ui.geometry.Offset getBottomCenter(androidx.ui.test.BaseGestureScope);
method public static androidx.ui.geometry.Offset getBottomLeft(androidx.ui.test.BaseGestureScope);
@@ -230,32 +251,46 @@
method public static androidx.ui.geometry.Offset getTopRight(androidx.ui.test.BaseGestureScope);
method public static inline int getWidth(androidx.ui.test.BaseGestureScope);
method public static androidx.ui.geometry.Offset localToGlobal(androidx.ui.test.BaseGestureScope, androidx.ui.geometry.Offset position);
+ method public static void longClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration duration = androidx.ui.core.gesture.ConstantsKt.LongPressTimeout + 100.milliseconds);
+ method public static void move(androidx.ui.test.PartialGestureScope);
+ method public static void moveBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
+ method public static void moveBy(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset delta);
method public static void movePointerBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
method public static void movePointerTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method public static void moveTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method public static void moveTo(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
method public static androidx.ui.geometry.Offset percentOffset(androidx.ui.test.BaseGestureScope, @FloatRange(from=-1.0, to=1.0) float x = 0f, @FloatRange(from=-1.0, to=1.0) float y = 0f);
- method public static void sendCancel(androidx.ui.test.PartialGestureScope);
- method public static void sendClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center);
- method public static void sendDoubleClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration delay = androidx.ui.test.GestureScopeKt.doubleClickDelay);
- method public static void sendDown(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
- method public static void sendDown(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
- method public static void sendLongClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration duration = androidx.ui.core.gesture.ConstantsKt.LongPressTimeout + 100.milliseconds);
- method public static void sendMove(androidx.ui.test.PartialGestureScope);
- method public static void sendMoveBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
- method public static void sendMoveBy(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset delta);
- method public static void sendMoveTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
- method public static void sendMoveTo(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
- method public static void sendPinch(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start0, androidx.ui.geometry.Offset end0, androidx.ui.geometry.Offset start1, androidx.ui.geometry.Offset end1, androidx.ui.unit.Duration duration = 400.milliseconds);
- method public static void sendSwipe(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, androidx.ui.unit.Duration duration = 200.milliseconds);
- method public static void sendSwipeDown(androidx.ui.test.GestureScope);
- method public static void sendSwipeLeft(androidx.ui.test.GestureScope);
- method public static void sendSwipeRight(androidx.ui.test.GestureScope);
- method public static void sendSwipeUp(androidx.ui.test.GestureScope);
- method public static void sendSwipeWithVelocity(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, @FloatRange(from=0.0) float endVelocity, androidx.ui.unit.Duration duration = 200.milliseconds);
- method public static void sendUp(androidx.ui.test.PartialGestureScope, int pointerId = 0);
+ method public static void pinch(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start0, androidx.ui.geometry.Offset end0, androidx.ui.geometry.Offset start1, androidx.ui.geometry.Offset end1, androidx.ui.unit.Duration duration = 400.milliseconds);
+ method @Deprecated public static void sendCancel(androidx.ui.test.PartialGestureScope);
+ method @Deprecated public static void sendClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center);
+ method @Deprecated public static void sendDoubleClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration delay = androidx.ui.test.GestureScopeKt.doubleClickDelay);
+ method @Deprecated public static void sendDown(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendDown(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendLongClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration duration = androidx.ui.core.gesture.ConstantsKt.LongPressTimeout + 100.milliseconds);
+ method @Deprecated public static void sendMove(androidx.ui.test.PartialGestureScope);
+ method @Deprecated public static void sendMoveBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
+ method @Deprecated public static void sendMoveBy(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset delta);
+ method @Deprecated public static void sendMoveTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendMoveTo(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendPinch(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start0, androidx.ui.geometry.Offset end0, androidx.ui.geometry.Offset start1, androidx.ui.geometry.Offset end1, androidx.ui.unit.Duration duration = 400.milliseconds);
+ method @Deprecated public static void sendSwipe(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method @Deprecated public static void sendSwipeDown(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeLeft(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeRight(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeUp(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeWithVelocity(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, @FloatRange(from=0.0) float endVelocity, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method @Deprecated public static void sendUp(androidx.ui.test.PartialGestureScope, int pointerId = 0);
+ method public static void swipe(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method public static void swipeDown(androidx.ui.test.GestureScope);
+ method public static void swipeLeft(androidx.ui.test.GestureScope);
+ method public static void swipeRight(androidx.ui.test.GestureScope);
+ method public static void swipeUp(androidx.ui.test.GestureScope);
+ method public static void swipeWithVelocity(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, @FloatRange(from=0.0) float endVelocity, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method public static void up(androidx.ui.test.PartialGestureScope, int pointerId = 0);
}
public final class KeyInputHelpersKt {
- method public static boolean doSendKeyEvent(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.core.keyinput.KeyEvent2 keyEvent);
+ method public static boolean performKeyPress(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.core.keyinput.KeyEvent2 keyEvent);
}
public final class OutputKt {
@@ -275,17 +310,17 @@
}
public final class SelectorsKt {
- method public static androidx.ui.test.SemanticsNodeInteractionCollection ancestors(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction child(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction childAt(androidx.ui.test.SemanticsNodeInteraction, int index);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection children(androidx.ui.test.SemanticsNodeInteraction);
method public static androidx.ui.test.SemanticsNodeInteractionCollection filter(androidx.ui.test.SemanticsNodeInteractionCollection, androidx.ui.test.SemanticsMatcher matcher);
method public static androidx.ui.test.SemanticsNodeInteraction filterToOne(androidx.ui.test.SemanticsNodeInteractionCollection, androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsNodeInteraction first(androidx.ui.test.SemanticsNodeInteractionCollection);
- method public static androidx.ui.test.SemanticsNodeInteraction last(androidx.ui.test.SemanticsNodeInteractionCollection);
- method public static androidx.ui.test.SemanticsNodeInteraction parent(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction sibling(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection siblings(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAncestors(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onChild(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onChildAt(androidx.ui.test.SemanticsNodeInteraction, int index);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onChildren(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onFirst(androidx.ui.test.SemanticsNodeInteractionCollection);
+ method public static androidx.ui.test.SemanticsNodeInteraction onLast(androidx.ui.test.SemanticsNodeInteractionCollection);
+ method public static androidx.ui.test.SemanticsNodeInteraction onParent(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onSibling(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onSiblings(androidx.ui.test.SemanticsNodeInteraction);
}
public final class SemanticsMatcher {
@@ -349,10 +384,14 @@
}
public final class TextActionsKt {
- method public static void doClearText(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
- method public static void doReplaceText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
- method public static void doSendImeAction(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
- method public static void doSendText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doClearText(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doReplaceText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doSendImeAction(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doSendText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method public static void performImeAction(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method public static void performTextClearance(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method public static void performTextInput(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method public static void performTextReplacement(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
}
}
diff --git a/ui/ui-test/api/public_plus_experimental_current.txt b/ui/ui-test/api/public_plus_experimental_current.txt
index 7104f4a..e992fff 100644
--- a/ui/ui-test/api/public_plus_experimental_current.txt
+++ b/ui/ui-test/api/public_plus_experimental_current.txt
@@ -2,12 +2,18 @@
package androidx.ui.test {
public final class ActionsKt {
- method public static <T extends kotlin.Function<? extends java.lang.Boolean>> void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<T>> key, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> invocation);
- method public static void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> key);
- method public static androidx.ui.test.SemanticsNodeInteraction doClick(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction doGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.GestureScope,kotlin.Unit> block);
- method public static androidx.ui.test.SemanticsNodeInteraction doPartialGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.PartialGestureScope,kotlin.Unit> block);
- method public static androidx.ui.test.SemanticsNodeInteraction doScrollTo(androidx.ui.test.SemanticsNodeInteraction);
+ method @Deprecated public static <T extends kotlin.Function<? extends java.lang.Boolean>> void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<T>> key, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> invocation);
+ method @Deprecated public static void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> key);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doClick(androidx.ui.test.SemanticsNodeInteraction);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.GestureScope,kotlin.Unit> block);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doPartialGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.PartialGestureScope,kotlin.Unit> block);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doScrollTo(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction performClick(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction performGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.GestureScope,kotlin.Unit> block);
+ method public static androidx.ui.test.SemanticsNodeInteraction performPartialGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.PartialGestureScope,kotlin.Unit> block);
+ method public static androidx.ui.test.SemanticsNodeInteraction performScrollTo(androidx.ui.test.SemanticsNodeInteraction);
+ method public static <T extends kotlin.Function<? extends java.lang.Boolean>> void performSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<T>> key, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> invocation);
+ method public static void performSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> key);
}
public final class AnimationClockTestRule implements org.junit.rules.TestRule {
@@ -160,17 +166,17 @@
}
public final class FiltersKt {
- method public static androidx.ui.test.SemanticsMatcher hasAnyAncestorThat(androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsMatcher hasAnyChildThat(androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsMatcher hasAnyDescendantThat(androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsMatcher hasAnySiblingThat(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnyAncestor(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnyChild(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnyDescendant(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnySibling(androidx.ui.test.SemanticsMatcher matcher);
method public static androidx.ui.test.SemanticsMatcher hasClickAction();
method public static androidx.ui.test.SemanticsMatcher hasImeAction(androidx.ui.input.ImeAction actionType);
method public static androidx.ui.test.SemanticsMatcher hasInputMethodsSupport();
method public static androidx.ui.test.SemanticsMatcher hasLabel(String label, boolean ignoreCase = false);
method public static androidx.ui.test.SemanticsMatcher hasNoClickAction();
method public static androidx.ui.test.SemanticsMatcher hasNoScrollAction();
- method public static androidx.ui.test.SemanticsMatcher hasParentThat(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasParent(androidx.ui.test.SemanticsMatcher matcher);
method public static androidx.ui.test.SemanticsMatcher hasRangeInfo(androidx.ui.semantics.AccessibilityRangeInfo rangeInfo);
method public static androidx.ui.test.SemanticsMatcher hasScrollAction();
method public static androidx.ui.test.SemanticsMatcher hasSubstring(String substring, boolean ignoreCase = false);
@@ -194,22 +200,37 @@
}
public final class FindersKt {
- method public static androidx.ui.test.SemanticsNodeInteraction find(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAll(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByTag(String testTag, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findBySubstring(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findByTag(String testTag, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findRoot(boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction find(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAll(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByTag(String testTag, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findBySubstring(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findByTag(String testTag, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findRoot(boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodes(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodesWithLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodesWithTag(String testTag, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodesWithText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNode(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithSubstring(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithTag(String testTag, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onRoot(boolean useUnmergedTree = false);
}
public final class GestureScope extends androidx.ui.test.BaseGestureScope {
}
public final class GestureScopeKt {
+ method public static void cancel(androidx.ui.test.PartialGestureScope);
+ method public static void click(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center);
+ method public static void doubleClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration delay = androidx.ui.test.GestureScopeKt.doubleClickDelay);
+ method public static void down(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method public static void down(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
method public static inline float getBottom(androidx.ui.test.BaseGestureScope);
method public static androidx.ui.geometry.Offset getBottomCenter(androidx.ui.test.BaseGestureScope);
method public static androidx.ui.geometry.Offset getBottomLeft(androidx.ui.test.BaseGestureScope);
@@ -230,32 +251,46 @@
method public static androidx.ui.geometry.Offset getTopRight(androidx.ui.test.BaseGestureScope);
method public static inline int getWidth(androidx.ui.test.BaseGestureScope);
method public static androidx.ui.geometry.Offset localToGlobal(androidx.ui.test.BaseGestureScope, androidx.ui.geometry.Offset position);
+ method public static void longClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration duration = androidx.ui.core.gesture.ConstantsKt.LongPressTimeout + 100.milliseconds);
+ method public static void move(androidx.ui.test.PartialGestureScope);
+ method public static void moveBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
+ method public static void moveBy(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset delta);
method public static void movePointerBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
method public static void movePointerTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method public static void moveTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method public static void moveTo(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
method public static androidx.ui.geometry.Offset percentOffset(androidx.ui.test.BaseGestureScope, @FloatRange(from=-1.0, to=1.0) float x = 0f, @FloatRange(from=-1.0, to=1.0) float y = 0f);
- method public static void sendCancel(androidx.ui.test.PartialGestureScope);
- method public static void sendClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center);
- method public static void sendDoubleClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration delay = androidx.ui.test.GestureScopeKt.doubleClickDelay);
- method public static void sendDown(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
- method public static void sendDown(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
- method public static void sendLongClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration duration = androidx.ui.core.gesture.ConstantsKt.LongPressTimeout + 100.milliseconds);
- method public static void sendMove(androidx.ui.test.PartialGestureScope);
- method public static void sendMoveBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
- method public static void sendMoveBy(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset delta);
- method public static void sendMoveTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
- method public static void sendMoveTo(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
- method public static void sendPinch(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start0, androidx.ui.geometry.Offset end0, androidx.ui.geometry.Offset start1, androidx.ui.geometry.Offset end1, androidx.ui.unit.Duration duration = 400.milliseconds);
- method public static void sendSwipe(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, androidx.ui.unit.Duration duration = 200.milliseconds);
- method public static void sendSwipeDown(androidx.ui.test.GestureScope);
- method public static void sendSwipeLeft(androidx.ui.test.GestureScope);
- method public static void sendSwipeRight(androidx.ui.test.GestureScope);
- method public static void sendSwipeUp(androidx.ui.test.GestureScope);
- method public static void sendSwipeWithVelocity(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, @FloatRange(from=0.0) float endVelocity, androidx.ui.unit.Duration duration = 200.milliseconds);
- method public static void sendUp(androidx.ui.test.PartialGestureScope, int pointerId = 0);
+ method public static void pinch(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start0, androidx.ui.geometry.Offset end0, androidx.ui.geometry.Offset start1, androidx.ui.geometry.Offset end1, androidx.ui.unit.Duration duration = 400.milliseconds);
+ method @Deprecated public static void sendCancel(androidx.ui.test.PartialGestureScope);
+ method @Deprecated public static void sendClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center);
+ method @Deprecated public static void sendDoubleClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration delay = androidx.ui.test.GestureScopeKt.doubleClickDelay);
+ method @Deprecated public static void sendDown(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendDown(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendLongClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration duration = androidx.ui.core.gesture.ConstantsKt.LongPressTimeout + 100.milliseconds);
+ method @Deprecated public static void sendMove(androidx.ui.test.PartialGestureScope);
+ method @Deprecated public static void sendMoveBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
+ method @Deprecated public static void sendMoveBy(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset delta);
+ method @Deprecated public static void sendMoveTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendMoveTo(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendPinch(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start0, androidx.ui.geometry.Offset end0, androidx.ui.geometry.Offset start1, androidx.ui.geometry.Offset end1, androidx.ui.unit.Duration duration = 400.milliseconds);
+ method @Deprecated public static void sendSwipe(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method @Deprecated public static void sendSwipeDown(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeLeft(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeRight(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeUp(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeWithVelocity(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, @FloatRange(from=0.0) float endVelocity, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method @Deprecated public static void sendUp(androidx.ui.test.PartialGestureScope, int pointerId = 0);
+ method public static void swipe(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method public static void swipeDown(androidx.ui.test.GestureScope);
+ method public static void swipeLeft(androidx.ui.test.GestureScope);
+ method public static void swipeRight(androidx.ui.test.GestureScope);
+ method public static void swipeUp(androidx.ui.test.GestureScope);
+ method public static void swipeWithVelocity(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, @FloatRange(from=0.0) float endVelocity, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method public static void up(androidx.ui.test.PartialGestureScope, int pointerId = 0);
}
public final class KeyInputHelpersKt {
- method public static boolean doSendKeyEvent(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.core.keyinput.KeyEvent2 keyEvent);
+ method public static boolean performKeyPress(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.core.keyinput.KeyEvent2 keyEvent);
}
public final class OutputKt {
@@ -275,17 +310,17 @@
}
public final class SelectorsKt {
- method public static androidx.ui.test.SemanticsNodeInteractionCollection ancestors(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction child(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction childAt(androidx.ui.test.SemanticsNodeInteraction, int index);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection children(androidx.ui.test.SemanticsNodeInteraction);
method public static androidx.ui.test.SemanticsNodeInteractionCollection filter(androidx.ui.test.SemanticsNodeInteractionCollection, androidx.ui.test.SemanticsMatcher matcher);
method public static androidx.ui.test.SemanticsNodeInteraction filterToOne(androidx.ui.test.SemanticsNodeInteractionCollection, androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsNodeInteraction first(androidx.ui.test.SemanticsNodeInteractionCollection);
- method public static androidx.ui.test.SemanticsNodeInteraction last(androidx.ui.test.SemanticsNodeInteractionCollection);
- method public static androidx.ui.test.SemanticsNodeInteraction parent(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction sibling(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection siblings(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAncestors(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onChild(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onChildAt(androidx.ui.test.SemanticsNodeInteraction, int index);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onChildren(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onFirst(androidx.ui.test.SemanticsNodeInteractionCollection);
+ method public static androidx.ui.test.SemanticsNodeInteraction onLast(androidx.ui.test.SemanticsNodeInteractionCollection);
+ method public static androidx.ui.test.SemanticsNodeInteraction onParent(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onSibling(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onSiblings(androidx.ui.test.SemanticsNodeInteraction);
}
public final class SemanticsMatcher {
@@ -349,10 +384,14 @@
}
public final class TextActionsKt {
- method public static void doClearText(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
- method public static void doReplaceText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
- method public static void doSendImeAction(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
- method public static void doSendText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doClearText(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doReplaceText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doSendImeAction(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doSendText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method public static void performImeAction(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method public static void performTextClearance(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method public static void performTextInput(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method public static void performTextReplacement(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
}
}
diff --git a/ui/ui-test/api/restricted_0.1.0-dev15.txt b/ui/ui-test/api/restricted_0.1.0-dev15.txt
index 7104f4a..e992fff 100644
--- a/ui/ui-test/api/restricted_0.1.0-dev15.txt
+++ b/ui/ui-test/api/restricted_0.1.0-dev15.txt
@@ -2,12 +2,18 @@
package androidx.ui.test {
public final class ActionsKt {
- method public static <T extends kotlin.Function<? extends java.lang.Boolean>> void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<T>> key, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> invocation);
- method public static void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> key);
- method public static androidx.ui.test.SemanticsNodeInteraction doClick(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction doGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.GestureScope,kotlin.Unit> block);
- method public static androidx.ui.test.SemanticsNodeInteraction doPartialGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.PartialGestureScope,kotlin.Unit> block);
- method public static androidx.ui.test.SemanticsNodeInteraction doScrollTo(androidx.ui.test.SemanticsNodeInteraction);
+ method @Deprecated public static <T extends kotlin.Function<? extends java.lang.Boolean>> void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<T>> key, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> invocation);
+ method @Deprecated public static void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> key);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doClick(androidx.ui.test.SemanticsNodeInteraction);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.GestureScope,kotlin.Unit> block);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doPartialGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.PartialGestureScope,kotlin.Unit> block);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doScrollTo(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction performClick(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction performGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.GestureScope,kotlin.Unit> block);
+ method public static androidx.ui.test.SemanticsNodeInteraction performPartialGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.PartialGestureScope,kotlin.Unit> block);
+ method public static androidx.ui.test.SemanticsNodeInteraction performScrollTo(androidx.ui.test.SemanticsNodeInteraction);
+ method public static <T extends kotlin.Function<? extends java.lang.Boolean>> void performSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<T>> key, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> invocation);
+ method public static void performSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> key);
}
public final class AnimationClockTestRule implements org.junit.rules.TestRule {
@@ -160,17 +166,17 @@
}
public final class FiltersKt {
- method public static androidx.ui.test.SemanticsMatcher hasAnyAncestorThat(androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsMatcher hasAnyChildThat(androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsMatcher hasAnyDescendantThat(androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsMatcher hasAnySiblingThat(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnyAncestor(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnyChild(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnyDescendant(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnySibling(androidx.ui.test.SemanticsMatcher matcher);
method public static androidx.ui.test.SemanticsMatcher hasClickAction();
method public static androidx.ui.test.SemanticsMatcher hasImeAction(androidx.ui.input.ImeAction actionType);
method public static androidx.ui.test.SemanticsMatcher hasInputMethodsSupport();
method public static androidx.ui.test.SemanticsMatcher hasLabel(String label, boolean ignoreCase = false);
method public static androidx.ui.test.SemanticsMatcher hasNoClickAction();
method public static androidx.ui.test.SemanticsMatcher hasNoScrollAction();
- method public static androidx.ui.test.SemanticsMatcher hasParentThat(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasParent(androidx.ui.test.SemanticsMatcher matcher);
method public static androidx.ui.test.SemanticsMatcher hasRangeInfo(androidx.ui.semantics.AccessibilityRangeInfo rangeInfo);
method public static androidx.ui.test.SemanticsMatcher hasScrollAction();
method public static androidx.ui.test.SemanticsMatcher hasSubstring(String substring, boolean ignoreCase = false);
@@ -194,22 +200,37 @@
}
public final class FindersKt {
- method public static androidx.ui.test.SemanticsNodeInteraction find(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAll(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByTag(String testTag, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findBySubstring(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findByTag(String testTag, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findRoot(boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction find(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAll(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByTag(String testTag, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findBySubstring(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findByTag(String testTag, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findRoot(boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodes(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodesWithLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodesWithTag(String testTag, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodesWithText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNode(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithSubstring(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithTag(String testTag, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onRoot(boolean useUnmergedTree = false);
}
public final class GestureScope extends androidx.ui.test.BaseGestureScope {
}
public final class GestureScopeKt {
+ method public static void cancel(androidx.ui.test.PartialGestureScope);
+ method public static void click(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center);
+ method public static void doubleClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration delay = androidx.ui.test.GestureScopeKt.doubleClickDelay);
+ method public static void down(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method public static void down(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
method public static inline float getBottom(androidx.ui.test.BaseGestureScope);
method public static androidx.ui.geometry.Offset getBottomCenter(androidx.ui.test.BaseGestureScope);
method public static androidx.ui.geometry.Offset getBottomLeft(androidx.ui.test.BaseGestureScope);
@@ -230,32 +251,46 @@
method public static androidx.ui.geometry.Offset getTopRight(androidx.ui.test.BaseGestureScope);
method public static inline int getWidth(androidx.ui.test.BaseGestureScope);
method public static androidx.ui.geometry.Offset localToGlobal(androidx.ui.test.BaseGestureScope, androidx.ui.geometry.Offset position);
+ method public static void longClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration duration = androidx.ui.core.gesture.ConstantsKt.LongPressTimeout + 100.milliseconds);
+ method public static void move(androidx.ui.test.PartialGestureScope);
+ method public static void moveBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
+ method public static void moveBy(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset delta);
method public static void movePointerBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
method public static void movePointerTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method public static void moveTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method public static void moveTo(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
method public static androidx.ui.geometry.Offset percentOffset(androidx.ui.test.BaseGestureScope, @FloatRange(from=-1.0, to=1.0) float x = 0f, @FloatRange(from=-1.0, to=1.0) float y = 0f);
- method public static void sendCancel(androidx.ui.test.PartialGestureScope);
- method public static void sendClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center);
- method public static void sendDoubleClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration delay = androidx.ui.test.GestureScopeKt.doubleClickDelay);
- method public static void sendDown(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
- method public static void sendDown(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
- method public static void sendLongClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration duration = androidx.ui.core.gesture.ConstantsKt.LongPressTimeout + 100.milliseconds);
- method public static void sendMove(androidx.ui.test.PartialGestureScope);
- method public static void sendMoveBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
- method public static void sendMoveBy(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset delta);
- method public static void sendMoveTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
- method public static void sendMoveTo(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
- method public static void sendPinch(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start0, androidx.ui.geometry.Offset end0, androidx.ui.geometry.Offset start1, androidx.ui.geometry.Offset end1, androidx.ui.unit.Duration duration = 400.milliseconds);
- method public static void sendSwipe(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, androidx.ui.unit.Duration duration = 200.milliseconds);
- method public static void sendSwipeDown(androidx.ui.test.GestureScope);
- method public static void sendSwipeLeft(androidx.ui.test.GestureScope);
- method public static void sendSwipeRight(androidx.ui.test.GestureScope);
- method public static void sendSwipeUp(androidx.ui.test.GestureScope);
- method public static void sendSwipeWithVelocity(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, @FloatRange(from=0.0) float endVelocity, androidx.ui.unit.Duration duration = 200.milliseconds);
- method public static void sendUp(androidx.ui.test.PartialGestureScope, int pointerId = 0);
+ method public static void pinch(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start0, androidx.ui.geometry.Offset end0, androidx.ui.geometry.Offset start1, androidx.ui.geometry.Offset end1, androidx.ui.unit.Duration duration = 400.milliseconds);
+ method @Deprecated public static void sendCancel(androidx.ui.test.PartialGestureScope);
+ method @Deprecated public static void sendClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center);
+ method @Deprecated public static void sendDoubleClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration delay = androidx.ui.test.GestureScopeKt.doubleClickDelay);
+ method @Deprecated public static void sendDown(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendDown(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendLongClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration duration = androidx.ui.core.gesture.ConstantsKt.LongPressTimeout + 100.milliseconds);
+ method @Deprecated public static void sendMove(androidx.ui.test.PartialGestureScope);
+ method @Deprecated public static void sendMoveBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
+ method @Deprecated public static void sendMoveBy(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset delta);
+ method @Deprecated public static void sendMoveTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendMoveTo(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendPinch(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start0, androidx.ui.geometry.Offset end0, androidx.ui.geometry.Offset start1, androidx.ui.geometry.Offset end1, androidx.ui.unit.Duration duration = 400.milliseconds);
+ method @Deprecated public static void sendSwipe(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method @Deprecated public static void sendSwipeDown(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeLeft(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeRight(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeUp(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeWithVelocity(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, @FloatRange(from=0.0) float endVelocity, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method @Deprecated public static void sendUp(androidx.ui.test.PartialGestureScope, int pointerId = 0);
+ method public static void swipe(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method public static void swipeDown(androidx.ui.test.GestureScope);
+ method public static void swipeLeft(androidx.ui.test.GestureScope);
+ method public static void swipeRight(androidx.ui.test.GestureScope);
+ method public static void swipeUp(androidx.ui.test.GestureScope);
+ method public static void swipeWithVelocity(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, @FloatRange(from=0.0) float endVelocity, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method public static void up(androidx.ui.test.PartialGestureScope, int pointerId = 0);
}
public final class KeyInputHelpersKt {
- method public static boolean doSendKeyEvent(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.core.keyinput.KeyEvent2 keyEvent);
+ method public static boolean performKeyPress(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.core.keyinput.KeyEvent2 keyEvent);
}
public final class OutputKt {
@@ -275,17 +310,17 @@
}
public final class SelectorsKt {
- method public static androidx.ui.test.SemanticsNodeInteractionCollection ancestors(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction child(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction childAt(androidx.ui.test.SemanticsNodeInteraction, int index);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection children(androidx.ui.test.SemanticsNodeInteraction);
method public static androidx.ui.test.SemanticsNodeInteractionCollection filter(androidx.ui.test.SemanticsNodeInteractionCollection, androidx.ui.test.SemanticsMatcher matcher);
method public static androidx.ui.test.SemanticsNodeInteraction filterToOne(androidx.ui.test.SemanticsNodeInteractionCollection, androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsNodeInteraction first(androidx.ui.test.SemanticsNodeInteractionCollection);
- method public static androidx.ui.test.SemanticsNodeInteraction last(androidx.ui.test.SemanticsNodeInteractionCollection);
- method public static androidx.ui.test.SemanticsNodeInteraction parent(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction sibling(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection siblings(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAncestors(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onChild(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onChildAt(androidx.ui.test.SemanticsNodeInteraction, int index);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onChildren(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onFirst(androidx.ui.test.SemanticsNodeInteractionCollection);
+ method public static androidx.ui.test.SemanticsNodeInteraction onLast(androidx.ui.test.SemanticsNodeInteractionCollection);
+ method public static androidx.ui.test.SemanticsNodeInteraction onParent(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onSibling(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onSiblings(androidx.ui.test.SemanticsNodeInteraction);
}
public final class SemanticsMatcher {
@@ -349,10 +384,14 @@
}
public final class TextActionsKt {
- method public static void doClearText(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
- method public static void doReplaceText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
- method public static void doSendImeAction(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
- method public static void doSendText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doClearText(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doReplaceText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doSendImeAction(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doSendText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method public static void performImeAction(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method public static void performTextClearance(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method public static void performTextInput(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method public static void performTextReplacement(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
}
}
diff --git a/ui/ui-test/api/restricted_current.txt b/ui/ui-test/api/restricted_current.txt
index 7104f4a..e992fff 100644
--- a/ui/ui-test/api/restricted_current.txt
+++ b/ui/ui-test/api/restricted_current.txt
@@ -2,12 +2,18 @@
package androidx.ui.test {
public final class ActionsKt {
- method public static <T extends kotlin.Function<? extends java.lang.Boolean>> void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<T>> key, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> invocation);
- method public static void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> key);
- method public static androidx.ui.test.SemanticsNodeInteraction doClick(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction doGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.GestureScope,kotlin.Unit> block);
- method public static androidx.ui.test.SemanticsNodeInteraction doPartialGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.PartialGestureScope,kotlin.Unit> block);
- method public static androidx.ui.test.SemanticsNodeInteraction doScrollTo(androidx.ui.test.SemanticsNodeInteraction);
+ method @Deprecated public static <T extends kotlin.Function<? extends java.lang.Boolean>> void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<T>> key, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> invocation);
+ method @Deprecated public static void callSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> key);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doClick(androidx.ui.test.SemanticsNodeInteraction);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.GestureScope,kotlin.Unit> block);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doPartialGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.PartialGestureScope,kotlin.Unit> block);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction doScrollTo(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction performClick(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction performGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.GestureScope,kotlin.Unit> block);
+ method public static androidx.ui.test.SemanticsNodeInteraction performPartialGesture(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super androidx.ui.test.PartialGestureScope,kotlin.Unit> block);
+ method public static androidx.ui.test.SemanticsNodeInteraction performScrollTo(androidx.ui.test.SemanticsNodeInteraction);
+ method public static <T extends kotlin.Function<? extends java.lang.Boolean>> void performSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<T>> key, kotlin.jvm.functions.Function1<? super T,kotlin.Unit> invocation);
+ method public static void performSemanticsAction(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.semantics.AccessibilityAction<kotlin.jvm.functions.Function0<java.lang.Boolean>>> key);
}
public final class AnimationClockTestRule implements org.junit.rules.TestRule {
@@ -160,17 +166,17 @@
}
public final class FiltersKt {
- method public static androidx.ui.test.SemanticsMatcher hasAnyAncestorThat(androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsMatcher hasAnyChildThat(androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsMatcher hasAnyDescendantThat(androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsMatcher hasAnySiblingThat(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnyAncestor(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnyChild(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnyDescendant(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasAnySibling(androidx.ui.test.SemanticsMatcher matcher);
method public static androidx.ui.test.SemanticsMatcher hasClickAction();
method public static androidx.ui.test.SemanticsMatcher hasImeAction(androidx.ui.input.ImeAction actionType);
method public static androidx.ui.test.SemanticsMatcher hasInputMethodsSupport();
method public static androidx.ui.test.SemanticsMatcher hasLabel(String label, boolean ignoreCase = false);
method public static androidx.ui.test.SemanticsMatcher hasNoClickAction();
method public static androidx.ui.test.SemanticsMatcher hasNoScrollAction();
- method public static androidx.ui.test.SemanticsMatcher hasParentThat(androidx.ui.test.SemanticsMatcher matcher);
+ method public static androidx.ui.test.SemanticsMatcher hasParent(androidx.ui.test.SemanticsMatcher matcher);
method public static androidx.ui.test.SemanticsMatcher hasRangeInfo(androidx.ui.semantics.AccessibilityRangeInfo rangeInfo);
method public static androidx.ui.test.SemanticsMatcher hasScrollAction();
method public static androidx.ui.test.SemanticsMatcher hasSubstring(String substring, boolean ignoreCase = false);
@@ -194,22 +200,37 @@
}
public final class FindersKt {
- method public static androidx.ui.test.SemanticsNodeInteraction find(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAll(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByTag(String testTag, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findBySubstring(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findByTag(String testTag, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
- method public static androidx.ui.test.SemanticsNodeInteraction findRoot(boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction find(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAll(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByTag(String testTag, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteractionCollection findAllByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findByLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findBySubstring(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findByTag(String testTag, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findByText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method @Deprecated public static androidx.ui.test.SemanticsNodeInteraction findRoot(boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodes(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodesWithLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodesWithTag(String testTag, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAllNodesWithText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNode(androidx.ui.test.SemanticsMatcher matcher, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithLabel(String label, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithSubstring(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithTag(String testTag, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onNodeWithText(String text, boolean ignoreCase = false, boolean useUnmergedTree = false);
+ method public static androidx.ui.test.SemanticsNodeInteraction onRoot(boolean useUnmergedTree = false);
}
public final class GestureScope extends androidx.ui.test.BaseGestureScope {
}
public final class GestureScopeKt {
+ method public static void cancel(androidx.ui.test.PartialGestureScope);
+ method public static void click(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center);
+ method public static void doubleClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration delay = androidx.ui.test.GestureScopeKt.doubleClickDelay);
+ method public static void down(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method public static void down(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
method public static inline float getBottom(androidx.ui.test.BaseGestureScope);
method public static androidx.ui.geometry.Offset getBottomCenter(androidx.ui.test.BaseGestureScope);
method public static androidx.ui.geometry.Offset getBottomLeft(androidx.ui.test.BaseGestureScope);
@@ -230,32 +251,46 @@
method public static androidx.ui.geometry.Offset getTopRight(androidx.ui.test.BaseGestureScope);
method public static inline int getWidth(androidx.ui.test.BaseGestureScope);
method public static androidx.ui.geometry.Offset localToGlobal(androidx.ui.test.BaseGestureScope, androidx.ui.geometry.Offset position);
+ method public static void longClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration duration = androidx.ui.core.gesture.ConstantsKt.LongPressTimeout + 100.milliseconds);
+ method public static void move(androidx.ui.test.PartialGestureScope);
+ method public static void moveBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
+ method public static void moveBy(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset delta);
method public static void movePointerBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
method public static void movePointerTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method public static void moveTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method public static void moveTo(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
method public static androidx.ui.geometry.Offset percentOffset(androidx.ui.test.BaseGestureScope, @FloatRange(from=-1.0, to=1.0) float x = 0f, @FloatRange(from=-1.0, to=1.0) float y = 0f);
- method public static void sendCancel(androidx.ui.test.PartialGestureScope);
- method public static void sendClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center);
- method public static void sendDoubleClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration delay = androidx.ui.test.GestureScopeKt.doubleClickDelay);
- method public static void sendDown(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
- method public static void sendDown(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
- method public static void sendLongClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration duration = androidx.ui.core.gesture.ConstantsKt.LongPressTimeout + 100.milliseconds);
- method public static void sendMove(androidx.ui.test.PartialGestureScope);
- method public static void sendMoveBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
- method public static void sendMoveBy(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset delta);
- method public static void sendMoveTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
- method public static void sendMoveTo(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
- method public static void sendPinch(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start0, androidx.ui.geometry.Offset end0, androidx.ui.geometry.Offset start1, androidx.ui.geometry.Offset end1, androidx.ui.unit.Duration duration = 400.milliseconds);
- method public static void sendSwipe(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, androidx.ui.unit.Duration duration = 200.milliseconds);
- method public static void sendSwipeDown(androidx.ui.test.GestureScope);
- method public static void sendSwipeLeft(androidx.ui.test.GestureScope);
- method public static void sendSwipeRight(androidx.ui.test.GestureScope);
- method public static void sendSwipeUp(androidx.ui.test.GestureScope);
- method public static void sendSwipeWithVelocity(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, @FloatRange(from=0.0) float endVelocity, androidx.ui.unit.Duration duration = 200.milliseconds);
- method public static void sendUp(androidx.ui.test.PartialGestureScope, int pointerId = 0);
+ method public static void pinch(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start0, androidx.ui.geometry.Offset end0, androidx.ui.geometry.Offset start1, androidx.ui.geometry.Offset end1, androidx.ui.unit.Duration duration = 400.milliseconds);
+ method @Deprecated public static void sendCancel(androidx.ui.test.PartialGestureScope);
+ method @Deprecated public static void sendClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center);
+ method @Deprecated public static void sendDoubleClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration delay = androidx.ui.test.GestureScopeKt.doubleClickDelay);
+ method @Deprecated public static void sendDown(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendDown(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendLongClick(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset position = center, androidx.ui.unit.Duration duration = androidx.ui.core.gesture.ConstantsKt.LongPressTimeout + 100.milliseconds);
+ method @Deprecated public static void sendMove(androidx.ui.test.PartialGestureScope);
+ method @Deprecated public static void sendMoveBy(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset delta);
+ method @Deprecated public static void sendMoveBy(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset delta);
+ method @Deprecated public static void sendMoveTo(androidx.ui.test.PartialGestureScope, int pointerId, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendMoveTo(androidx.ui.test.PartialGestureScope, androidx.ui.geometry.Offset position);
+ method @Deprecated public static void sendPinch(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start0, androidx.ui.geometry.Offset end0, androidx.ui.geometry.Offset start1, androidx.ui.geometry.Offset end1, androidx.ui.unit.Duration duration = 400.milliseconds);
+ method @Deprecated public static void sendSwipe(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method @Deprecated public static void sendSwipeDown(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeLeft(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeRight(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeUp(androidx.ui.test.GestureScope);
+ method @Deprecated public static void sendSwipeWithVelocity(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, @FloatRange(from=0.0) float endVelocity, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method @Deprecated public static void sendUp(androidx.ui.test.PartialGestureScope, int pointerId = 0);
+ method public static void swipe(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method public static void swipeDown(androidx.ui.test.GestureScope);
+ method public static void swipeLeft(androidx.ui.test.GestureScope);
+ method public static void swipeRight(androidx.ui.test.GestureScope);
+ method public static void swipeUp(androidx.ui.test.GestureScope);
+ method public static void swipeWithVelocity(androidx.ui.test.GestureScope, androidx.ui.geometry.Offset start, androidx.ui.geometry.Offset end, @FloatRange(from=0.0) float endVelocity, androidx.ui.unit.Duration duration = 200.milliseconds);
+ method public static void up(androidx.ui.test.PartialGestureScope, int pointerId = 0);
}
public final class KeyInputHelpersKt {
- method public static boolean doSendKeyEvent(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.core.keyinput.KeyEvent2 keyEvent);
+ method public static boolean performKeyPress(androidx.ui.test.SemanticsNodeInteraction, androidx.ui.core.keyinput.KeyEvent2 keyEvent);
}
public final class OutputKt {
@@ -275,17 +310,17 @@
}
public final class SelectorsKt {
- method public static androidx.ui.test.SemanticsNodeInteractionCollection ancestors(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction child(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction childAt(androidx.ui.test.SemanticsNodeInteraction, int index);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection children(androidx.ui.test.SemanticsNodeInteraction);
method public static androidx.ui.test.SemanticsNodeInteractionCollection filter(androidx.ui.test.SemanticsNodeInteractionCollection, androidx.ui.test.SemanticsMatcher matcher);
method public static androidx.ui.test.SemanticsNodeInteraction filterToOne(androidx.ui.test.SemanticsNodeInteractionCollection, androidx.ui.test.SemanticsMatcher matcher);
- method public static androidx.ui.test.SemanticsNodeInteraction first(androidx.ui.test.SemanticsNodeInteractionCollection);
- method public static androidx.ui.test.SemanticsNodeInteraction last(androidx.ui.test.SemanticsNodeInteractionCollection);
- method public static androidx.ui.test.SemanticsNodeInteraction parent(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteraction sibling(androidx.ui.test.SemanticsNodeInteraction);
- method public static androidx.ui.test.SemanticsNodeInteractionCollection siblings(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onAncestors(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onChild(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onChildAt(androidx.ui.test.SemanticsNodeInteraction, int index);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onChildren(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onFirst(androidx.ui.test.SemanticsNodeInteractionCollection);
+ method public static androidx.ui.test.SemanticsNodeInteraction onLast(androidx.ui.test.SemanticsNodeInteractionCollection);
+ method public static androidx.ui.test.SemanticsNodeInteraction onParent(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteraction onSibling(androidx.ui.test.SemanticsNodeInteraction);
+ method public static androidx.ui.test.SemanticsNodeInteractionCollection onSiblings(androidx.ui.test.SemanticsNodeInteraction);
}
public final class SemanticsMatcher {
@@ -349,10 +384,14 @@
}
public final class TextActionsKt {
- method public static void doClearText(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
- method public static void doReplaceText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
- method public static void doSendImeAction(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
- method public static void doSendText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doClearText(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doReplaceText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doSendImeAction(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method @Deprecated public static void doSendText(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method public static void performImeAction(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method public static void performTextClearance(androidx.ui.test.SemanticsNodeInteraction, boolean alreadyHasFocus = false);
+ method public static void performTextInput(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
+ method public static void performTextReplacement(androidx.ui.test.SemanticsNodeInteraction, String text, boolean alreadyHasFocus = false);
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/AssertExistsTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/AssertExistsTest.kt
index 9902d3a..dd2f27a 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/AssertExistsTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/AssertExistsTest.kt
@@ -61,28 +61,28 @@
}
}
- findByText("Hello")
+ onNodeWithText("Hello")
.assertExists()
expectAssertionError(true) {
- findByText("Hello")
+ onNodeWithText("Hello")
.assertDoesNotExist()
}
- val cachedResult = findByText("Hello")
+ val cachedResult = onNodeWithText("Hello")
// Hide
- findByTag("MyButton")
- .doClick()
+ onNodeWithTag("MyButton")
+ .performClick()
- findByText("Hello")
+ onNodeWithText("Hello")
.assertDoesNotExist()
cachedResult
.assertDoesNotExist()
expectAssertionError(true) {
- findByText("Hello")
+ onNodeWithText("Hello")
.assertExists()
}
@@ -91,14 +91,14 @@
}
// Show
- findByTag("MyButton")
- .doClick()
+ onNodeWithTag("MyButton")
+ .performClick()
- findByText("Hello")
+ onNodeWithText("Hello")
.assertExists()
expectAssertionError(true) {
- findByText("Hello")
+ onNodeWithText("Hello")
.assertDoesNotExist()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/AssertsTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/AssertsTest.kt
index 9eb6a66..d035cc5 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/AssertsTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/AssertsTest.kt
@@ -38,40 +38,40 @@
@Test
fun assertIsNotHidden_forVisibleElement_isOk() {
composeTestRule.setContent {
- BoundaryNode { testTag = "test"; hidden = false }
+ BoundaryNode { testTag = "test" }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsNotHidden()
}
@Test(expected = AssertionError::class)
fun assertIsNotHidden_forHiddenElement_throwsError() {
composeTestRule.setContent {
- BoundaryNode { testTag = "test"; hidden = true }
+ BoundaryNode { testTag = "test"; hidden() }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsNotHidden()
}
@Test
fun assertIsHidden_forHiddenElement_isOk() {
composeTestRule.setContent {
- BoundaryNode { testTag = "test"; hidden = true }
+ BoundaryNode { testTag = "test"; hidden() }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsHidden()
}
@Test(expected = AssertionError::class)
fun assertIsHidden_forNotHiddenElement_throwsError() {
composeTestRule.setContent {
- BoundaryNode { testTag = "test"; hidden = false }
+ BoundaryNode { testTag = "test" }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsHidden()
}
@@ -81,7 +81,7 @@
BoundaryNode { testTag = "test"; toggleableState = ToggleableState.On }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsOn()
}
@@ -91,7 +91,7 @@
BoundaryNode { testTag = "test"; toggleableState = ToggleableState.Off }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsOn()
}
@@ -101,7 +101,7 @@
BoundaryNode { testTag = "test" }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsOn()
}
@@ -111,7 +111,7 @@
BoundaryNode { testTag = "test"; toggleableState = ToggleableState.On }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsOff()
}
@@ -121,7 +121,7 @@
BoundaryNode { testTag = "test"; toggleableState = ToggleableState.Off }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsOff()
}
@@ -131,7 +131,7 @@
BoundaryNode { testTag = "test"; }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsOff()
}
@@ -141,7 +141,7 @@
BoundaryNode { testTag = "test"; selected = false }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsSelected()
}
@@ -151,7 +151,7 @@
BoundaryNode { testTag = "test"; selected = true }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsSelected()
}
@@ -161,7 +161,7 @@
BoundaryNode { testTag = "test"; }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsSelected()
}
@@ -171,7 +171,7 @@
BoundaryNode { testTag = "test"; selected = true }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsUnselected()
}
@@ -181,7 +181,7 @@
BoundaryNode { testTag = "test"; selected = false }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsUnselected()
}
@@ -191,27 +191,26 @@
BoundaryNode { testTag = "test"; }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsUnselected()
}
-
@Test(expected = AssertionError::class)
fun assertItemInExclusiveGroup_forItemNotInGroup_throwsError() {
composeTestRule.setContent {
BoundaryNode { testTag = "test"; inMutuallyExclusiveGroup = false }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsInMutuallyExclusiveGroup()
}
@Test(expected = AssertionError::class)
fun assertItemInExclusiveGroup_forItemWithoutProperty_throwsError() {
composeTestRule.setContent {
- BoundaryNode { testTag = "test"; }
+ BoundaryNode { testTag = "test" }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsInMutuallyExclusiveGroup()
}
@@ -221,12 +220,12 @@
BoundaryNode { testTag = "test"; inMutuallyExclusiveGroup = true }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsInMutuallyExclusiveGroup()
}
@Composable
- fun BoundaryNode(props: (SemanticsPropertyReceiver.() -> Unit)? = null) {
+ fun BoundaryNode(props: (SemanticsPropertyReceiver.() -> Unit)) {
Column(Modifier.semantics(properties = props)) {}
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/BitmapCapturingTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/BitmapCapturingTest.kt
index e5a0e3d..e51c8d3 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/BitmapCapturingTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/BitmapCapturingTest.kt
@@ -79,7 +79,7 @@
composeCheckerboard()
var calledCount = 0
- findByTag(tag11)
+ onNodeWithTag(tag11)
.captureToBitmap()
.assertPixels(expectedSize = IntSize(100, 50)) {
calledCount++
@@ -87,17 +87,17 @@
}
assertThat(calledCount).isEqualTo(100 * 50)
- findByTag(tag12)
+ onNodeWithTag(tag12)
.captureToBitmap()
.assertPixels(expectedSize = IntSize(100, 50)) {
color12
}
- findByTag(tag21)
+ onNodeWithTag(tag21)
.captureToBitmap()
.assertPixels(expectedSize = IntSize(100, 50)) {
color21
}
- findByTag(tag22)
+ onNodeWithTag(tag22)
.captureToBitmap()
.assertPixels(expectedSize = IntSize(100, 50)) {
color22
@@ -108,7 +108,7 @@
fun captureRootContainer_checkSizeAndColors() {
composeCheckerboard()
- findByTag(rootTag)
+ onNodeWithTag(rootTag)
.captureToBitmap()
.assertPixels(expectedSize = IntSize(200, 100)) {
if (it.y >= 100 || it.x >= 200) {
@@ -122,7 +122,7 @@
fun assertWrongColor_expectException() {
composeCheckerboard()
- findByTag(tag11)
+ onNodeWithTag(tag11)
.captureToBitmap()
.assertPixels(expectedSize = IntSize(100, 50)) {
color22 // Assuming wrong color
@@ -133,7 +133,7 @@
fun assertWrongSize_expectException() {
composeCheckerboard()
- findByTag(tag11)
+ onNodeWithTag(tag11)
.captureToBitmap()
.assertPixels(expectedSize = IntSize(10, 10)) {
color21
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/CallSemanticsActionTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/CallSemanticsActionTest.kt
index 920fa85..e58171a 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/CallSemanticsActionTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/CallSemanticsActionTest.kt
@@ -48,14 +48,14 @@
}
}
- findByLabel("Nothing")
+ onNodeWithLabel("Nothing")
.assertExists()
- .callSemanticsAction(MyActions.SetString) { it("Hello") }
+ .performSemanticsAction(MyActions.SetString) { it("Hello") }
- findByLabel("Nothing")
+ onNodeWithLabel("Nothing")
.assertDoesNotExist()
- findByLabel("Hello")
+ onNodeWithLabel("Hello")
.assertExists()
}
@@ -68,7 +68,7 @@
}
@Composable
- fun BoundaryNode(props: (SemanticsPropertyReceiver.() -> Unit)? = null) {
+ fun BoundaryNode(props: (SemanticsPropertyReceiver.() -> Unit)) {
Column(Modifier.semantics(properties = props)) {}
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/CustomActivityTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/CustomActivityTest.kt
index e789401..15cae35 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/CustomActivityTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/CustomActivityTest.kt
@@ -59,6 +59,6 @@
@Test
fun launchCustomActivity() {
- findByText("Hello").assertExists()
+ onNodeWithText("Hello").assertExists()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/ErrorMessagesTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/ErrorMessagesTest.kt
index e43d92d..4036a2a 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/ErrorMessagesTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/ErrorMessagesTest.kt
@@ -20,7 +20,6 @@
import androidx.compose.state
import androidx.test.filters.MediumTest
import androidx.ui.core.Modifier
-import androidx.ui.core.semantics.semantics
import androidx.ui.core.testTag
import androidx.ui.foundation.Box
import androidx.ui.foundation.Text
@@ -53,13 +52,13 @@
"Failed to assert the following: (OnClick is defined)\n" +
"Semantics of the node:\n" +
"Node #X at (X, X, X, X)px, Tag: 'MyButton'\n" +
- "Enabled = 'false'\n" +
+ "Disabled = 'kotlin.Unit'\n" +
"Text = 'Toggle'\n" +
"MergeDescendants = 'true'\n" +
"Has 1 sibling\n" +
"Selector used: (TestTag = 'MyButton')"
) {
- findByTag("MyButton")
+ onNodeWithTag("MyButton")
.assertHasClickAction()
}
}
@@ -75,7 +74,7 @@
"Reason: Expected exactly '1' node but could not find any node that satisfies: " +
"(TestTag = 'MyButton3')"
) {
- findByTag("MyButton3")
+ onNodeWithTag("MyButton3")
.assertExists()
}
}
@@ -91,8 +90,8 @@
"Reason: Expected exactly '1' node but could not find any node that satisfies: " +
"(TestTag = 'MyButton3')"
) {
- findByTag("MyButton3")
- .doClick()
+ onNodeWithTag("MyButton3")
+ .performClick()
}
}
@@ -107,8 +106,8 @@
"Reason: Expected exactly '1' node but could not find any node that satisfies: " +
"((TestTag = 'MyButton3') && (OnClick is defined))"
) {
- find(hasTestTag("MyButton3") and hasClickAction())
- .doClick()
+ onNode(hasTestTag("MyButton3") and hasClickAction())
+ .performClick()
}
}
@@ -125,8 +124,8 @@
"Nodes found:\n" +
"1) Node #X at (X, X, X, X)px, Tag: 'MyButton'"
) {
- findByText("Toggle")
- .doClick()
+ onNodeWithText("Toggle")
+ .performClick()
}
}
@@ -137,11 +136,11 @@
}
expectErrorMessageStartsWith("" +
- "Failed to call OnClick action as it is not defined on the node.\n" +
+ "Failed to perform OnClick action as it is not defined on the node.\n" +
"Semantics of the node:"
) {
- findByTag("MyButton")
- .callSemanticsAction(SemanticsActions.OnClick)
+ onNodeWithTag("MyButton")
+ .performSemanticsAction(SemanticsActions.OnClick)
}
}
@@ -152,12 +151,12 @@
}
expectErrorMessageStartsWith("" +
- "Failed to call OnClick action.\n" +
+ "Failed to perform OnClick action.\n" +
"Reason: Expected exactly '1' node but could not find any node that satisfies: " +
"(TestTag = 'MyButton3')"
) {
- findByTag("MyButton3")
- .callSemanticsAction(SemanticsActions.OnClick)
+ onNodeWithTag("MyButton3")
+ .performSemanticsAction(SemanticsActions.OnClick)
}
}
@@ -174,7 +173,7 @@
"Node found:\n" +
"Node #X at (X, X, X, X)px, Tag: 'MyButton'"
) {
- findByTag("MyButton")
+ onNodeWithTag("MyButton")
.assertDoesNotExist()
}
}
@@ -192,7 +191,7 @@
"Nodes found:\n" +
"1) Node #X at (X, X, X, X)px"
) {
- findAllByText("Toggle")
+ onAllNodesWithText("Toggle")
.assertCountEquals(3)
}
}
@@ -208,7 +207,7 @@
"Reason: Expected '3' nodes but could not find any node that satisfies: " +
"(Text = 'Toggle2' (ignoreCase: false))"
) {
- findAllByText("Toggle2")
+ onAllNodesWithText("Toggle2")
.assertCountEquals(3)
}
}
@@ -219,11 +218,11 @@
ComposeTextToHideCase()
}
- val node = findByText("Hello")
+ val node = onNodeWithText("Hello")
.assertExists()
- findByTag("MyButton")
- .doClick()
+ onNodeWithTag("MyButton")
+ .performClick()
expectErrorMessage("" +
"Failed to perform a gesture.\n" +
@@ -233,7 +232,7 @@
"Has 1 sibling\n" +
"Original selector: Text = 'Hello' (ignoreCase: false)"
) {
- node.doClick()
+ node.performClick()
}
}
@@ -243,12 +242,12 @@
ComposeTextToHideCase()
}
- val node = findByText("Hello")
+ val node = onNodeWithText("Hello")
.assertExists()
// Hide text
- findByTag("MyButton")
- .doClick()
+ onNodeWithTag("MyButton")
+ .performClick()
expectErrorMessage("" +
"Failed: assertExists.\n" +
@@ -268,12 +267,12 @@
ComposeTextToHideCase()
}
- val node = findByText("Hello")
+ val node = onNodeWithText("Hello")
.assertExists()
// Hide text
- findByTag("MyButton")
- .doClick()
+ onNodeWithTag("MyButton")
+ .performClick()
expectErrorMessage("" +
"Failed to assert the following: (OnClick is defined)\n" +
@@ -325,11 +324,8 @@
onClick: (() -> Unit)? = null,
children: @Composable () -> Unit
) {
- // Since we're adding layouts in between the clickable layer and the content, we need to
- // merge all descendants, or we'll get multiple nodes
Surface {
- Box(modifier.semantics(mergeAllDescendants = true)
- .clickable(onClick = onClick ?: {}, enabled = onClick != null)) {
+ Box(modifier.clickable(onClick = onClick ?: {}, enabled = onClick != null)) {
Box(children = children)
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/FindAllTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/FindAllTest.kt
index 821f6f3..494ac91 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/FindAllTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/FindAllTest.kt
@@ -47,7 +47,7 @@
}
}
- findAll(isOn())
+ onAllNodes(isOn())
.assertCountEquals(2)
.apply {
get(0).assertIsOn()
@@ -76,14 +76,14 @@
}
}
- findAll(isToggleable())
+ onAllNodes(isToggleable())
.assertCountEquals(2)
.apply {
get(0)
- .doClick()
+ .performClick()
.assertIsOn()
get(1)
- .doClick()
+ .performClick()
.assertIsOn()
}
}
@@ -101,7 +101,7 @@
}
}
- findAll(isOff())
+ onAllNodes(isOff())
.assertCountEquals(0)
}
@@ -127,9 +127,9 @@
}
}
- findAll(isToggleable()).apply {
+ onAllNodes(isToggleable()).apply {
get(0)
- .doClick()
+ .performClick()
.assertIsOn()
get(1)
.assertIsOff()
@@ -168,15 +168,15 @@
}
}
- findAll(isToggleable())
+ onAllNodes(isToggleable())
.assertCountEquals(2).apply {
get(0)
.assertIsOff()
- .doClick()
+ .performClick()
.assertIsOn()
}
- findAll(isToggleable())
+ onAllNodes(isToggleable())
.assertCountEquals(3).apply {
get(2)
.assertIsOff()
@@ -209,12 +209,12 @@
}
}
- findAll(isToggleable())
+ onAllNodes(isToggleable())
.assertCountEquals(2)
.apply {
get(0)
.assertIsOff()
- .doClick()
+ .performClick()
.assertIsOn()
get(1)
.assertDoesNotExist()
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/FindInPopupTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/FindInPopupTest.kt
index 326cbcc..655a4702 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/FindInPopupTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/FindInPopupTest.kt
@@ -45,7 +45,7 @@
Box(Modifier.testTag(popupTag))
}
}
- findByTag(contentTag).assertExists()
- findByTag(popupTag).assertExists()
+ onNodeWithTag(contentTag).assertExists()
+ onNodeWithTag(popupTag).assertExists()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/FindersTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/FindersTest.kt
index 4a2ceb7..0084446 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/FindersTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/FindersTest.kt
@@ -45,7 +45,7 @@
BoundaryNode { testTag = "not_myTestTag" }
}
- findAll(hasTestTag("myTestTag")).assertCountEquals(0)
+ onAllNodes(hasTestTag("myTestTag")).assertCountEquals(0)
}
@Test
@@ -55,9 +55,9 @@
BoundaryNode { testTag = "myTestTag2" }
}
- findAll(hasTestTag("myTestTag"))
+ onAllNodes(hasTestTag("myTestTag"))
.assertCountEquals(1)
- .first()
+ .onFirst()
.assert(hasTestTag("myTestTag"))
}
@@ -68,7 +68,7 @@
BoundaryNode { testTag = "myTestTag" }
}
- findAll(hasTestTag("myTestTag"))
+ onAllNodes(hasTestTag("myTestTag"))
.assertCountEquals(2)
.apply {
get(0).assert(hasTestTag("myTestTag"))
@@ -82,7 +82,7 @@
BoundaryNode { accessibilityLabel = "Hello World" }
}
- findByText("Hello World")
+ onNodeWithText("Hello World")
}
@Test(expected = AssertionError::class)
@@ -92,7 +92,7 @@
}
// Need to assert exists or it won't fail
- findByText("World").assertExists()
+ onNodeWithText("World").assertExists()
}
@Test
@@ -101,7 +101,7 @@
BoundaryNode { text = AnnotatedString("Hello World") }
}
- findBySubstring("World")
+ onNodeWithSubstring("World")
}
@Test
@@ -110,7 +110,7 @@
BoundaryNode { text = AnnotatedString("Hello World") }
}
- findBySubstring("world", ignoreCase = true)
+ onNodeWithSubstring("world", ignoreCase = true)
}
@Test
@@ -121,12 +121,12 @@
expectError<AssertionError> {
// Need to assert exists or it won't fetch nodes
- findBySubstring("world").assertExists()
+ onNodeWithSubstring("world").assertExists()
}
}
@Composable
- fun BoundaryNode(props: (SemanticsPropertyReceiver.() -> Unit)? = null) {
+ fun BoundaryNode(props: (SemanticsPropertyReceiver.() -> Unit)) {
Column(Modifier.semantics(properties = props)) {}
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/IsDisplayedTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/IsDisplayedTest.kt
index d2eef00..9a0085d 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/IsDisplayedTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/IsDisplayedTest.kt
@@ -113,7 +113,7 @@
}
}
- findByTag("item0")
+ onNodeWithTag("item0")
.assertIsDisplayed()
}
@@ -125,7 +125,7 @@
}
}
- findByTag("item4")
+ onNodeWithTag("item4")
.assertIsNotDisplayed()
}
@@ -140,14 +140,14 @@
}
}
- findByTag("item0")
+ onNodeWithTag("item0")
.assertIsDisplayed()
runOnIdleCompose {
place = false
}
- findByTag("item0")
+ onNodeWithTag("item0")
.assertIsNotDisplayed()
}
@@ -164,14 +164,14 @@
}
}
- findByTag("item0")
+ onNodeWithTag("item0")
.assertIsDisplayed()
runOnIdleCompose {
place = false
}
- findByTag("item0")
+ onNodeWithTag("item0")
.assertIsNotDisplayed()
}
@@ -183,7 +183,7 @@
}
}
- findByTag("item9")
+ onNodeWithTag("item9")
.assertIsNotDisplayed()
}
@@ -208,14 +208,14 @@
}
onComposeView().check(matches(isDisplayed()))
- findByTag("item0").assertIsDisplayed()
+ onNodeWithTag("item0").assertIsDisplayed()
runOnIdleCompose {
androidComposeView.visibility = View.GONE
}
onComposeView().check(matches(not(isDisplayed())))
- findByTag("item0").assertIsNotDisplayed()
+ onNodeWithTag("item0").assertIsNotDisplayed()
}
@Test
@@ -240,13 +240,13 @@
}
onComposeView().check(matches(isDisplayed()))
- findByTag("item0").assertIsDisplayed()
+ onNodeWithTag("item0").assertIsDisplayed()
runOnIdleCompose {
composeContainer.visibility = View.GONE
}
onComposeView().check(matches(not(isDisplayed())))
- findByTag("item0").assertIsNotDisplayed()
+ onNodeWithTag("item0").assertIsNotDisplayed()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/LateSetContentTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/LateSetContentTest.kt
index aa37c23..52f0e3f 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/LateSetContentTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/LateSetContentTest.kt
@@ -34,7 +34,7 @@
@Test
fun test() {
- findByTag("Node").assertExists()
+ onNodeWithTag("Node").assertExists()
}
class Activity : ComponentActivity() {
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleActivitiesClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleActivitiesClickTest.kt
index d40a5ed..ab19cad 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleActivitiesClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleActivitiesClickTest.kt
@@ -43,7 +43,7 @@
lateinit var activity1: Activity1
composeTestRule.activityRule.scenario.onActivity { activity1 = it }
activity1.startNewActivity()
- findByTag("activity2").doGesture { sendClick() }
+ onNodeWithTag("activity2").performGesture { click() }
val activity2 = getCurrentActivity() as Activity2
assertThat(activity1.recorder.events).isEmpty()
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleActivitiesFindTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleActivitiesFindTest.kt
index 2ba48e4..47d2453 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleActivitiesFindTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleActivitiesFindTest.kt
@@ -35,8 +35,8 @@
@Test
fun test() {
composeTestRule.activityRule.scenario.onActivity { it.startNewActivity() }
- findByTag("activity1").assertDoesNotExist()
- findByTag("activity2").assertExists()
+ onNodeWithTag("activity1").assertDoesNotExist()
+ onNodeWithTag("activity2").assertExists()
}
class Activity1 : TaggedActivity("activity1")
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleComposeRootsTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleComposeRootsTest.kt
index a3f79e6..c20e9f8d 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleComposeRootsTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleComposeRootsTest.kt
@@ -142,21 +142,21 @@
Espresso.onView(withText("Compose 1")).check(matches(isDisplayed()))
Espresso.onView(withText("Compose 2")).check(matches(isDisplayed()))
- findByTag("checkbox1")
- .doClick()
+ onNodeWithTag("checkbox1")
+ .performClick()
.assertIsOn()
- findByTag("checkbox2")
+ onNodeWithTag("checkbox2")
.assertIsOff()
Espresso.onView(withText("Compose 1 - On")).check(matches(isDisplayed()))
Espresso.onView(withText("Compose 2 - Off")).check(matches(isDisplayed()))
- findByTag("checkbox2")
- .doClick()
+ onNodeWithTag("checkbox2")
+ .performClick()
.assertIsOn()
- findByTag("checkbox1")
+ onNodeWithTag("checkbox1")
.assertIsOff()
Espresso.onView(withText("Compose 1 - Off")).check(matches(isDisplayed()))
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/PrintToStringTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/PrintToStringTest.kt
index a997989..afd122c 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/PrintToStringTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/PrintToStringTest.kt
@@ -25,7 +25,7 @@
import androidx.ui.layout.Column
import androidx.ui.material.Button
import androidx.ui.material.MaterialTheme
-import androidx.ui.semantics.enabled
+import androidx.ui.semantics.disabled
import androidx.ui.semantics.testTag
import androidx.ui.test.util.BoundaryNode
import androidx.ui.test.util.expectErrorMessageStartsWith
@@ -53,7 +53,7 @@
"Failed: assertExists.\n" +
"Reason: Expected exactly '1' node but could not find any node that satisfies:"
) {
- findByText("Oops").printToString()
+ onNodeWithText("Oops").printToString()
}
}
@@ -63,7 +63,7 @@
ComposeSimpleCase()
}
- val result = findByText("Hello")
+ val result = onNodeWithText("Hello")
.printToString(maxDepth = 0)
assertThat(obfuscateNodesInfo(result)).isEqualTo("" +
@@ -78,8 +78,8 @@
ComposeSimpleCase()
}
- val result = findRoot()
- .children()
+ val result = onRoot()
+ .onChildren()
.printToString()
assertThat(obfuscateNodesInfo(result)).isEqualTo("" +
@@ -94,8 +94,8 @@
@Test
fun printHierarchy() {
composeTestRule.setContent {
- Column(Modifier.semantics { this.enabled = true; this.testTag = "column" }) {
- Box(Modifier.semantics { this.enabled = true; this.testTag = "box" }) {
+ Column(Modifier.semantics { this.disabled(); this.testTag = "column" }) {
+ Box(Modifier.semantics { this.disabled(); this.testTag = "box" }) {
Button(onClick = {}) {
Text("Button")
}
@@ -104,17 +104,16 @@
}
}
- val result = findRoot()
+ val result = onRoot()
.printToString()
assertThat(obfuscateNodesInfo(result)).isEqualTo("" +
"Node #X at (X, X, X, X)px\n" +
" |-Node #X at (X, X, X, X)px, Tag: 'column'\n" +
- " Enabled = 'true'\n" +
+ " Disabled = 'kotlin.Unit'\n" +
" |-Node #X at (X, X, X, X)px, Tag: 'box'\n" +
- " | Enabled = 'true'\n" +
+ " | Disabled = 'kotlin.Unit'\n" +
" | |-Node #X at (X, X, X, X)px\n" +
- " | Enabled = 'true'\n" +
" | OnClick = 'AccessibilityAction(label=null, action=Function0" +
"<java.lang.Boolean>)'\n" +
" | Text = 'Button'\n" +
@@ -138,8 +137,8 @@
}
}
- val result = findRoot()
- .children()
+ val result = onRoot()
+ .onChildren()
.printToString(maxDepth = 1)
assertThat(obfuscateNodesInfo(result)).isEqualTo("" +
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/ScrollToTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/ScrollToTest.kt
index d59a833..ad45a26 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/ScrollToTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/ScrollToTest.kt
@@ -25,7 +25,7 @@
import androidx.ui.graphics.Color
import androidx.ui.layout.Column
import androidx.ui.layout.preferredSize
-import androidx.ui.semantics.ScrollTo
+import androidx.ui.semantics.scrollBy
import androidx.ui.unit.dp
import com.google.common.truth.Truth
import org.junit.Assert
@@ -43,9 +43,9 @@
composeTestRule.setContent {
Box(Modifier.semantics {
- ScrollTo(action = { _, _ ->
+ scrollBy(action = { _, _ ->
wasScrollToCalled = true
- return@ScrollTo true
+ return@scrollBy true
})
}) {
Box(Modifier.testTag(tag))
@@ -56,8 +56,8 @@
Assert.assertTrue(!wasScrollToCalled)
}
- findByTag(tag)
- .doScrollTo()
+ onNodeWithTag(tag)
+ .performScrollTo()
runOnIdleCompose {
Assert.assertTrue(wasScrollToCalled)
@@ -85,10 +85,10 @@
val green = Color(alpha = 0xFF, red = 0, green = 0xFF, blue = 0)
Box(Modifier.semantics {
- ScrollTo(action = { x, y ->
- currentScrollPositionY = y
- currentScrollPositionX = x
- return@ScrollTo true
+ scrollBy(action = { x, y ->
+ currentScrollPositionY += y
+ currentScrollPositionX += x
+ return@scrollBy true
})
}) {
Column {
@@ -104,8 +104,8 @@
Truth.assertThat(currentScrollPositionX).isEqualTo(0.0f)
}
- findByTag(tag)
- .doScrollTo() // scroll to third element
+ onNodeWithTag(tag)
+ .performScrollTo() // scroll to third element
runOnIdleCompose {
val expected = elementHeight * 2
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/SynchronizationMethodsTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/SynchronizationMethodsTest.kt
index 9c4369f..ad4e374 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/SynchronizationMethodsTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/SynchronizationMethodsTest.kt
@@ -77,7 +77,7 @@
withAndroidOwnerRegistry {
runOnIdleCompose {
expectError<IllegalStateException> {
- findByTag("dummy").assertExists()
+ onNodeWithTag("dummy").assertExists()
}
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/TextActionsTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/TextActionsTest.kt
index 967c45b..c1ac5d8 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/TextActionsTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/TextActionsTest.kt
@@ -70,15 +70,15 @@
}
}
- findByTag(fieldTag)
- .doSendText("Hello!")
+ onNodeWithTag(fieldTag)
+ .performTextInput("Hello!")
runOnIdleCompose {
assertThat(lastSeenText).isEqualTo("Hello!")
}
- findByTag(fieldTag)
- .doClearText(alreadyHasFocus = true)
+ onNodeWithTag(fieldTag)
+ .performTextClearance(alreadyHasFocus = true)
runOnIdleCompose {
assertThat(lastSeenText).isEqualTo("")
@@ -94,11 +94,11 @@
}
}
- findByTag(fieldTag)
- .doSendText("Hello ")
+ onNodeWithTag(fieldTag)
+ .performTextInput("Hello ")
- findByTag(fieldTag)
- .doSendText("world!", alreadyHasFocus = true)
+ onNodeWithTag(fieldTag)
+ .performTextInput("world!", alreadyHasFocus = true)
runOnIdleCompose {
assertThat(lastSeenText).isEqualTo("Hello world!")
@@ -114,14 +114,14 @@
}
}
- findByTag(fieldTag)
- .doSendText("Hello")
+ onNodeWithTag(fieldTag)
+ .performTextInput("Hello")
// This helps. So there must be some timing issue.
// Thread.sleep(3000)
- findByTag(fieldTag)
- .doSendText(" world!", alreadyHasFocus = true)
+ onNodeWithTag(fieldTag)
+ .performTextInput(" world!", alreadyHasFocus = true)
runOnIdleCompose {
assertThat(lastSeenText).isEqualTo("Hello world!")
@@ -135,8 +135,8 @@
}
expectError<IllegalStateException> {
- findByTag(fieldTag)
- .doSendText("Hello!", alreadyHasFocus = true)
+ onNodeWithTag(fieldTag)
+ .performTextInput("Hello!", alreadyHasFocus = true)
}
}
@@ -149,15 +149,15 @@
}
}
- findByTag(fieldTag)
- .doSendText("Hello")
+ onNodeWithTag(fieldTag)
+ .performTextInput("Hello")
runOnIdleCompose {
assertThat(lastSeenText).isEqualTo("Hello")
}
- findByTag(fieldTag)
- .doReplaceText("world", alreadyHasFocus = true)
+ onNodeWithTag(fieldTag)
+ .performTextReplacement("world", alreadyHasFocus = true)
runOnIdleCompose {
assertThat(lastSeenText).isEqualTo("world")
@@ -173,8 +173,8 @@
}
assertThat(actionPerformed).isEqualTo(ImeAction.Unspecified)
- findByTag(fieldTag)
- .doSendImeAction()
+ onNodeWithTag(fieldTag)
+ .performImeAction()
runOnIdleCompose {
assertThat(actionPerformed).isEqualTo(ImeAction.Search)
@@ -191,11 +191,11 @@
assertThat(actionPerformed).isEqualTo(ImeAction.Unspecified)
expectErrorMessageStartsWith("" +
- "Failed to send IME action as current node does not specify any.\n" +
+ "Failed to perform IME action as current node does not specify any.\n" +
"Semantics of the node:"
) {
- findByTag(fieldTag)
- .doSendImeAction()
+ onNodeWithTag(fieldTag)
+ .performImeAction()
}
}
@@ -206,12 +206,12 @@
}
expectErrorMessageStartsWith("" +
- "Failed to send IME action.\n" +
- "Failed to assert the following: (SupportsInputMethods = 'true')\n" +
+ "Failed to perform IME action.\n" +
+ "Failed to assert the following: (SupportsInputMethods is defined)\n" +
"Semantics of the node:"
) {
- findByTag("node")
- .doSendImeAction()
+ onNodeWithTag("node")
+ .performImeAction()
}
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/TimeOutTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/TimeOutTest.kt
index 2fe01a7..011e46a 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/TimeOutTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/TimeOutTest.kt
@@ -117,13 +117,13 @@
}
}
- findByText("Hello 0").assertExists()
+ onNodeWithText("Hello 0").assertExists()
count.value++ // Start infinite re-compositions
IdlingPolicies.setMasterPolicyTimeout(300, TimeUnit.MILLISECONDS)
expectError<ComposeNotIdleException>(expectedMessage = expectedErrorDueToRecompositions) {
- findByText("Hello").assertExists()
+ onNodeWithText("Hello").assertExists()
}
}
@@ -167,7 +167,7 @@
}
// No timeout should happen this time
- findByText("Hello").assertExists()
+ onNodeWithText("Hello").assertExists()
}
private object InfiniteResource : IdlingResource {
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/AssertAllTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/AssertAllTest.kt
index 09a6ed4..518222e 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/AssertAllTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/AssertAllTest.kt
@@ -19,9 +19,9 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assertAll
import androidx.ui.test.assertCountEquals
-import androidx.ui.test.children
+import androidx.ui.test.onChildren
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import androidx.ui.test.util.expectErrorMessageStartsWith
@@ -47,8 +47,8 @@
}
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertAll(hasTestTag("Child1") or hasTestTag("Child2"))
}
@@ -66,8 +66,8 @@
"Found '1' node not matching:\n" +
"Node #X"
) {
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertAll(hasTestTag("Child1"))
}
}
@@ -87,8 +87,8 @@
"Found '2' nodes not matching:\n" +
"1) "
) {
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertAll(hasTestTag("Child1"))
}
}
@@ -99,8 +99,8 @@
BoundaryNode(testTag = "Parent")
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertCountEquals(0)
.assertAll(hasTestTag("Child"))
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/AssertAnyTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/AssertAnyTest.kt
index 7cede74..0f94a36 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/AssertAnyTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/AssertAnyTest.kt
@@ -18,9 +18,9 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assertAny
-import androidx.ui.test.children
+import androidx.ui.test.onChildren
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import androidx.ui.test.util.expectErrorMessageStartsWith
@@ -46,12 +46,12 @@
}
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertAny(hasTestTag("Child1"))
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertAny(hasTestTag("Child1") or hasTestTag("Child2"))
}
@@ -68,8 +68,8 @@
"Failed to assertAny(TestTag = 'Child3')\n" +
"None of the following nodes match:\n" +
"1) ") {
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertAny(hasTestTag("Child3"))
}
}
@@ -84,8 +84,8 @@
"Failed to assertAny(TestTag = 'Child')\n" +
"Assert needs to receive at least 1 node but 0 nodes were found for selector: " +
"'(TestTag = 'Parent').children'") {
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertAny(hasTestTag("Child"))
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/BoundsAssertionsTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/BoundsAssertionsTest.kt
index c4234df..26ca383 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/BoundsAssertionsTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/BoundsAssertionsTest.kt
@@ -37,7 +37,7 @@
import androidx.ui.test.assertWidthIsAtLeast
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.util.expectError
import androidx.ui.unit.dp
import org.junit.Rule
@@ -102,7 +102,7 @@
fun assertEquals() {
composeBox()
- findByTag(tag)
+ onNodeWithTag(tag)
.assertWidthIsEqualTo(80.dp)
.assertHeightIsEqualTo(100.dp)
}
@@ -111,7 +111,7 @@
fun assertAtLeast() {
composeBox()
- findByTag(tag)
+ onNodeWithTag(tag)
.assertWidthIsAtLeast(80.dp)
.assertWidthIsAtLeast(79.dp)
.assertHeightIsAtLeast(100.dp)
@@ -123,12 +123,12 @@
composeBox()
expectError<AssertionError> {
- findByTag(tag)
+ onNodeWithTag(tag)
.assertWidthIsEqualTo(70.dp)
}
expectError<AssertionError> {
- findByTag(tag)
+ onNodeWithTag(tag)
.assertHeightIsEqualTo(90.dp)
}
}
@@ -138,12 +138,12 @@
composeBox()
expectError<AssertionError> {
- findByTag(tag)
+ onNodeWithTag(tag)
.assertWidthIsAtLeast(81.dp)
}
expectError<AssertionError> {
- findByTag(tag)
+ onNodeWithTag(tag)
.assertHeightIsAtLeast(101.dp)
}
}
@@ -152,7 +152,7 @@
fun assertPosition() {
composeBox()
- findByTag(tag)
+ onNodeWithTag(tag)
.assertPositionInRootIsEqualTo(expectedLeft = 50.dp, expectedTop = 100.dp)
.assertLeftPositionInRootIsEqualTo(50.dp)
.assertTopPositionInRootIsEqualTo(100.dp)
@@ -163,12 +163,12 @@
composeBox()
expectError<AssertionError> {
- findByTag(tag)
+ onNodeWithTag(tag)
.assertPositionInRootIsEqualTo(expectedLeft = 51.dp, expectedTop = 101.dp)
}
expectError<AssertionError> {
- findByTag(tag)
+ onNodeWithTag(tag)
.assertPositionInRootIsEqualTo(expectedLeft = 49.dp, expectedTop = 99.dp)
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/PositionsTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/PositionsTest.kt
index e4a018c..9d2b331 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/PositionsTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/PositionsTest.kt
@@ -29,8 +29,8 @@
import androidx.ui.test.centerX
import androidx.ui.test.centerY
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.height
import androidx.ui.test.left
import androidx.ui.test.right
@@ -55,7 +55,7 @@
fun testCornersEdgesAndCenter() {
composeTestRule.setContent { ClickableTestBox(width = 3f, height = 100f) }
- findByTag(defaultTag).doGesture {
+ onNodeWithTag(defaultTag).performGesture {
assertThat(width).isEqualTo(3)
assertThat(height).isEqualTo(100)
@@ -83,7 +83,7 @@
fun testRelativeOffset() {
composeTestRule.setContent { ClickableTestBox() }
- findByTag(defaultTag).doGesture {
+ onNodeWithTag(defaultTag).performGesture {
assertThat(percentOffset(.1f, .1f)).isEqualTo(Offset(10f, 10f))
assertThat(percentOffset(-.2f, 0f)).isEqualTo(Offset(-20f, 0f))
assertThat(percentOffset(.25f, -.5f)).isEqualTo(Offset(25f, -50f))
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendClickTest.kt
index b4e1492..bdbea41 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendClickTest.kt
@@ -28,10 +28,10 @@
import androidx.ui.layout.Column
import androidx.ui.test.ActivityWithActionBar
import androidx.ui.test.android.AndroidComposeTestRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendClick
+import androidx.ui.test.click
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.RecordingFilter
import com.google.common.truth.Truth.assertThat
@@ -126,11 +126,11 @@
}
private fun click(tag: String) {
- findByTag(tag).doGesture {
+ onNodeWithTag(tag).performGesture {
if (config.position != null) {
- sendClick(config.position)
+ click(config.position)
} else {
- sendClick()
+ click()
}
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendDoubleClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendDoubleClickTest.kt
index 2c194a6..fcd5823 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendDoubleClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendDoubleClickTest.kt
@@ -23,9 +23,9 @@
import androidx.ui.test.InputDispatcher.Companion.eventPeriod
import androidx.ui.test.InputDispatcher.InputDispatcherTestRule
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
-import androidx.ui.test.sendDoubleClick
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.doubleClick
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.ClickableTestBox.defaultSize
import androidx.ui.test.util.ClickableTestBox.defaultTag
@@ -89,15 +89,15 @@
}
// When we inject a double click
- findByTag(defaultTag).doGesture {
+ onNodeWithTag(defaultTag).performGesture {
if (config.position != null && config.delay != null) {
- sendDoubleClick(config.position, config.delay)
+ doubleClick(config.position, config.delay)
} else if (config.position != null) {
- sendDoubleClick(config.position)
+ doubleClick(config.position)
} else if (config.delay != null) {
- sendDoubleClick(delay = config.delay)
+ doubleClick(delay = config.delay)
} else {
- sendDoubleClick()
+ doubleClick()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendLongClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendLongClickTest.kt
index 5cbd19e..2f92087 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendLongClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendLongClickTest.kt
@@ -25,9 +25,9 @@
import androidx.ui.layout.fillMaxSize
import androidx.ui.layout.wrapContentSize
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
-import androidx.ui.test.sendLongClick
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.longClick
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.ClickableTestBox.defaultSize
import androidx.ui.test.util.ClickableTestBox.defaultTag
@@ -44,7 +44,7 @@
import org.junit.runners.Parameterized
/**
- * Tests [sendLongClick] with arguments. Verifies that the click is in the middle
+ * Tests [longClick] with arguments. Verifies that the click is in the middle
* of the component, that the gesture has a duration of 600 milliseconds and that all input
* events were on the same location.
*/
@@ -93,15 +93,15 @@
}
// When we inject a long click
- findByTag(defaultTag).doGesture {
+ onNodeWithTag(defaultTag).performGesture {
if (config.position != null && config.duration != null) {
- sendLongClick(config.position, config.duration)
+ longClick(config.position, config.duration)
} else if (config.position != null) {
- sendLongClick(config.position)
+ longClick(config.position)
} else if (config.duration != null) {
- sendLongClick(duration = config.duration)
+ longClick(duration = config.duration)
} else {
- sendLongClick()
+ longClick()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendPinchTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendPinchTest.kt
index e28dac9..257102a 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendPinchTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendPinchTest.kt
@@ -23,10 +23,10 @@
import androidx.ui.layout.fillMaxSize
import androidx.ui.test.InputDispatcher.Companion.eventPeriod
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendPinch
+import androidx.ui.test.pinch
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.MultiPointerInputRecorder
import androidx.ui.test.util.assertTimestampsAreIncreasing
@@ -65,8 +65,8 @@
val end1 = Offset(92f, 50f)
val duration = 400.milliseconds
- findByTag(TAG).doGesture {
- sendPinch(start0, end0, start1, end1, duration)
+ onNodeWithTag(TAG).performGesture {
+ pinch(start0, end0, start1, end1, duration)
}
runOnIdleCompose {
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeTest.kt
index b81d6d6..6d67ef1 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeTest.kt
@@ -26,14 +26,14 @@
import androidx.ui.layout.wrapContentSize
import androidx.ui.test.bottomRight
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendSwipe
-import androidx.ui.test.sendSwipeDown
-import androidx.ui.test.sendSwipeLeft
-import androidx.ui.test.sendSwipeRight
-import androidx.ui.test.sendSwipeUp
+import androidx.ui.test.swipe
+import androidx.ui.test.swipeDown
+import androidx.ui.test.swipeLeft
+import androidx.ui.test.swipeRight
+import androidx.ui.test.swipeUp
import androidx.ui.test.topLeft
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.SinglePointerInputRecorder
@@ -72,7 +72,7 @@
@Test
fun swipeUp() {
composeTestRule.setContent { Ui(Alignment.TopStart) }
- findByTag(tag).doGesture { sendSwipeUp() }
+ onNodeWithTag(tag).performGesture { swipeUp() }
runOnIdleCompose {
recorder.run {
assertTimestampsAreIncreasing()
@@ -85,7 +85,7 @@
@Test
fun swipeDown() {
composeTestRule.setContent { Ui(Alignment.TopEnd) }
- findByTag(tag).doGesture { sendSwipeDown() }
+ onNodeWithTag(tag).performGesture { swipeDown() }
runOnIdleCompose {
recorder.run {
assertTimestampsAreIncreasing()
@@ -98,7 +98,7 @@
@Test
fun swipeLeft() {
composeTestRule.setContent { Ui(Alignment.BottomEnd) }
- findByTag(tag).doGesture { sendSwipeLeft() }
+ onNodeWithTag(tag).performGesture { swipeLeft() }
runOnIdleCompose {
recorder.run {
assertTimestampsAreIncreasing()
@@ -111,7 +111,7 @@
@Test
fun swipeRight() {
composeTestRule.setContent { Ui(Alignment.BottomStart) }
- findByTag(tag).doGesture { sendSwipeRight() }
+ onNodeWithTag(tag).performGesture { swipeRight() }
runOnIdleCompose {
recorder.run {
assertTimestampsAreIncreasing()
@@ -124,7 +124,7 @@
@Test
fun swipeShort() {
composeTestRule.setContent { Ui(Alignment.Center) }
- findByTag(tag).doGesture { sendSwipe(topLeft, bottomRight, 1.milliseconds) }
+ onNodeWithTag(tag).performGesture { swipe(topLeft, bottomRight, 1.milliseconds) }
runOnIdleCompose {
recorder.run {
assertTimestampsAreIncreasing()
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeVelocityTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeVelocityTest.kt
index 2739718..9fad642 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeVelocityTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeVelocityTest.kt
@@ -25,10 +25,10 @@
import androidx.ui.layout.wrapContentSize
import androidx.ui.test.InputDispatcher.InputDispatcherTestRule
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendSwipeWithVelocity
+import androidx.ui.test.swipeWithVelocity
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.SinglePointerInputRecorder
import androidx.ui.test.util.assertOnlyLastEventIsUp
@@ -136,8 +136,8 @@
}
}
- findByTag(tag).doGesture {
- sendSwipeWithVelocity(start, end, velocity, duration)
+ onNodeWithTag(tag).performGesture {
+ swipeWithVelocity(start, end, velocity, duration)
}
runOnIdleCompose {
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/Common.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/Common.kt
index 6c0c86c..243b09a 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/Common.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/Common.kt
@@ -17,12 +17,12 @@
package androidx.ui.test.partialgesturescope
import androidx.ui.test.PartialGestureScope
-import androidx.ui.test.doPartialGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performPartialGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.util.ClickableTestBox.defaultTag
object Common {
fun partialGesture(block: PartialGestureScope.() -> Unit) {
- findByTag(defaultTag).doPartialGesture(block)
+ onNodeWithTag(defaultTag).performPartialGesture(block)
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendCancelTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendCancelTest.kt
index 388bd24..404f59d 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendCancelTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendCancelTest.kt
@@ -23,9 +23,9 @@
import androidx.ui.test.inputdispatcher.verifyNoGestureInProgress
import androidx.ui.test.partialgesturescope.Common.partialGesture
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendCancel
-import androidx.ui.test.sendDown
-import androidx.ui.test.sendUp
+import androidx.ui.test.cancel
+import androidx.ui.test.down
+import androidx.ui.test.up
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.MultiPointerInputRecorder
import androidx.ui.test.util.assertTimestampsAreIncreasing
@@ -37,7 +37,7 @@
import org.junit.rules.TestRule
/**
- * Tests if [sendCancel] works
+ * Tests if [cancel] works
*/
@MediumTest
class SendCancelTest {
@@ -65,8 +65,8 @@
@Test
fun onePointer() {
// When we inject a down event followed by a cancel event
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendCancel() }
+ partialGesture { down(downPosition1) }
+ partialGesture { cancel() }
runOnIdleCompose {
recorder.run {
@@ -83,9 +83,9 @@
@Test
fun twoPointers() {
// When we inject two down events followed by a cancel event
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendDown(2, downPosition2) }
- partialGesture { sendCancel() }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { down(2, downPosition2) }
+ partialGesture { cancel() }
runOnIdleCompose {
recorder.run {
@@ -102,25 +102,25 @@
@Test
fun cancelWithoutDown() {
expectError<IllegalStateException> {
- partialGesture { sendCancel() }
+ partialGesture { cancel() }
}
}
@Test
fun cancelAfterUp() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendUp() }
+ partialGesture { down(downPosition1) }
+ partialGesture { up() }
expectError<IllegalStateException> {
- partialGesture { sendCancel() }
+ partialGesture { cancel() }
}
}
@Test
fun cancelAfterCancel() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendCancel() }
+ partialGesture { down(downPosition1) }
+ partialGesture { cancel() }
expectError<IllegalStateException> {
- partialGesture { sendCancel() }
+ partialGesture { cancel() }
}
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendDownTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendDownTest.kt
index 9e2d7a0..1a06cd5 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendDownTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendDownTest.kt
@@ -23,7 +23,7 @@
import androidx.ui.test.createComposeRule
import androidx.ui.test.partialgesturescope.Common.partialGesture
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendDown
+import androidx.ui.test.down
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.MultiPointerInputRecorder
import androidx.ui.test.util.assertTimestampsAreIncreasing
@@ -36,7 +36,7 @@
import org.junit.rules.TestRule
/**
- * Tests if [sendDown] works
+ * Tests if [down] works
*/
@MediumTest
class SendDownTest {
@@ -64,7 +64,7 @@
@Test
fun onePointer() {
// When we put a pointer down
- partialGesture { sendDown(position1) }
+ partialGesture { down(position1) }
runOnIdleCompose {
recorder.run {
@@ -80,9 +80,9 @@
@Test
fun twoPointers() {
// When we put two pointers down
- partialGesture { sendDown(1, position1) }
+ partialGesture { down(1, position1) }
sleep(20) // (with some time in between)
- partialGesture { sendDown(2, position2) }
+ partialGesture { down(2, position2) }
runOnIdleCompose {
recorder.run {
@@ -109,10 +109,10 @@
@Test
fun duplicatePointers() {
// When we inject two down events with the same pointer id
- partialGesture { sendDown(1, position1) }
+ partialGesture { down(1, position1) }
// Then the second throws an exception
expectError<IllegalArgumentException> {
- partialGesture { sendDown(1, position1) }
+ partialGesture { down(1, position1) }
}
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveByTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveByTest.kt
index 8fcfe89..73b9ed4 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveByTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveByTest.kt
@@ -24,11 +24,11 @@
import androidx.ui.test.movePointerBy
import androidx.ui.test.partialgesturescope.Common.partialGesture
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendCancel
-import androidx.ui.test.sendDown
-import androidx.ui.test.sendMove
-import androidx.ui.test.sendMoveBy
-import androidx.ui.test.sendUp
+import androidx.ui.test.cancel
+import androidx.ui.test.down
+import androidx.ui.test.move
+import androidx.ui.test.moveBy
+import androidx.ui.test.up
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.MultiPointerInputRecorder
import androidx.ui.test.util.assertTimestampsAreIncreasing
@@ -42,7 +42,7 @@
import org.junit.rules.TestRule
/**
- * Tests if [sendMoveBy] and [movePointerBy] work
+ * Tests if [moveBy] and [movePointerBy] work
*/
@MediumTest
class SendMoveByTest {
@@ -72,9 +72,9 @@
@Test
fun onePointer() {
// When we inject a down event followed by a move event
- partialGesture { sendDown(downPosition1) }
+ partialGesture { down(downPosition1) }
sleep(20) // (with some time in between)
- partialGesture { sendMoveBy(delta1) }
+ partialGesture { moveBy(delta1) }
runOnIdleCompose {
recorder.run {
@@ -95,10 +95,10 @@
@Test
fun twoPointers() {
// When we inject two down events followed by two move events
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendDown(2, downPosition2) }
- partialGesture { sendMoveBy(1, delta1) }
- partialGesture { sendMoveBy(2, delta2) }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { down(2, downPosition2) }
+ partialGesture { moveBy(1, delta1) }
+ partialGesture { moveBy(2, delta2) }
runOnIdleCompose {
recorder.run {
@@ -126,12 +126,12 @@
@Test
fun twoPointers_oneMoveEvent() {
// When we inject two down events followed by one move events
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendDown(2, downPosition2) }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { down(2, downPosition2) }
sleep(20) // (with some time in between)
partialGesture { movePointerBy(1, delta1) }
partialGesture { movePointerBy(2, delta2) }
- partialGesture { sendMove() }
+ partialGesture { move() }
runOnIdleCompose {
recorder.run {
@@ -154,33 +154,33 @@
@Test
fun moveByWithoutDown() {
expectError<IllegalStateException> {
- partialGesture { sendMoveBy(delta1) }
+ partialGesture { moveBy(delta1) }
}
}
@Test
fun moveByWrongPointerId() {
- partialGesture { sendDown(1, downPosition1) }
+ partialGesture { down(1, downPosition1) }
expectError<IllegalArgumentException> {
- partialGesture { sendMoveBy(2, delta1) }
+ partialGesture { moveBy(2, delta1) }
}
}
@Test
fun moveByAfterUp() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendUp() }
+ partialGesture { down(downPosition1) }
+ partialGesture { up() }
expectError<IllegalStateException> {
- partialGesture { sendMoveBy(delta1) }
+ partialGesture { moveBy(delta1) }
}
}
@Test
fun moveByAfterCancel() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendCancel() }
+ partialGesture { down(downPosition1) }
+ partialGesture { cancel() }
expectError<IllegalStateException> {
- partialGesture { sendMoveBy(delta1) }
+ partialGesture { moveBy(delta1) }
}
}
@@ -193,7 +193,7 @@
@Test
fun movePointerByWrongPointerId() {
- partialGesture { sendDown(1, downPosition1) }
+ partialGesture { down(1, downPosition1) }
expectError<IllegalArgumentException> {
partialGesture { movePointerBy(2, delta1) }
}
@@ -201,8 +201,8 @@
@Test
fun movePointerByAfterUp() {
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendUp(1) }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { up(1) }
expectError<IllegalStateException> {
partialGesture { movePointerBy(1, delta1) }
}
@@ -210,8 +210,8 @@
@Test
fun movePointerByAfterCancel() {
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendCancel() }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { cancel() }
expectError<IllegalStateException> {
partialGesture { movePointerBy(1, delta1) }
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveTest.kt
index bd7e890..f73435e 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveTest.kt
@@ -21,10 +21,10 @@
import androidx.ui.test.InputDispatcher.InputDispatcherTestRule
import androidx.ui.test.createComposeRule
import androidx.ui.test.partialgesturescope.Common.partialGesture
-import androidx.ui.test.sendCancel
-import androidx.ui.test.sendDown
-import androidx.ui.test.sendMove
-import androidx.ui.test.sendUp
+import androidx.ui.test.cancel
+import androidx.ui.test.down
+import androidx.ui.test.move
+import androidx.ui.test.up
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.expectError
import org.junit.Before
@@ -33,7 +33,7 @@
import org.junit.rules.TestRule
/**
- * Tests the error states of [sendMove] that are not tested in [SendMoveToTest] and [SendMoveByTest]
+ * Tests the error states of [move] that are not tested in [SendMoveToTest] and [SendMoveByTest]
*/
@MediumTest
class SendMoveTest() {
@@ -58,25 +58,25 @@
@Test
fun moveWithoutDown() {
expectError<IllegalStateException> {
- partialGesture { sendMove() }
+ partialGesture { move() }
}
}
@Test
fun moveAfterUp() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendUp() }
+ partialGesture { down(downPosition1) }
+ partialGesture { up() }
expectError<IllegalStateException> {
- partialGesture { sendMove() }
+ partialGesture { move() }
}
}
@Test
fun moveAfterCancel() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendCancel() }
+ partialGesture { down(downPosition1) }
+ partialGesture { cancel() }
expectError<IllegalStateException> {
- partialGesture { sendMove() }
+ partialGesture { move() }
}
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveToTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveToTest.kt
index 599bfa3..3978213 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveToTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveToTest.kt
@@ -24,11 +24,11 @@
import androidx.ui.test.movePointerTo
import androidx.ui.test.partialgesturescope.Common.partialGesture
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendCancel
-import androidx.ui.test.sendDown
-import androidx.ui.test.sendMove
-import androidx.ui.test.sendMoveTo
-import androidx.ui.test.sendUp
+import androidx.ui.test.cancel
+import androidx.ui.test.down
+import androidx.ui.test.move
+import androidx.ui.test.moveTo
+import androidx.ui.test.up
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.MultiPointerInputRecorder
import androidx.ui.test.util.assertTimestampsAreIncreasing
@@ -42,7 +42,7 @@
import org.junit.rules.TestRule
/**
- * Tests if [sendMoveTo] and [movePointerTo] work
+ * Tests if [moveTo] and [movePointerTo] work
*/
@MediumTest
class SendMoveToTest() {
@@ -72,9 +72,9 @@
@Test
fun onePointer() {
// When we inject a down event followed by a move event
- partialGesture { sendDown(downPosition1) }
+ partialGesture { down(downPosition1) }
sleep(20) // (with some time in between)
- partialGesture { sendMoveTo(moveToPosition1) }
+ partialGesture { moveTo(moveToPosition1) }
runOnIdleCompose {
recorder.run {
@@ -95,10 +95,10 @@
@Test
fun twoPointers_separateMoveEvents() {
// When we inject two down events followed by two move events
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendDown(2, downPosition2) }
- partialGesture { sendMoveTo(1, moveToPosition1) }
- partialGesture { sendMoveTo(2, moveToPosition2) }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { down(2, downPosition2) }
+ partialGesture { moveTo(1, moveToPosition1) }
+ partialGesture { moveTo(2, moveToPosition2) }
runOnIdleCompose {
recorder.run {
@@ -126,12 +126,12 @@
@Test
fun twoPointers_oneMoveEvent() {
// When we inject two down events followed by one move events
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendDown(2, downPosition2) }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { down(2, downPosition2) }
sleep(20) // (with some time in between)
partialGesture { movePointerTo(1, moveToPosition1) }
partialGesture { movePointerTo(2, moveToPosition2) }
- partialGesture { sendMove() }
+ partialGesture { move() }
runOnIdleCompose {
recorder.run {
@@ -154,33 +154,33 @@
@Test
fun moveToWithoutDown() {
expectError<IllegalStateException> {
- partialGesture { sendMoveTo(moveToPosition1) }
+ partialGesture { moveTo(moveToPosition1) }
}
}
@Test
fun moveToWrongPointerId() {
- partialGesture { sendDown(1, downPosition1) }
+ partialGesture { down(1, downPosition1) }
expectError<IllegalArgumentException> {
- partialGesture { sendMoveTo(2, moveToPosition1) }
+ partialGesture { moveTo(2, moveToPosition1) }
}
}
@Test
fun moveToAfterUp() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendUp() }
+ partialGesture { down(downPosition1) }
+ partialGesture { up() }
expectError<IllegalStateException> {
- partialGesture { sendMoveTo(moveToPosition1) }
+ partialGesture { moveTo(moveToPosition1) }
}
}
@Test
fun moveToAfterCancel() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendCancel() }
+ partialGesture { down(downPosition1) }
+ partialGesture { cancel() }
expectError<IllegalStateException> {
- partialGesture { sendMoveTo(moveToPosition1) }
+ partialGesture { moveTo(moveToPosition1) }
}
}
@@ -193,7 +193,7 @@
@Test
fun movePointerToWrongPointerId() {
- partialGesture { sendDown(1, downPosition1) }
+ partialGesture { down(1, downPosition1) }
expectError<IllegalArgumentException> {
partialGesture { movePointerTo(2, moveToPosition1) }
}
@@ -201,8 +201,8 @@
@Test
fun movePointerToAfterUp() {
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendUp(1) }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { up(1) }
expectError<IllegalStateException> {
partialGesture { movePointerTo(1, moveToPosition1) }
}
@@ -210,8 +210,8 @@
@Test
fun movePointerToAfterCancel() {
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendCancel() }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { cancel() }
expectError<IllegalStateException> {
partialGesture { movePointerTo(1, moveToPosition1) }
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendUpTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendUpTest.kt
index fc6da04..9a9c3f5 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendUpTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendUpTest.kt
@@ -24,9 +24,9 @@
import androidx.ui.test.inputdispatcher.verifyNoGestureInProgress
import androidx.ui.test.partialgesturescope.Common.partialGesture
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendCancel
-import androidx.ui.test.sendDown
-import androidx.ui.test.sendUp
+import androidx.ui.test.cancel
+import androidx.ui.test.down
+import androidx.ui.test.up
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.MultiPointerInputRecorder
import androidx.ui.test.util.assertTimestampsAreIncreasing
@@ -39,7 +39,7 @@
import org.junit.rules.TestRule
/**
- * Tests if [sendUp] works
+ * Tests if [up] works
*/
@MediumTest
class SendUpTest {
@@ -67,9 +67,9 @@
@Test
fun onePointer() {
// When we inject a down event followed by an up event
- partialGesture { sendDown(downPosition1) }
+ partialGesture { down(downPosition1) }
sleep(20) // (with some time in between)
- partialGesture { sendUp() }
+ partialGesture { up() }
runOnIdleCompose {
recorder.run {
@@ -92,10 +92,10 @@
@Test
fun twoPointers() {
// When we inject two down events followed by two up events
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendDown(2, downPosition2) }
- partialGesture { sendUp(1) }
- partialGesture { sendUp(2) }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { down(2, downPosition2) }
+ partialGesture { up(1) }
+ partialGesture { up(2) }
runOnIdleCompose {
recorder.run {
@@ -123,33 +123,33 @@
@Test
fun upWithoutDown() {
expectError<IllegalStateException> {
- partialGesture { sendUp() }
+ partialGesture { up() }
}
}
@Test
fun upWrongPointerId() {
- partialGesture { sendDown(1, downPosition1) }
+ partialGesture { down(1, downPosition1) }
expectError<IllegalArgumentException> {
- partialGesture { sendUp(2) }
+ partialGesture { up(2) }
}
}
@Test
fun upAfterUp() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendUp() }
+ partialGesture { down(downPosition1) }
+ partialGesture { up() }
expectError<IllegalStateException> {
- partialGesture { sendUp() }
+ partialGesture { up() }
}
}
@Test
fun upAfterCancel() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendCancel() }
+ partialGesture { down(downPosition1) }
+ partialGesture { cancel() }
expectError<IllegalStateException> {
- partialGesture { sendUp() }
+ partialGesture { up() }
}
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyAncestorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyAncestorTest.kt
index bff8537..c612c5d 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyAncestorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyAncestorTest.kt
@@ -20,9 +20,9 @@
import androidx.ui.test.assert
import androidx.ui.test.assertCountEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.find
-import androidx.ui.test.findAll
-import androidx.ui.test.hasAnyAncestorThat
+import androidx.ui.test.onNode
+import androidx.ui.test.onAllNodes
+import androidx.ui.test.hasAnyAncestor
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import org.junit.Rule
@@ -47,7 +47,7 @@
}
}
- find(hasAnyAncestorThat(hasTestTag("Parent")))
+ onNode(hasAnyAncestor(hasTestTag("Parent")))
.assert(hasTestTag("Child"))
}
@@ -63,7 +63,7 @@
}
}
- findAll(hasAnyAncestorThat(hasTestTag("Parent")))
+ onAllNodes(hasAnyAncestor(hasTestTag("Parent")))
.assertCountEquals(2)
}
@@ -78,7 +78,7 @@
}
}
- find(hasAnyAncestorThat(hasTestTag("Grandparent"))
+ onNode(hasAnyAncestor(hasTestTag("Grandparent"))
and !hasTestTag("Parent"))
.assert(hasTestTag("Child"))
}
@@ -94,7 +94,7 @@
}
}
- findAll(hasAnyAncestorThat(hasTestTag("Parent") or hasTestTag("Grandparent")))
+ onAllNodes(hasAnyAncestor(hasTestTag("Parent") or hasTestTag("Grandparent")))
.assertCountEquals(2)
}
@@ -104,7 +104,7 @@
BoundaryNode(testTag = "Node")
}
- find(hasAnyAncestorThat(hasTestTag("Node")))
+ onNode(hasAnyAncestor(hasTestTag("Node")))
.assertDoesNotExist()
}
@@ -116,7 +116,7 @@
}
}
- find(hasAnyAncestorThat(hasTestTag("Child")))
+ onNode(hasAnyAncestor(hasTestTag("Child")))
.assertDoesNotExist()
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyChildTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyChildTest.kt
index eac72bf..ade55ac 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyChildTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyChildTest.kt
@@ -20,9 +20,9 @@
import androidx.ui.test.assert
import androidx.ui.test.assertCountEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.find
-import androidx.ui.test.findAll
-import androidx.ui.test.hasAnyChildThat
+import androidx.ui.test.onNode
+import androidx.ui.test.onAllNodes
+import androidx.ui.test.hasAnyChild
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import org.junit.Rule
@@ -47,7 +47,7 @@
}
}
- find(hasAnyChildThat(hasTestTag("Child")))
+ onNode(hasAnyChild(hasTestTag("Child")))
.assert(hasTestTag("Parent"))
}
@@ -69,11 +69,11 @@
}
}
- findAll(hasAnyChildThat(hasTestTag("Child1")))
+ onAllNodes(hasAnyChild(hasTestTag("Child1")))
.assertCountEquals(2)
- findAll(hasAnyChildThat(hasTestTag("Child2")))
+ onAllNodes(hasAnyChild(hasTestTag("Child2")))
.assertCountEquals(3)
- findAll(hasAnyChildThat(hasTestTag("Child3")))
+ onAllNodes(hasAnyChild(hasTestTag("Child3")))
.assertCountEquals(1)
}
@@ -83,7 +83,7 @@
BoundaryNode(testTag = "Child")
}
- find(hasAnyChildThat(hasTestTag("Child")))
+ onNode(hasAnyChild(hasTestTag("Child")))
.assertExists() // The root node
}
@@ -97,7 +97,7 @@
}
}
- find(hasAnyChildThat(hasTestTag("Child"))
+ onNode(hasAnyChild(hasTestTag("Child"))
and hasTestTag("Parent"))
.assertDoesNotExist()
}
@@ -112,7 +112,7 @@
}
}
- find(hasAnyChildThat(hasAnyChildThat(hasTestTag("Child"))))
+ onNode(hasAnyChild(hasAnyChild(hasTestTag("Child"))))
.assert(hasTestTag("Parent"))
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyDescendantTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyDescendantTest.kt
index 0fa8b93..d39bd5f 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyDescendantTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyDescendantTest.kt
@@ -20,9 +20,9 @@
import androidx.ui.test.assert
import androidx.ui.test.assertCountEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.find
-import androidx.ui.test.findAll
-import androidx.ui.test.hasAnyDescendantThat
+import androidx.ui.test.onNode
+import androidx.ui.test.onAllNodes
+import androidx.ui.test.hasAnyDescendant
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import org.junit.Rule
@@ -47,7 +47,7 @@
}
}
- find(hasAnyDescendantThat(hasTestTag("Child")) and hasTestTag("Parent"))
+ onNode(hasAnyDescendant(hasTestTag("Child")) and hasTestTag("Parent"))
.assert(hasTestTag("Parent"))
}
@@ -62,7 +62,7 @@
}
}
- find(hasAnyDescendantThat(hasTestTag("Child")) and !hasTestTag("Parent")
+ onNode(hasAnyDescendant(hasTestTag("Child")) and !hasTestTag("Parent")
and hasTestTag("Grandparent"))
.assert(hasTestTag("Grandparent"))
}
@@ -73,7 +73,7 @@
BoundaryNode(testTag = "Node")
}
- find(hasAnyDescendantThat(hasTestTag("Node")))
+ onNode(hasAnyDescendant(hasTestTag("Node")))
.assertExists() // Root node
}
@@ -89,7 +89,7 @@
}
}
- findAll(hasAnyDescendantThat(hasTestTag("Child")))
+ onAllNodes(hasAnyDescendant(hasTestTag("Child")))
.assertCountEquals(3) // Parent, Parent2 and root
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnySiblingTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnySiblingTest.kt
index c1b4a80..ab87d0f 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnySiblingTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnySiblingTest.kt
@@ -20,10 +20,10 @@
import androidx.ui.test.assert
import androidx.ui.test.assertCountEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.find
-import androidx.ui.test.findAll
-import androidx.ui.test.hasAnySiblingThat
-import androidx.ui.test.hasParentThat
+import androidx.ui.test.onNode
+import androidx.ui.test.onAllNodes
+import androidx.ui.test.hasAnySibling
+import androidx.ui.test.hasParent
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import org.junit.Rule
@@ -49,7 +49,7 @@
}
}
- find(hasAnySiblingThat(hasTestTag("Sibling")))
+ onNode(hasAnySibling(hasTestTag("Sibling")))
.assert(hasTestTag("Me"))
}
@@ -64,7 +64,7 @@
}
}
- findAll(hasAnySiblingThat(hasTestTag("Sibling")))
+ onAllNodes(hasAnySibling(hasTestTag("Sibling")))
.assertCountEquals(2)
}
@@ -78,7 +78,7 @@
}
}
- findAll(hasAnySiblingThat(hasTestTag("Sibling")))
+ onAllNodes(hasAnySibling(hasTestTag("Sibling")))
.assertCountEquals(2)
}
@@ -96,7 +96,7 @@
}
}
- findAll(hasAnySiblingThat(hasTestTag("Sibling")))
+ onAllNodes(hasAnySibling(hasTestTag("Sibling")))
.assertCountEquals(2)
}
@@ -108,7 +108,7 @@
}
}
- find(hasAnySiblingThat(hasTestTag("Me")))
+ onNode(hasAnySibling(hasTestTag("Me")))
.assertDoesNotExist()
}
@@ -121,7 +121,7 @@
}
}
- find(hasAnySiblingThat(hasTestTag("Sibling2")))
+ onNode(hasAnySibling(hasTestTag("Sibling2")))
.assertDoesNotExist()
}
@@ -137,7 +137,7 @@
}
}
- find(hasAnySiblingThat(hasTestTag("Sibling")) and hasTestTag("Me"))
+ onNode(hasAnySibling(hasTestTag("Sibling")) and hasTestTag("Me"))
.assertDoesNotExist()
}
@@ -154,7 +154,7 @@
}
}
- find(hasParentThat(hasAnySiblingThat(hasTestTag("ParentSibling"))))
+ onNode(hasParent(hasAnySibling(hasTestTag("ParentSibling"))))
.assert(hasTestTag("Me"))
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasParentTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasParentTest.kt
index d371c54..ec9982ad 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasParentTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasParentTest.kt
@@ -20,9 +20,9 @@
import androidx.ui.test.assert
import androidx.ui.test.assertCountEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.find
-import androidx.ui.test.findAll
-import androidx.ui.test.hasParentThat
+import androidx.ui.test.onNode
+import androidx.ui.test.onAllNodes
+import androidx.ui.test.hasParent
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import org.junit.Rule
@@ -47,7 +47,7 @@
}
}
- find(hasParentThat(hasTestTag("Parent")))
+ onNode(hasParent(hasTestTag("Parent")))
.assert(hasTestTag("Child"))
}
@@ -61,7 +61,7 @@
}
}
- findAll(hasParentThat(hasTestTag("Parent")))
+ onAllNodes(hasParent(hasTestTag("Parent")))
.assertCountEquals(2)
}
@@ -79,7 +79,7 @@
}
}
- findAll(hasParentThat(hasTestTag("Parent")))
+ onAllNodes(hasParent(hasTestTag("Parent")))
.assertCountEquals(4)
}
@@ -93,7 +93,7 @@
}
}
- find(hasParentThat(hasTestTag("Parent"))
+ onNode(hasParent(hasTestTag("Parent"))
and hasTestTag("Child"))
.assertDoesNotExist()
}
@@ -108,7 +108,7 @@
}
}
- find(hasParentThat(hasParentThat(hasTestTag("Parent"))))
+ onNode(hasParent(hasParent(hasTestTag("Parent"))))
.assert(hasTestTag("Child"))
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/AddIndexSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/AddIndexSelectorTest.kt
index f76ab14..023c898 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/AddIndexSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/AddIndexSelectorTest.kt
@@ -18,11 +18,11 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assert
-import androidx.ui.test.childAt
-import androidx.ui.test.children
+import androidx.ui.test.onChildAt
+import androidx.ui.test.onChildren
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
-import androidx.ui.test.first
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onFirst
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import androidx.ui.test.util.expectErrorMessageStartsWith
@@ -47,9 +47,9 @@
}
}
- findByTag("Parent")
- .children()
- .first()
+ onNodeWithTag("Parent")
+ .onChildren()
+ .onFirst()
.assert(hasTestTag("Child1"))
}
@@ -62,8 +62,8 @@
}
}
- findByTag("Parent")
- .childAt(1)
+ onNodeWithTag("Parent")
+ .onChildAt(1)
.assert(hasTestTag("Child2"))
}
@@ -80,8 +80,8 @@
"Failed: assertExists.\n" +
"Can't retrieve node at index '2' of '(TestTag = 'Parent').children'\n" +
"There are '2' nodes only:") {
- findByTag("Parent")
- .childAt(2)
+ onNodeWithTag("Parent")
+ .onChildAt(2)
.assertExists()
}
}
@@ -92,8 +92,8 @@
BoundaryNode(testTag = "Parent")
}
- findByTag("Parent")
- .childAt(2)
+ onNodeWithTag("Parent")
+ .onChildAt(2)
.assertDoesNotExist()
}
@@ -107,8 +107,8 @@
"Failed: assertExists.\n" +
"Can't retrieve node at index '2' of '(TestTag = 'Parent').children'\n" +
"There are no existing nodes for that selector.") {
- findByTag("Parent")
- .childAt(2)
+ onNodeWithTag("Parent")
+ .onChildAt(2)
.assertExists()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/AncestorsSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/AncestorsSelectorTest.kt
index b223997..0e1f9b4 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/AncestorsSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/AncestorsSelectorTest.kt
@@ -17,14 +17,14 @@
package androidx.ui.test.selectors
import androidx.test.filters.MediumTest
-import androidx.ui.test.ancestors
+import androidx.ui.test.onAncestors
import androidx.ui.test.assert
import androidx.ui.test.assertCountEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
-import androidx.ui.test.first
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onFirst
import androidx.ui.test.hasTestTag
-import androidx.ui.test.parent
+import androidx.ui.test.onParent
import androidx.ui.test.util.BoundaryNode
import org.junit.Rule
import org.junit.Test
@@ -50,8 +50,8 @@
}
}
- findByTag("NodeD")
- .ancestors()
+ onNodeWithTag("NodeD")
+ .onAncestors()
.assertCountEquals(4)
.apply {
get(0).assert(hasTestTag("NodeC"))
@@ -72,10 +72,10 @@
}
}
- findByTag("NodeD")
- .ancestors()
- .first()
- .ancestors()
+ onNodeWithTag("NodeD")
+ .onAncestors()
+ .onFirst()
+ .onAncestors()
.assertCountEquals(3)
.apply {
get(0).assert(hasTestTag("NodeB"))
@@ -89,9 +89,9 @@
BoundaryNode(testTag = "Node")
}
- findByTag("Node")
- .parent()
- .ancestors()
+ onNodeWithTag("Node")
+ .onParent()
+ .onAncestors()
.assertCountEquals(0)
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ChildSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ChildSelectorTest.kt
index 0ae4de0..92edb12 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ChildSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ChildSelectorTest.kt
@@ -18,9 +18,9 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assert
-import androidx.ui.test.child
+import androidx.ui.test.onChild
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import androidx.ui.test.util.expectErrorMessageStartsWith
@@ -44,8 +44,8 @@
}
}
- findByTag("Parent")
- .child()
+ onNodeWithTag("Parent")
+ .onChild()
.assert(hasTestTag("Child"))
}
@@ -55,8 +55,8 @@
BoundaryNode(testTag = "Parent")
}
- findByTag("Parent")
- .child()
+ onNodeWithTag("Parent")
+ .onChild()
.assertDoesNotExist()
}
@@ -66,8 +66,8 @@
BoundaryNode(testTag = "Parent")
}
- findByTag("Parent")
- .child()
+ onNodeWithTag("Parent")
+ .onChild()
.assertExists()
}
@@ -86,8 +86,8 @@
"((TestTag = 'Parent').child)\n" +
"Nodes found:"
) {
- findByTag("Parent")
- .child()
+ onNodeWithTag("Parent")
+ .onChild()
.assertExists()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ChildrenSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ChildrenSelectorTest.kt
index d03732d..cb78014 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ChildrenSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ChildrenSelectorTest.kt
@@ -19,9 +19,9 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assert
import androidx.ui.test.assertCountEquals
-import androidx.ui.test.children
+import androidx.ui.test.onChildren
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import org.junit.Rule
@@ -45,8 +45,8 @@
}
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertCountEquals(2)
.apply {
get(0).assert(hasTestTag("Child1"))
@@ -60,8 +60,8 @@
BoundaryNode(testTag = "Parent")
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertCountEquals(0)
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/FilterSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/FilterSelectorTest.kt
index 871533af..9345588 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/FilterSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/FilterSelectorTest.kt
@@ -19,10 +19,10 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assert
import androidx.ui.test.assertCountEquals
-import androidx.ui.test.children
+import androidx.ui.test.onChildren
import androidx.ui.test.createComposeRule
import androidx.ui.test.filter
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import org.junit.Rule
@@ -46,8 +46,8 @@
}
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.filter(hasTestTag("Child1"))
.assertCountEquals(1)
.apply {
@@ -64,8 +64,8 @@
}
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.filter(hasTestTag("Child1") or hasTestTag("Child2"))
.assertCountEquals(2)
.apply {
@@ -83,8 +83,8 @@
}
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.filter(hasTestTag("Child"))
.assertCountEquals(0)
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/FilterToOneSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/FilterToOneSelectorTest.kt
index 5772435..735f3a9 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/FilterToOneSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/FilterToOneSelectorTest.kt
@@ -18,10 +18,10 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assert
-import androidx.ui.test.children
+import androidx.ui.test.onChildren
import androidx.ui.test.createComposeRule
import androidx.ui.test.filterToOne
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import androidx.ui.test.util.expectErrorMessageStartsWith
@@ -46,8 +46,8 @@
}
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.filterToOne(hasTestTag("Child1"))
.assert(hasTestTag("Child1"))
}
@@ -69,8 +69,8 @@
"Nodes found:\n" +
"1) "
) {
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.filterToOne(hasTestTag("Child1") or hasTestTag("Child2"))
.assertExists()
}
@@ -85,8 +85,8 @@
}
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.filterToOne(hasTestTag("Child"))
.assertDoesNotExist()
}
@@ -104,8 +104,8 @@
"Failed: assertExists.\n" +
"Reason: Expected exactly '1' node but could not find any node that satisfies: " +
"(((TestTag = 'Parent').children).filterToOne(TestTag = 'Child'))") {
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.filterToOne(hasTestTag("Child"))
.assertExists()
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/LastNodeSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/LastNodeSelectorTest.kt
index c779481a..1ebcc152 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/LastNodeSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/LastNodeSelectorTest.kt
@@ -18,11 +18,11 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assert
-import androidx.ui.test.children
+import androidx.ui.test.onChildren
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
-import androidx.ui.test.last
+import androidx.ui.test.onLast
import androidx.ui.test.util.BoundaryNode
import androidx.ui.test.util.expectErrorMessageStartsWith
import org.junit.Rule
@@ -46,9 +46,9 @@
}
}
- findByTag("Parent")
- .children()
- .last()
+ onNodeWithTag("Parent")
+ .onChildren()
+ .onLast()
.assert(hasTestTag("Child2"))
}
@@ -58,9 +58,9 @@
BoundaryNode(testTag = "Parent")
}
- findByTag("Parent")
- .children()
- .last()
+ onNodeWithTag("Parent")
+ .onChildren()
+ .onLast()
.assertDoesNotExist()
}
@@ -74,9 +74,9 @@
"Failed: assertExists.\n" +
"Reason: Expected exactly '1' node but could not find any node that satisfies: " +
"(((TestTag = 'Parent').children).last)") {
- findByTag("Parent")
- .children()
- .last()
+ onNodeWithTag("Parent")
+ .onChildren()
+ .onLast()
.assertExists()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ParentSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ParentSelectorTest.kt
index 60baee2..2cec2b7 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ParentSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ParentSelectorTest.kt
@@ -19,9 +19,9 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assert
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
-import androidx.ui.test.parent
+import androidx.ui.test.onParent
import androidx.ui.test.util.BoundaryNode
import androidx.ui.test.util.expectErrorMessage
import org.junit.Rule
@@ -44,8 +44,8 @@
}
}
- findByTag("Child")
- .parent()
+ onNodeWithTag("Child")
+ .onParent()
.assert(hasTestTag("Parent"))
}
@@ -55,9 +55,9 @@
BoundaryNode(testTag = "Node")
}
- findByTag("Node")
- .parent()
- .parent()
+ onNodeWithTag("Node")
+ .onParent()
+ .onParent()
.assertDoesNotExist()
}
@@ -72,9 +72,9 @@
"Reason: Expected exactly '1' node but could not find any node that satisfies: " +
"(((TestTag = 'Node').parent).parent)"
) {
- findByTag("Node")
- .parent()
- .parent()
+ onNodeWithTag("Node")
+ .onParent()
+ .onParent()
.assertExists()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/SiblingSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/SiblingSelectorTest.kt
index d4f4796..f019c5f 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/SiblingSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/SiblingSelectorTest.kt
@@ -19,9 +19,9 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assert
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
-import androidx.ui.test.sibling
+import androidx.ui.test.onSibling
import androidx.ui.test.util.BoundaryNode
import androidx.ui.test.util.expectErrorMessageStartsWith
import org.junit.Rule
@@ -45,8 +45,8 @@
}
}
- findByTag("Child1")
- .sibling()
+ onNodeWithTag("Child1")
+ .onSibling()
.assert(hasTestTag("Child2"))
}
@@ -67,8 +67,8 @@
"Nodes found:"
) {
- findByTag("Child1")
- .sibling()
+ onNodeWithTag("Child1")
+ .onSibling()
.assert(hasTestTag("Child2"))
}
}
@@ -81,8 +81,8 @@
}
}
- findByTag("Child")
- .sibling()
+ onNodeWithTag("Child")
+ .onSibling()
.assertDoesNotExist()
}
@@ -94,8 +94,8 @@
}
}
- findByTag("Child")
- .sibling()
+ onNodeWithTag("Child")
+ .onSibling()
.assertExists()
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/SiblingsSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/SiblingsSelectorTest.kt
index 568481b..124ad9f 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/SiblingsSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/SiblingsSelectorTest.kt
@@ -20,9 +20,9 @@
import androidx.ui.test.assert
import androidx.ui.test.assertCountEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
-import androidx.ui.test.siblings
+import androidx.ui.test.onSiblings
import androidx.ui.test.util.BoundaryNode
import org.junit.Rule
import org.junit.Test
@@ -44,8 +44,8 @@
}
}
- findByTag("Child")
- .siblings()
+ onNodeWithTag("Child")
+ .onSiblings()
.assertCountEquals(0)
}
@@ -58,8 +58,8 @@
}
}
- findByTag("Child1")
- .siblings()
+ onNodeWithTag("Child1")
+ .onSiblings()
.assertCountEquals(1)
}
@@ -73,8 +73,8 @@
}
}
- findByTag("Child2")
- .siblings()
+ onNodeWithTag("Child2")
+ .onSiblings()
.assertCountEquals(2)
.apply {
get(0).assert(hasTestTag("Child1"))
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/Actions.kt b/ui/ui-test/src/main/java/androidx/ui/test/Actions.kt
index 9543c65..a3f01d1 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/Actions.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/Actions.kt
@@ -24,9 +24,9 @@
import androidx.ui.semantics.SemanticsPropertyKey
/**
- * Performs a click action on the given component.
+ * Performs a click action on the element represented by the given semantics node.
*/
-fun SemanticsNodeInteraction.doClick(): SemanticsNodeInteraction {
+fun SemanticsNodeInteraction.performClick(): SemanticsNodeInteraction {
// TODO(jellefresen): Replace with semantics action when semantics merging is done
// The problem we currently have is that the click action might be defined on a different
// semantics node than we're interacting with now, even though it is "semantically" the same.
@@ -35,22 +35,22 @@
// Since in general the intended click action can be on a wrapping node or a child node, we
// can't just forward to the correct node, as we don't know if we should search up or down the
// tree.
- return doGesture {
- sendClick()
+ return performGesture {
+ click()
}
}
/**
- * Scrolls to a component using SemanticsActions. It first identifies a parent component with a
- * Semantics ScrollTo action, then it retrieves the location of the current element and computes
+ * Scrolls to a node using SemanticsActions. It first identifies a parent semantics node with a
+ * Semantics ScrollBy action, then it retrieves the location of the current element and computes
* the relative coordinates that will be used by the scroller.
*
- * Throws [AssertionError] if there is no parent component with ScrollTo SemanticsAction, the
- * current semantics component doesn't have a bounding rectangle set or if a layout node used to
- * compute the relative coordinates to be fed to the ScrollTo action can't be found.
+ * Throws [AssertionError] if there is no parent node with ScrollBy SemanticsAction, the
+ * current semantics node doesn't have a bounding rectangle set or if a layout node used to
+ * compute the relative coordinates to be fed to the ScrollBy action can't be found.
*/
-fun SemanticsNodeInteraction.doScrollTo(): SemanticsNodeInteraction {
- // find containing component with scroll action
+fun SemanticsNodeInteraction.performScrollTo(): SemanticsNodeInteraction {
+ // find containing node with scroll action
val errorMessageOnFail = "Failed to perform doScrollTo."
val node = fetchSemanticsNode(errorMessageOnFail)
val scrollableSemanticsNode = node.findClosestParentNode {
@@ -68,7 +68,7 @@
val position = layoutNode.coordinates.localToGlobal(Offset(0.0f, 0.0f))
runOnUiThread {
- scrollableSemanticsNode.config[SemanticsActions.ScrollTo].action(
+ scrollableSemanticsNode.config[SemanticsActions.ScrollBy].action(
(globalPosition.x - position.x),
(globalPosition.y - position.y)
)
@@ -82,13 +82,13 @@
*
* Example usage:
* ```
- * findByTag("myWidget")
+ * onNodeWithTag("myWidget")
* .doGesture {
* sendSwipeUp()
* }
* ```
*/
-fun SemanticsNodeInteraction.doGesture(
+fun SemanticsNodeInteraction.performGesture(
block: GestureScope.() -> Unit
): SemanticsNodeInteraction {
val node = fetchSemanticsNode("Failed to perform a gesture.")
@@ -107,19 +107,19 @@
* complete and can be resumed later. It is the responsibility of the caller to make sure partial
* gestures don't leave the test in an inconsistent state.
*
- * When [sending the down event][sendDown], a token is returned which needs to be used in all
+ * When [sending the down event][down], a token is returned which needs to be used in all
* subsequent events of this gesture.
*
* Example usage:
* ```
* val position = Offset(10f, 10f)
- * findByTag("myWidget")
- * .doPartialGesture { sendDown(position) }
+ * onNodeWithTag("myWidget")
+ * .performPartialGesture { sendDown(position) }
* .assertHasClickAction()
- * .doPartialGesture { sendUp(position) }
+ * .performPartialGesture { sendUp(position) }
* ```
*/
-fun SemanticsNodeInteraction.doPartialGesture(
+fun SemanticsNodeInteraction.performPartialGesture(
block: PartialGestureScope.() -> Unit
): SemanticsNodeInteraction {
val node = fetchSemanticsNode("Failed to perform a partial gesture.")
@@ -148,15 +148,15 @@
*
* @throws AssertionError If the semantics action is not defined on this node.
*/
-fun <T : Function<Boolean>> SemanticsNodeInteraction.callSemanticsAction(
+fun <T : Function<Boolean>> SemanticsNodeInteraction.performSemanticsAction(
key: SemanticsPropertyKey<AccessibilityAction<T>>,
invocation: (T) -> Unit
) {
- val node = fetchSemanticsNode("Failed to call ${key.name} action.")
+ val node = fetchSemanticsNode("Failed to perform ${key.name} action.")
if (key !in node.config) {
throw AssertionError(
buildGeneralErrorMessage(
- "Failed to call ${key.name} action as it is not defined on the node.",
+ "Failed to perform ${key.name} action as it is not defined on the node.",
selector, node)
)
}
@@ -179,8 +179,111 @@
*
* @throws AssertionError If the semantics action is not defined on this node.
*/
-fun SemanticsNodeInteraction.callSemanticsAction(
+fun SemanticsNodeInteraction.performSemanticsAction(
key: SemanticsPropertyKey<AccessibilityAction<() -> Boolean>>
) {
- callSemanticsAction(key) { it.invoke() }
+ performSemanticsAction(key) { it.invoke() }
}
+
+// DEPRECATED APIs SECTION
+
+/**
+ * Performs a click action on the given component.
+ */
+@Deprecated("Renamed to performClick",
+ replaceWith = ReplaceWith("performClick()"))
+fun SemanticsNodeInteraction.doClick(): SemanticsNodeInteraction = performClick()
+
+/**
+ * Scrolls to a component using SemanticsActions. It first identifies a parent component with a
+ * Semantics ScrollTo action, then it retrieves the location of the current element and computes
+ * the relative coordinates that will be used by the scroller.
+ *
+ * Throws [AssertionError] if there is no parent component with ScrollTo SemanticsAction, the
+ * current semantics component doesn't have a bounding rectangle set or if a layout node used to
+ * compute the relative coordinates to be fed to the ScrollTo action can't be found.
+ */
+@Deprecated("Renamed to performScrollTo",
+ replaceWith = ReplaceWith("performScrollTo()"))
+fun SemanticsNodeInteraction.doScrollTo(): SemanticsNodeInteraction = performScrollTo()
+
+/**
+ * Executes the gestures specified in the given block.
+ *
+ * Example usage:
+ * ```
+ * onNodeWithTag("myWidget")
+ * .doGesture {
+ * sendSwipeUp()
+ * }
+ * ```
+ */
+@Deprecated("Renamed to performGesture",
+ replaceWith = ReplaceWith("performGesture(block)"))
+fun SemanticsNodeInteraction.doGesture(
+ block: GestureScope.() -> Unit
+): SemanticsNodeInteraction = performGesture(block)
+
+/**
+ * Executes the (partial) gesture specified in the given block. The gesture doesn't need to be
+ * complete and can be resumed later. It is the responsibility of the caller to make sure partial
+ * gestures don't leave the test in an inconsistent state.
+ *
+ * When [sending the down event][down], a token is returned which needs to be used in all
+ * subsequent events of this gesture.
+ *
+ * Example usage:
+ * ```
+ * val position = Offset(10f, 10f)
+ * onNodeWithTag("myWidget")
+ * .doPartialGesture { sendDown(position) }
+ * .assertHasClickAction()
+ * .doPartialGesture { sendUp(position) }
+ * ```
+ */
+@Deprecated("Renamed to performPartialGesture",
+ replaceWith = ReplaceWith("performPartialGesture(block)"))
+fun SemanticsNodeInteraction.doPartialGesture(
+ block: PartialGestureScope.() -> Unit
+): SemanticsNodeInteraction = performPartialGesture(block)
+
+/**
+ * Provides support to call custom semantics actions on this node.
+ *
+ * This method is supposed to be used for actions with parameters.
+ *
+ * This will properly verify that the actions exists and provide clear error message in case it
+ * does not. It also handle synchronization and performing the action on the UI thread. This call
+ * is blocking until the action is performed
+ *
+ * @param key Key of the action to be performed.
+ * @param invocation Place where you call your action. In the argument is provided the underlying
+ * action from the given Semantics action.
+ *
+ * @throws AssertionError If the semantics action is not defined on this node.
+ */
+@Deprecated("Renamed to performSemanticsAction",
+ replaceWith = ReplaceWith("performSemanticsAction(key, invocation)"))
+fun <T : Function<Boolean>> SemanticsNodeInteraction.callSemanticsAction(
+ key: SemanticsPropertyKey<AccessibilityAction<T>>,
+ invocation: (T) -> Unit
+) = performSemanticsAction(key, invocation)
+
+/**
+ * Provides support to call custom semantics actions on this node.
+ *
+ * This method is for calling actions that have no parameters.
+ *
+ * This will properly verify that the actions exists and provide clear error message in case it
+ * does not. It also handle synchronization and performing the action on the UI thread. This call
+ * is blocking until the action is performed
+ *
+ * @param key Key of the action to be performed.
+ *
+ * @throws AssertionError If the semantics action is not defined on this node.
+ */
+@Deprecated("Renamed to performSemanticsAction",
+ replaceWith = ReplaceWith("performSemanticsAction(key)"))
+fun SemanticsNodeInteraction.callSemanticsAction(
+ key: SemanticsPropertyKey<AccessibilityAction<() -> Boolean>>
+) = performSemanticsAction(key)
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/Assertions.kt b/ui/ui-test/src/main/java/androidx/ui/test/Assertions.kt
index 7e72a19..a5641aa 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/Assertions.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/Assertions.kt
@@ -31,31 +31,31 @@
import androidx.ui.unit.width
/**
- * Asserts that the current component has hidden property set to true.
+ * Asserts that the current semantics node has hidden property set to true.
*
- * Note that this does not verify parents of the component. For stronger guarantees of visibility
- * see [assertIsNotDisplayed]. If you want to assert that the component is not even in the hierarchy
+ * Note that this does not verify parents of the node. For stronger guarantees of visibility
+ * see [assertIsNotDisplayed]. If you want to assert that the node is not even in the hierarchy
* use [SemanticsNodeInteraction.assertDoesNotExist].
*
- * Throws [AssertionError] if the component is not hidden.
+ * Throws [AssertionError] if the node is not hidden.
*/
fun SemanticsNodeInteraction.assertIsHidden(): SemanticsNodeInteraction = assert(isHidden())
/**
- * Asserts that the current component has hidden property set to false.
+ * Asserts that the current semantics node has hidden property set to false.
*
- * Note that this does not verify parents of the component. For stronger guarantees of visibility
- * see [assertIsDisplayed]. If you only want to assert that the component is in the hierarchy use
+ * Note that this does not verify parents of the node. For stronger guarantees of visibility
+ * see [assertIsDisplayed]. If you only want to assert that the node is in the hierarchy use
* [SemanticsNodeInteraction.assertExists]
*
- * Throws [AssertionError] if the component is hidden.
+ * Throws [AssertionError] if the node is hidden.
*/
fun SemanticsNodeInteraction.assertIsNotHidden(): SemanticsNodeInteraction = assert(isNotHidden())
/**
- * Asserts that the current component is displayed on screen.
+ * Asserts that the current semantics node is displayed on screen.
*
- * Throws [AssertionError] if the component is not displayed.
+ * Throws [AssertionError] if the node is not displayed.
*/
fun SemanticsNodeInteraction.assertIsDisplayed(): SemanticsNodeInteraction {
// TODO(b/143607231): check semantics hidden property
@@ -69,9 +69,9 @@
}
/**
- * Asserts that the current component is not displayed on screen.
+ * Asserts that the current semantics node is not displayed on screen.
*
- * Throws [AssertionError] if the component is displayed.
+ * Throws [AssertionError] if the node is displayed.
*/
fun SemanticsNodeInteraction.assertIsNotDisplayed(): SemanticsNodeInteraction {
// TODO(b/143607231): check semantics hidden property
@@ -85,73 +85,73 @@
}
/**
- * Asserts that the current component is enabled.
+ * Asserts that the current semantics node is enabled.
*
- * Throws [AssertionError] if the component is not enabled or does not define the property at all.
+ * Throws [AssertionError] if the node is not enabled or does not define the property at all.
*/
fun SemanticsNodeInteraction.assertIsEnabled(): SemanticsNodeInteraction = assert(isEnabled())
/**
- * Asserts that the current component is not enabled.
+ * Asserts that the current semantics node is not enabled.
*
- * Throws [AssertionError] if the component is enabled or does not defined the property at all.
+ * Throws [AssertionError] if the node is enabled or does not defined the property at all.
*/
fun SemanticsNodeInteraction.assertIsNotEnabled(): SemanticsNodeInteraction = assert(isNotEnabled())
/**
- * Asserts that the current component is checked.
+ * Asserts that the current semantics node is checked.
*
- * Throws [AssertionError] if the component is not unchecked, indeterminate, or not toggleable.
+ * Throws [AssertionError] if the node is not unchecked, indeterminate, or not toggleable.
*/
fun SemanticsNodeInteraction.assertIsOn(): SemanticsNodeInteraction = assert(isOn())
/**
- * Asserts that the current component is unchecked.
+ * Asserts that the current semantics node is unchecked.
*
- * Throws [AssertionError] if the component is checked, indeterminate, or not toggleable.
+ * Throws [AssertionError] if the node is checked, indeterminate, or not toggleable.
*/
fun SemanticsNodeInteraction.assertIsOff(): SemanticsNodeInteraction = assert(isOff())
/**
- * Asserts that the current component is selected.
+ * Asserts that the current semantics node is selected.
*
- * Throws [AssertionError] if the component is unselected or not selectable.
+ * Throws [AssertionError] if the node is unselected or not selectable.
*/
fun SemanticsNodeInteraction.assertIsSelected(): SemanticsNodeInteraction = assert(isSelected())
/**
- * Asserts that the current component is unselected.
+ * Asserts that the current semantics node is unselected.
*
- * Throws [AssertionError] if the component is selected or not selectable.
+ * Throws [AssertionError] if the node is selected or not selectable.
*/
fun SemanticsNodeInteraction.assertIsUnselected(): SemanticsNodeInteraction =
assert(isUnselected())
/**
- * Asserts that the current component is toggleable.
+ * Asserts that the current semantics node is toggleable.
*
- * Throws [AssertionError] if the component is not toggleable.
+ * Throws [AssertionError] if the node is not toggleable.
*/
fun SemanticsNodeInteraction.assertIsToggleable(): SemanticsNodeInteraction =
assert(isToggleable())
/**
- * Asserts that the current component is selectable.
+ * Asserts that the current semantics node is selectable.
*
- * Throws [AssertionError] if the component is not selectable.
+ * Throws [AssertionError] if the node is not selectable.
*/
fun SemanticsNodeInteraction.assertIsSelectable(): SemanticsNodeInteraction =
assert(isSelectable())
/**
- * Asserts the component is in a mutually exclusive group. This is used by radio groups to assert
- * only one is selected at a given time.
+ * Asserts the semantics node is in a mutually exclusive group. This is used by radio groups to
+ * assert only one is selected at a given time.
*/
fun SemanticsNodeInteraction.assertIsInMutuallyExclusiveGroup(): SemanticsNodeInteraction =
assert(isInMutuallyExclusiveGroup())
/**
- * Asserts the component's label equals the given String.
+ * Asserts the node's label equals the given String.
* For further details please check [SemanticsProperties.AccessibilityLabel].
* Throws [AssertionError] if the node's value is not equal to `value`, or if the node has no value
*/
@@ -159,7 +159,7 @@
assert(hasLabel(value))
/**
- * Asserts the component's text equals the given String.
+ * Asserts the node's text equals the given String.
* For further details please check [SemanticsProperties.Text].
* Throws [AssertionError] if the node's value is not equal to `value`, or if the node has no value
*/
@@ -167,7 +167,7 @@
assert(hasText(value))
/**
- * Asserts the component's value equals the given value.
+ * Asserts the node's value equals the given value.
*
* For further details please check [SemanticsProperties.AccessibilityValue].
* Throws [AssertionError] if the node's value is not equal to `value`, or if the node has no value
@@ -176,7 +176,7 @@
assert(hasValue(value))
/**
- * Asserts the component's range info equals the given value.
+ * Asserts the node's range info equals the given value.
*
* For further details please check [SemanticsProperties.AccessibilityRangeInfo].
* Throws [AssertionError] if the node's value is not equal to `value`, or if the node has no value
@@ -186,17 +186,17 @@
assert(hasRangeInfo(value))
/**
- * Asserts that the current component has a click action.
+ * Asserts that the current semantics node has a click action.
*
- * Throws [AssertionError] if the component is doesn't have a click action.
+ * Throws [AssertionError] if the node is doesn't have a click action.
*/
fun SemanticsNodeInteraction.assertHasClickAction(): SemanticsNodeInteraction =
assert(hasClickAction())
/**
- * Asserts that the current component doesn't have a click action.
+ * Asserts that the current semantics node has doesn't have a click action.
*
- * Throws [AssertionError] if the component has a click action.
+ * Throws [AssertionError] if the node has a click action.
*/
fun SemanticsNodeInteraction.assertHasNoClickAction(): SemanticsNodeInteraction =
assert(hasNoClickAction())
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/BitmapHelpers.kt b/ui/ui-test/src/main/java/androidx/ui/test/BitmapHelpers.kt
index 822aeb2..6f2b904 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/BitmapHelpers.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/BitmapHelpers.kt
@@ -43,9 +43,9 @@
import kotlin.math.roundToInt
/**
- * Captures the underlying component's surface into bitmap.
+ * Captures the underlying semantics node's surface into bitmap.
*
- * This has a limitation that if there is another window covering part of this component, such a
+ * This has a limitation that if there is another window covering part of this node, such a
* window won't occur in this bitmap.
*/
@RequiresApi(Build.VERSION_CODES.O)
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/Filters.kt b/ui/ui-test/src/main/java/androidx/ui/test/Filters.kt
index eba23b0..4f8fad7 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/Filters.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/Filters.kt
@@ -28,23 +28,23 @@
import androidx.ui.util.fastAny
/**
- * Returns whether the component is enabled.
+ * Returns whether the node is enabled.
*
- * @see SemanticsProperties.Enabled
+ * @see SemanticsProperties.Disabled
*/
fun isEnabled(): SemanticsMatcher =
- SemanticsMatcher.expectValue(SemanticsProperties.Enabled, true)
+ !SemanticsMatcher.keyIsDefined(SemanticsProperties.Disabled)
/**
- * Returns whether the component is not enabled.
+ * Returns whether the node is not enabled.
*
- * @see SemanticsProperties.Enabled
+ * @see SemanticsProperties.Disabled
*/
fun isNotEnabled(): SemanticsMatcher =
- SemanticsMatcher.expectValue(SemanticsProperties.Enabled, false)
+ SemanticsMatcher.keyIsDefined(SemanticsProperties.Disabled)
/**
- * Return whether the component is checkable.
+ * Return whether the node is checkable.
*
* @see FoundationSemanticsProperties.ToggleableState
*/
@@ -52,7 +52,7 @@
SemanticsMatcher.keyIsDefined(FoundationSemanticsProperties.ToggleableState)
/**
- * Returns whether the component is toggled.
+ * Returns whether the node is toggled.
*
* @see FoundationSemanticsProperties.ToggleableState
*/
@@ -60,7 +60,7 @@
FoundationSemanticsProperties.ToggleableState, ToggleableState.On)
/**
- * Returns whether the component is not toggled.
+ * Returns whether the node is not toggled.
*
* @see FoundationSemanticsProperties.ToggleableState
*/
@@ -68,7 +68,7 @@
FoundationSemanticsProperties.ToggleableState, ToggleableState.Off)
/**
- * Return whether the component is selectable.
+ * Return whether the node is selectable.
*
* @see FoundationSemanticsProperties.Selected
*/
@@ -76,7 +76,7 @@
SemanticsMatcher.keyIsDefined(FoundationSemanticsProperties.Selected)
/**
- * Returns whether the component is selected.
+ * Returns whether the node is selected.
*
* @see FoundationSemanticsProperties.Selected
*/
@@ -84,7 +84,7 @@
SemanticsMatcher.expectValue(FoundationSemanticsProperties.Selected, true)
/**
- * Returns whether the component is not selected.
+ * Returns whether the node is not selected.
*
* @see FoundationSemanticsProperties.Selected
*/
@@ -92,7 +92,7 @@
SemanticsMatcher.expectValue(FoundationSemanticsProperties.Selected, false)
/**
- * Return whether the component has a semantics click action defined.
+ * Return whether the node has a semantics click action defined.
*
* @see SemanticsActions.OnClick
*/
@@ -100,7 +100,7 @@
SemanticsMatcher.keyIsDefined(SemanticsActions.OnClick)
/**
- * Return whether the component has no semantics click action defined.
+ * Return whether the node has no semantics click action defined.
*
* @see SemanticsActions.OnClick
*/
@@ -108,23 +108,23 @@
SemanticsMatcher.keyNotDefined(SemanticsActions.OnClick)
/**
- * Return whether the component has a semantics scrollable action defined.
+ * Return whether the node has a semantics scrollable action defined.
*
- * @see SemanticsActions.ScrollTo
+ * @see SemanticsActions.ScrollBy
*/
fun hasScrollAction(): SemanticsMatcher =
- SemanticsMatcher.keyIsDefined(SemanticsActions.ScrollTo)
+ SemanticsMatcher.keyIsDefined(SemanticsActions.ScrollBy)
/**
- * Return whether the component has no semantics scrollable action defined.
+ * Return whether the node has no semantics scrollable action defined.
*
- * @see SemanticsActions.ScrollTo
+ * @see SemanticsActions.ScrollBy
*/
fun hasNoScrollAction(): SemanticsMatcher =
- SemanticsMatcher.keyNotDefined(SemanticsActions.ScrollTo)
+ SemanticsMatcher.keyNotDefined(SemanticsActions.ScrollBy)
/**
- * Returns whether the component's label matches exactly to the given text.
+ * Returns whether the node's label matches exactly to the given text.
*
* @param label Text to match.
* @param ignoreCase Whether case should be ignored.
@@ -140,7 +140,7 @@
}
/**
- * Returns whether the component's text matches exactly to the given text.
+ * Returns whether the node's text matches exactly to the given text.
*
* @param text Text to match.
* @param ignoreCase Whether case should be ignored.
@@ -157,7 +157,7 @@
}
/**
- * Returns whether the component's text contains the given substring.
+ * Returns whether the node's text contains the given substring.
*
* @param substring Substring to check.
* @param ignoreCase Whether case should be ignored.
@@ -176,7 +176,7 @@
}
/**
- * Returns whether the component's value matches exactly to the given accessibility value.
+ * Returns whether the node's value matches exactly to the given accessibility value.
*
* @param value Value to match.
*
@@ -186,7 +186,7 @@
SemanticsProperties.AccessibilityValue, value)
/**
- * Returns whether the component's range info matches exactly to the given accessibility range info.
+ * Returns whether the node's range info matches exactly to the given accessibility range info.
*
* @param rangeInfo range info to match.
*
@@ -196,7 +196,7 @@
.expectValue(SemanticsProperties.AccessibilityRangeInfo, rangeInfo)
/**
- * Returns whether the component is annotated by the given test tag.
+ * Returns whether the node is annotated by the given test tag.
*
* @param testTag Value to match.
*
@@ -205,9 +205,8 @@
fun hasTestTag(testTag: String): SemanticsMatcher =
SemanticsMatcher.expectValue(SemanticsProperties.TestTag, testTag)
-// TODO(ryanmentley/pavlis): Do we want these convenience functions?
/**
- * Verifies that the component is in a mutually exclusive group - that is,
+ * Verifies that the node is in a mutually exclusive group - that is,
* that [FoundationSemanticsProperties.InMutuallyExclusiveGroup] is set to true
*
*/
@@ -215,29 +214,29 @@
SemanticsMatcher.expectValue(FoundationSemanticsProperties.InMutuallyExclusiveGroup, true)
/**
- * Returns whether the component is hidden.
+ * Returns whether the node is hidden.
*
- * This checks only the property of the component itself. Ignoring parents visibility.
+ * This checks only the property of the node itself. Ignoring parents visibility.
*
* @see SemanticsProperties.Hidden
*/
fun isHidden(): SemanticsMatcher =
- SemanticsMatcher.expectValue(SemanticsProperties.Hidden, true)
+ SemanticsMatcher.keyIsDefined(SemanticsProperties.Hidden)
/**
- * Returns whether the component is not hidden.
+ * Returns whether the node is not hidden.
*
- * This checks only the property of the component itself. Ignoring parents visibility.
+ * This checks only the property of the node itself. Ignoring parents visibility.
*
* @see SemanticsProperties.Hidden
*/
fun isNotHidden(): SemanticsMatcher =
- SemanticsMatcher.expectValue(SemanticsProperties.Hidden, false)
+ !SemanticsMatcher.keyIsDefined(SemanticsProperties.Hidden)
/**
- * Returns whether the component is a dialog.
+ * Returns whether the node is a dialog.
*
- * This only checks if the component itself is a dialog, not if it is _part of_ a dialog. Use
+ * This only checks if the node itself is a dialog, not if it is _part of_ a dialog. Use
* `hasAnyAncestorThat(isDialog())` for that.
*
* @see FoundationSemanticsProperties.IsDialog
@@ -245,9 +244,9 @@
fun isDialog(): SemanticsMatcher =
SemanticsMatcher.keyIsDefined(FoundationSemanticsProperties.IsDialog)
-/** Returns whether the component is a popup.
+/** Returns whether the node is a popup.
*
- * This only checks if the component itself is a popup, not if it is _part of_ a popup. Use
+ * This only checks if the node itself is a popup, not if it is _part of_ a popup. Use
* `hasAnyAncestorThat(isPopup())` for that.
*
* @see SemanticsProperties.IsPopup
@@ -256,7 +255,7 @@
SemanticsMatcher.keyIsDefined(SemanticsProperties.IsPopup)
/**
- * Returns whether the component defines the given IME action.
+ * Returns whether the node defines the given IME action.
*
* @param actionType the action to match.
*/
@@ -264,30 +263,30 @@
SemanticsMatcher.expectValue(TextSemanticsProperties.ImeAction, actionType)
/**
- * Return whether the component supports input methods.
+ * Return whether the node supports input methods.
*
- * Supporting input methods means that the component provides a connection to IME (keyboard) and is
- * able to accept input from it. This is however not enforced and relies on the components to
+ * Supporting input methods means that the node provides a connection to IME (keyboard) and is
+ * able to accept input from it. This is however not enforced and relies on the nodes to
* properly add this to semantics when they provide input. Note that this is not related to
* gestures input but only to IME. This can be used to for instance filter out all text fields.
*/
fun hasInputMethodsSupport() =
- SemanticsMatcher.expectValue(TextSemanticsProperties.SupportsInputMethods, true)
+ SemanticsMatcher.keyIsDefined(TextSemanticsProperties.SupportsInputMethods)
-/*
- * Return whether the component is the root semantics node.
+/**
+ * Return whether the node is the root semantics node.
*
- * There is always one root in every component tree, added implicitly by Compose.
+ * There is always one root in every node tree, added implicitly by Compose.
*/
fun isRoot() =
SemanticsMatcher("isRoot") { it.isRoot }
/**
- * Returns whether the component's parent satisfies the given matcher.
+ * Returns whether the node's parent satisfies the given matcher.
*
* Returns false if no parent exists.
*/
-fun hasParentThat(matcher: SemanticsMatcher): SemanticsMatcher {
+fun hasParent(matcher: SemanticsMatcher): SemanticsMatcher {
// TODO(b/150292800): If this is used in assert we should print the parent's node semantics
// in the error message or say that no parent was found.
return SemanticsMatcher("hasParentThat(${matcher.description})") {
@@ -296,9 +295,9 @@
}
/**
- * Returns whether the component has at least one child that satisfies the given matcher.
+ * Returns whether the node has at least one child that satisfies the given matcher.
*/
-fun hasAnyChildThat(matcher: SemanticsMatcher): SemanticsMatcher {
+fun hasAnyChild(matcher: SemanticsMatcher): SemanticsMatcher {
// TODO(b/150292800): If this is used in assert we should print the children nodes semantics
// in the error message or say that no children were found.
return SemanticsMatcher("hasAnyChildThat(${matcher.description})") {
@@ -307,11 +306,11 @@
}
/**
- * Returns whether the component has at least one sibling that satisfies the given matcher.
+ * Returns whether the node has at least one sibling that satisfies the given matcher.
*
* Sibling is defined as a any other node that shares the same parent.
*/
-fun hasAnySiblingThat(matcher: SemanticsMatcher): SemanticsMatcher {
+fun hasAnySibling(matcher: SemanticsMatcher): SemanticsMatcher {
// TODO(b/150292800): If this is used in assert we should print the sibling nodes semantics
// in the error message or say that no siblings were found.
return SemanticsMatcher("hasAnySiblingThat(${matcher.description})"
@@ -323,7 +322,7 @@
}
/**
- * Returns whether the component has at least one ancestor that satisfies the given matcher.
+ * Returns whether the node has at least one ancestor that satisfies the given matcher.
*
* Example: For the following tree
* |-X
@@ -333,7 +332,7 @@
* |-C2
* In case of C1, we would check the matcher against A and B
*/
-fun hasAnyAncestorThat(matcher: SemanticsMatcher): SemanticsMatcher {
+fun hasAnyAncestor(matcher: SemanticsMatcher): SemanticsMatcher {
// TODO(b/150292800): If this is used in assert we should print the ancestor nodes semantics
// in the error message or say that no ancestors were found.
return SemanticsMatcher("hasAnyAncestorThat(${matcher.description})") {
@@ -342,7 +341,7 @@
}
/**
- * Returns whether the component has at least one descendant that satisfies the given matcher.
+ * Returns whether the node has at least one descendant that satisfies the given matcher.
*
* Example: For the following tree
* |-X
@@ -352,7 +351,7 @@
* |-C2
* In case of A, we would check the matcher against B,C1 and C2
*/
-fun hasAnyDescendantThat(matcher: SemanticsMatcher): SemanticsMatcher {
+fun hasAnyDescendant(matcher: SemanticsMatcher): SemanticsMatcher {
// TODO(b/150292800): If this is used in assert we could consider printing the whole subtree but
// it might be too much to show. But we could at least warn if there were no ancestors found.
fun checkIfSubtreeMatches(matcher: SemanticsMatcher, node: SemanticsNode): Boolean {
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/Finders.kt b/ui/ui-test/src/main/java/androidx/ui/test/Finders.kt
index fd37af3..95650cb 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/Finders.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/Finders.kt
@@ -17,18 +17,170 @@
package androidx.ui.test
/**
+ * Finds a semantics node identified by the given tag.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ *
+ * @see onNode for general find method.
+ */
+fun onNodeWithTag(
+ testTag: String,
+ useUnmergedTree: Boolean = false
+): SemanticsNodeInteraction = onNode(hasTestTag(testTag), useUnmergedTree)
+
+/**
+ * Finds all semantics nodes identified by the given tag.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ *
+ * @see onAllNodes for general find method.
+ */
+fun onAllNodesWithTag(
+ testTag: String,
+ useUnmergedTree: Boolean = false
+): SemanticsNodeInteractionCollection = onAllNodes(hasTestTag(testTag), useUnmergedTree)
+
+/**
+ * Finds a semantics node with the given label as its accessibilityLabel.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ *
+ * @see onNode for general find method.
+ */
+fun onNodeWithLabel(
+ label: String,
+ ignoreCase: Boolean = false,
+ useUnmergedTree: Boolean = false
+): SemanticsNodeInteraction = onNode(hasLabel(label, ignoreCase), useUnmergedTree)
+
+/**
+ * Finds a semantincs node with the given text.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ * @see onNodeWithSubstring to search by substring instead of via exact match.
+ * @see onNode for general find method.
+ */
+fun onNodeWithText(
+ text: String,
+ ignoreCase: Boolean = false,
+ useUnmergedTree: Boolean = false
+): SemanticsNodeInteraction = onNode(hasText(text, ignoreCase), useUnmergedTree)
+
+/**
+ * Finds a semantics node with text that contains the given substring.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ * @see onNodeWithText to perform exact matches.
+ * @see onNode for general find method.
+ */
+fun onNodeWithSubstring(
+ text: String,
+ ignoreCase: Boolean = false,
+ useUnmergedTree: Boolean = false
+): SemanticsNodeInteraction = onNode(hasSubstring(text, ignoreCase), useUnmergedTree)
+
+/**
+ * Finds all semantics nodes with the given text.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ */
+fun onAllNodesWithText(
+ text: String,
+ ignoreCase: Boolean = false,
+ useUnmergedTree: Boolean = false
+): SemanticsNodeInteractionCollection = onAllNodes(hasText(text, ignoreCase), useUnmergedTree)
+
+/**
+ * Finds all semantics nodes with the given label as AccessibilityLabel.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ */
+fun onAllNodesWithLabel(
+ label: String,
+ ignoreCase: Boolean = false,
+ useUnmergedTree: Boolean = false
+): SemanticsNodeInteractionCollection = onAllNodes(hasLabel(label, ignoreCase), useUnmergedTree)
+
+/**
+ * Finds the root semantics node of the Compose tree.
+ *
+ * Useful for example for screenshot tests of the entire scene.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ */
+fun onRoot(useUnmergedTree: Boolean = false): SemanticsNodeInteraction =
+ onNode(isRoot(), useUnmergedTree)
+
+/**
+ * Finds a semantics node that matches the given condition.
+ *
+ * Any subsequent operation on its result will expect exactly one element found (unless
+ * [SemanticsNodeInteraction.assertDoesNotExist] is used) and will throw [AssertionError] if
+ * none or more than one element is found.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ * @see onAllNodes to work with multiple elements
+ */
+fun onNode(
+ matcher: SemanticsMatcher,
+ useUnmergedTree: Boolean = false
+): SemanticsNodeInteraction {
+ return SemanticsNodeInteraction(useUnmergedTree, SemanticsSelector(matcher))
+}
+
+/**
+ * Finds all semantics nodes that match the given condition.
+ *
+ * If you are working with elements that are not supposed to occur multiple times use [onNode]
+ * instead.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ * @see onNode
+ */
+fun onAllNodes(
+ matcher: SemanticsMatcher,
+ useUnmergedTree: Boolean = false
+): SemanticsNodeInteractionCollection {
+ return SemanticsNodeInteractionCollection(useUnmergedTree, SemanticsSelector(matcher))
+}
+
+// DEPRECATED APIs SECTION
+
+/**
* Finds a component identified by the given tag.
*
* For usage patterns and semantics concepts see [SemanticsNodeInteraction]
*
* @param useUnmergedTree Find within merged composables like Buttons.
*
- * @see find for general find method.
+ * @see onNode for general find method.
*/
+@Deprecated("Renamed to onNodeWithTag",
+ replaceWith = ReplaceWith("onNodeWithTag(testTag, useUnmergedTree)"))
fun findByTag(
testTag: String,
useUnmergedTree: Boolean = false
-): SemanticsNodeInteraction = find(hasTestTag(testTag), useUnmergedTree)
+): SemanticsNodeInteraction = onNodeWithTag(testTag, useUnmergedTree)
/**
* Finds all components identified by the given tag.
@@ -37,12 +189,14 @@
*
* @param useUnmergedTree Find within merged composables like Buttons.
*
- * @see findAll for general find method.
+ * @see onAllNodes for general find method.
*/
+@Deprecated("Renamed to onAllNodesWithTag",
+ replaceWith = ReplaceWith("onAllNodesWithTag(testTag, useUnmergedTree)"))
fun findAllByTag(
testTag: String,
useUnmergedTree: Boolean = false
-): SemanticsNodeInteractionCollection = findAll(hasTestTag(testTag), useUnmergedTree)
+): SemanticsNodeInteractionCollection = onAllNodesWithTag(testTag, useUnmergedTree)
/**
* Finds a component with the given label as its accessibilityLabel.
@@ -51,13 +205,15 @@
*
* @param useUnmergedTree Find within merged composables like Buttons.
*
- * @see find for general find method.
+ * @see onNode for general find method.
*/
+@Deprecated("Renamed to onNodeWithLabel",
+ replaceWith = ReplaceWith("onNodeWithLabel(label, ignoreCase, useUnmergedTree)"))
fun findByLabel(
label: String,
ignoreCase: Boolean = false,
useUnmergedTree: Boolean = false
-): SemanticsNodeInteraction = find(hasLabel(label, ignoreCase), useUnmergedTree)
+): SemanticsNodeInteraction = onNodeWithLabel(label, ignoreCase, useUnmergedTree)
/**
* Finds a component with the given text.
@@ -65,14 +221,16 @@
* For usage patterns and semantics concepts see [SemanticsNodeInteraction]
*
* @param useUnmergedTree Find within merged composables like Buttons.
- * @see findBySubstring to search by substring instead of via exact match.
- * @see find for general find method.
+ * @see onNodeWithSubstring to search by substring instead of via exact match.
+ * @see onNode for general find method.
*/
+@Deprecated("Renamed to onNodeWithText",
+ replaceWith = ReplaceWith("onNodeWithText(text, ignoreCase, useUnmergedTree)"))
fun findByText(
text: String,
ignoreCase: Boolean = false,
useUnmergedTree: Boolean = false
-): SemanticsNodeInteraction = find(hasText(text, ignoreCase), useUnmergedTree)
+): SemanticsNodeInteraction = onNodeWithText(text, ignoreCase, useUnmergedTree)
/**
* Finds a component with text that contains the given substring.
@@ -80,14 +238,16 @@
* For usage patterns and semantics concepts see [SemanticsNodeInteraction]
*
* @param useUnmergedTree Find within merged composables like Buttons.
- * @see findByText to perform exact matches.
- * @see find for general find method.
+ * @see onNodeWithText to perform exact matches.
+ * @see onNode for general find method.
*/
+@Deprecated("Renamed to onNodeWithSubstring",
+ replaceWith = ReplaceWith("onNodeWithSubstring(text, ignoreCase, useUnmergedTree)"))
fun findBySubstring(
text: String,
ignoreCase: Boolean = false,
useUnmergedTree: Boolean = false
-): SemanticsNodeInteraction = find(hasSubstring(text, ignoreCase), useUnmergedTree)
+): SemanticsNodeInteraction = onNodeWithSubstring(text, ignoreCase, useUnmergedTree)
/**
* Finds all components with the given text.
@@ -96,11 +256,13 @@
*
* @param useUnmergedTree Find within merged composables like Buttons.
*/
+@Deprecated("Renamed to onAllNodesWithText",
+ replaceWith = ReplaceWith("onAllNodesWithText(text, ignoreCase, useUnmergedTree)"))
fun findAllByText(
text: String,
ignoreCase: Boolean = false,
useUnmergedTree: Boolean = false
-): SemanticsNodeInteractionCollection = findAll(hasText(text, ignoreCase), useUnmergedTree)
+): SemanticsNodeInteractionCollection = onAllNodesWithText(text, ignoreCase, useUnmergedTree)
/**
* Finds all components with the given label as AccessibilityLabel.
@@ -109,11 +271,13 @@
*
* @param useUnmergedTree Find within merged composables like Buttons.
*/
+@Deprecated("Renamed to onAllNodesWithLabel",
+ replaceWith = ReplaceWith("onAllNodesWithLabel(label, ignoreCase, useUnmergedTree)"))
fun findAllByLabel(
label: String,
ignoreCase: Boolean = false,
useUnmergedTree: Boolean = false
-): SemanticsNodeInteractionCollection = findAll(hasLabel(label, ignoreCase), useUnmergedTree)
+): SemanticsNodeInteractionCollection = onAllNodesWithLabel(label, ignoreCase, useUnmergedTree)
/**
* Finds the root semantics node of the Compose tree. Useful for example for screenshot tests
@@ -123,8 +287,10 @@
*
* @param useUnmergedTree Find within merged composables like Buttons.
*/
+@Deprecated("Renamed to onRoot",
+ replaceWith = ReplaceWith("onRoot(useUnmergedTree)"))
fun findRoot(useUnmergedTree: Boolean = false): SemanticsNodeInteraction =
- find(isRoot(), useUnmergedTree)
+ onRoot(useUnmergedTree)
/**
* Finds a component that matches the given condition.
@@ -136,14 +302,14 @@
* For usage patterns and semantics concepts see [SemanticsNodeInteraction]
*
* @param useUnmergedTree Find within merged composables like Buttons.
- * @see findAll to work with multiple elements
+ * @see onAllNodes to work with multiple elements
*/
+@Deprecated("Renamed to onNode",
+ replaceWith = ReplaceWith("onNode(matcher, useUnmergedTree)"))
fun find(
matcher: SemanticsMatcher,
useUnmergedTree: Boolean = false
-): SemanticsNodeInteraction {
- return SemanticsNodeInteraction(useUnmergedTree, SemanticsSelector(matcher))
-}
+): SemanticsNodeInteraction = onNode(matcher, useUnmergedTree)
/**
* Finds all components that match the given condition.
@@ -154,11 +320,11 @@
* For usage patterns and semantics concepts see [SemanticsNodeInteraction]
*
* @param useUnmergedTree Find within merged composables like Buttons.
- * @see find
+ * @see onNode
*/
+@Deprecated("Renamed to onAllNodes",
+ replaceWith = ReplaceWith("onAllNodes(matcher, useUnmergedTree)"))
fun findAll(
matcher: SemanticsMatcher,
useUnmergedTree: Boolean = false
-): SemanticsNodeInteractionCollection {
- return SemanticsNodeInteractionCollection(useUnmergedTree, SemanticsSelector(matcher))
-}
+): SemanticsNodeInteractionCollection = onAllNodes(matcher, useUnmergedTree)
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/GestureScope.kt b/ui/ui-test/src/main/java/androidx/ui/test/GestureScope.kt
index 40f5775..560b917 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/GestureScope.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/GestureScope.kt
@@ -78,7 +78,7 @@
}
/**
- * Returns the size of the component we're interacting with
+ * Returns the size of the node we're interacting with
*/
val BaseGestureScope.size: IntSize
get() = semanticsNode.size
@@ -96,38 +96,38 @@
get() = size.height
/**
- * Returns the x-coordinate for the left edge of the component we're interacting with, in the
- * component's local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the x-coordinate for the left edge of the node we're interacting with, in the
+ * node's local coordinate system, where (0, 0) is the top left corner of the node.
*/
@Suppress("unused")
inline val BaseGestureScope.left: Float
get() = 0f
/**
- * Returns the y-coordinate for the bottom of the component we're interacting with, in the
- * component's local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the y-coordinate for the bottom of the node we're interacting with, in the
+ * node's local coordinate system, where (0, 0) is the top left corner of the node.
*/
@Suppress("unused")
inline val BaseGestureScope.top: Float
get() = 0f
/**
- * Returns the x-coordinate for the center of the component we're interacting with, in the
- * component's local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the x-coordinate for the center of the node we're interacting with, in the
+ * node's local coordinate system, where (0, 0) is the top left corner of the node.
*/
inline val BaseGestureScope.centerX: Float
get() = width / 2f
/**
- * Returns the y-coordinate for the center of the component we're interacting with, in the
- * component's local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the y-coordinate for the center of the node we're interacting with, in the
+ * node's local coordinate system, where (0, 0) is the top left corner of the node.
*/
inline val BaseGestureScope.centerY: Float
get() = height / 2f
/**
- * Returns the x-coordinate for the right edge of the component we're interacting with, in the
- * component's local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the x-coordinate for the right edge of the node we're interacting with, in the
+ * node's local coordinate system, where (0, 0) is the top left corner of the node.
* Note that, unless `width == 0`, `right != width`. In particular, `right == width - 1f`, because
* pixels are 0-based. If `width == 0`, `right == 0` too.
*/
@@ -135,8 +135,8 @@
get() = width.let { if (it == 0) 0f else it - 1f }
/**
- * Returns the y-coordinate for the bottom of the component we're interacting with, in the
- * component's local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the y-coordinate for the bottom of the node we're interacting with, in the
+ * node's local coordinate system, where (0, 0) is the top left corner of the node.
* Note that, unless `height == 0`, `bottom != height`. In particular, `bottom == height - 1f`,
* because pixels are 0-based. If `height == 0`, `bottom == 0` too.
*/
@@ -144,76 +144,76 @@
get() = height.let { if (it == 0) 0f else it - 1f }
/**
- * Returns the top left corner of the component we're interacting with, in the component's
- * local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the top left corner of the node we're interacting with, in the node's
+ * local coordinate system, where (0, 0) is the top left corner of the node.
*/
@Suppress("unused")
val BaseGestureScope.topLeft: Offset
get() = Offset(left, top)
/**
- * Returns the center of the top edge of the component we're interacting with, in the component's
- * local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the center of the top edge of the node we're interacting with, in the node's
+ * local coordinate system, where (0, 0) is the top left corner of the node.
*/
val BaseGestureScope.topCenter: Offset
get() = Offset(centerX, top)
/**
- * Returns the top right corner of the component we're interacting with, in the component's
- * local coordinate system, where (0, 0) is the top left corner of the component. Note that
+ * Returns the top right corner of the node we're interacting with, in the node's
+ * local coordinate system, where (0, 0) is the top left corner of the node. Note that
* `topRight.x != width`, see [right].
*/
val BaseGestureScope.topRight: Offset
get() = Offset(right, top)
/**
- * Returns the center of the left edge of the component we're interacting with, in the
- * component's local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the center of the left edge of the node we're interacting with, in the
+ * node's local coordinate system, where (0, 0) is the top left corner of the node.
*/
val BaseGestureScope.centerLeft: Offset
get() = Offset(left, centerY)
/**
- * Returns the center of the component we're interacting with, in the component's
- * local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the center of the node we're interacting with, in the node's
+ * local coordinate system, where (0, 0) is the top left corner of the node.
*/
val BaseGestureScope.center: Offset
get() = Offset(centerX, centerY)
/**
- * Returns the center of the right edge of the component we're interacting with, in the
- * component's local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the center of the right edge of the node we're interacting with, in the
+ * node's local coordinate system, where (0, 0) is the top left corner of the node.
* Note that `centerRight.x != width`, see [right].
*/
val BaseGestureScope.centerRight: Offset
get() = Offset(right, centerY)
/**
- * Returns the bottom left corner of the component we're interacting with, in the component's
- * local coordinate system, where (0, 0) is the top left corner of the component. Note that
+ * Returns the bottom left corner of the node we're interacting with, in the node's
+ * local coordinate system, where (0, 0) is the top left corner of the node. Note that
* `bottomLeft.y != height`, see [bottom].
*/
val BaseGestureScope.bottomLeft: Offset
get() = Offset(left, bottom)
/**
- * Returns the center of the bottom edge of the component we're interacting with, in the component's
- * local coordinate system, where (0, 0) is the top left corner of the component. Note that
+ * Returns the center of the bottom edge of the node we're interacting with, in the node's
+ * local coordinate system, where (0, 0) is the top left corner of the node. Note that
* `bottomCenter.y != height`, see [bottom].
*/
val BaseGestureScope.bottomCenter: Offset
get() = Offset(centerX, bottom)
/**
- * Returns the bottom right corner of the component we're interacting with, in the component's
- * local coordinate system, where (0, 0) is the top left corner of the component. Note that
+ * Returns the bottom right corner of the node we're interacting with, in the node's
+ * local coordinate system, where (0, 0) is the top left corner of the node. Note that
* `bottomRight.x != width` and `bottomRight.y != height`, see [right] and [bottom].
*/
val BaseGestureScope.bottomRight: Offset
get() = Offset(right, bottom)
/**
- * Creates an [Offset] relative to the size of the component we're interacting with. [x] and [y]
+ * Creates an [Offset] relative to the size of the node we're interacting with. [x] and [y]
* are fractions of the [width] and [height]. Note that `percentOffset(1f, 1f) != bottomRight`,
* see [right] and [bottom].
*
@@ -230,7 +230,7 @@
}
/**
- * Returns the global bounds of the component we're interacting with
+ * Returns the global bounds of the node we're interacting with
*/
val BaseGestureScope.globalBounds: PxBounds
get() = semanticsNode.globalBounds
@@ -248,13 +248,13 @@
/**
* The receiver scope for injecting gestures on the [semanticsNode] identified by the
* corresponding [SemanticsNodeInteraction]. Gestures can be injected by calling methods defined
- * on [GestureScope], such as [sendSwipeUp]. The [SemanticsNodeInteraction] can be found by one
- * of the finder methods such as [findByTag].
+ * on [GestureScope], such as [swipeUp]. The [SemanticsNodeInteraction] can be found by one
+ * of the finder methods such as [onNodeWithTag].
*
* Example usage:
* ```
- * findByTag("myWidget")
- * .doGesture {
+ * onNodeWithTag("myWidget")
+ * .performGesture {
* sendSwipeUp()
* }
* ```
@@ -264,50 +264,50 @@
) : BaseGestureScope(semanticsNode)
/**
- * Performs a click gesture at the given [position] on the associated component, or in the center
- * if the [position] is omitted. The [position] is in the component's local coordinate system,
- * where (0, 0) is the top left corner of the component. The default [position] is the
- * center of the component.
+ * Performs a click gesture at the given [position] on the associated node, or in the center
+ * if the [position] is omitted. The [position] is in the node's local coordinate system,
+ * where (0, 0) is the top left corner of the node. The default [position] is the
+ * center of the node.
*
- * @param position The position where to click, in the component's local coordinate system. If
+ * @param position The position where to click, in the node's local coordinate system. If
* omitted, the center position will be used.
*/
-fun GestureScope.sendClick(position: Offset = center) {
+fun GestureScope.click(position: Offset = center) {
inputDispatcher.sendClick(localToGlobal(position))
}
/**
- * Performs a long click gesture at the given [position] on the associated component, or in the
+ * Performs a long click gesture at the given [position] on the associated node, or in the
* center if the [position] is omitted. By default, the [duration] of the press is
- * [LongPressTimeout] + 100 milliseconds. The [position] is in the component's local coordinate
- * system, where (0, 0) is the top left corner of the component.
+ * [LongPressTimeout] + 100 milliseconds. The [position] is in the node's local coordinate
+ * system, where (0, 0) is the top left corner of the node.
*
- * @param position The position of the long click, in the component's local coordinate system. If
+ * @param position The position of the long click, in the node's local coordinate system. If
* omitted, the center position will be used.
* @param duration The time between the down and the up event
*/
-fun GestureScope.sendLongClick(
+fun GestureScope.longClick(
position: Offset = center,
duration: Duration = LongPressTimeout + 100.milliseconds
) {
require(duration >= LongPressTimeout) {
"Long click must have a duration of at least ${LongPressTimeout.inMilliseconds()}ms"
}
- sendSwipe(position, position, duration)
+ swipe(position, position, duration)
}
/**
- * Performs a double click gesture at the given [position] on the associated component, or in the
+ * Performs a double click gesture at the given [position] on the associated node, or in the
* center if the [position] is omitted. By default, the [delay] between the first and the second
- * click is 145 milliseconds (empirically established). The [position] is in the component's
- * local coordinate system, where (0, 0) is the top left corner of the component.
+ * click is 145 milliseconds (empirically established). The [position] is in the node's
+ * local coordinate system, where (0, 0) is the top left corner of the node.
*
- * @param position The position of the double click, in the component's local coordinate system.
+ * @param position The position of the double click, in the node's local coordinate system.
* If omitted, the center position will be used.
* @param delay The time between the up event of the first click and the down event of the second
* click
*/
-fun GestureScope.sendDoubleClick(
+fun GestureScope.doubleClick(
position: Offset = center,
delay: Duration = doubleClickDelay
) {
@@ -321,16 +321,16 @@
}
/**
- * Performs the swipe gesture on the associated component. The motion events are linearly
- * interpolated between [start] and [end]. The coordinates are in the component's local
- * coordinate system, where (0, 0) is the top left corner of the component. The default
+ * Performs the swipe gesture on the associated node. The motion events are linearly
+ * interpolated between [start] and [end]. The coordinates are in the node's local
+ * coordinate system, where (0, 0) is the top left corner of the node. The default
* duration is 200 milliseconds.
*
- * @param start The start position of the gesture, in the component's local coordinate system
- * @param end The end position of the gesture, in the component's local coordinate system
+ * @param start The start position of the gesture, in the node's local coordinate system
+ * @param end The end position of the gesture, in the node's local coordinate system
* @param duration The duration of the gesture
*/
-fun GestureScope.sendSwipe(
+fun GestureScope.swipe(
start: Offset,
end: Offset,
duration: Duration = 200.milliseconds
@@ -341,19 +341,19 @@
}
/**
- * Performs a pinch gesture on the associated component.
+ * Performs a pinch gesture on the associated node.
*
* For each pair of start and end [Offset]s, the motion events are linearly interpolated. The
- * coordinates are in the component's local coordinate system where (0, 0) is the top left
- * corner of the component. The default duration is 400 milliseconds.
+ * coordinates are in the node's local coordinate system where (0, 0) is the top left
+ * corner of the node. The default duration is 400 milliseconds.
*
- * @param start0 The start position of the first gesture in the component's local coordinate system
- * @param end0 The end position of the first gesture in the component's local coordinate system
- * @param start1 The start position of the second gesture in the component's local coordinate system
- * @param end1 The end position of the second gesture in the component's local coordinate system
+ * @param start0 The start position of the first gesture in the node's local coordinate system
+ * @param end0 The end position of the first gesture in the node's local coordinate system
+ * @param start1 The start position of the second gesture in the node's local coordinate system
+ * @param end1 The end position of the second gesture in the node's local coordinate system
* @param duration the duration of the gesture
*/
-fun GestureScope.sendPinch(
+fun GestureScope.pinch(
start0: Offset,
end0: Offset,
start1: Offset,
@@ -376,22 +376,22 @@
}
/**
- * Performs the swipe gesture on the associated component, such that the velocity when the
+ * Performs the swipe gesture on the associated node, such that the velocity when the
* gesture is finished is roughly equal to [endVelocity]. The MotionEvents are linearly
- * interpolated between [start] and [end]. The coordinates are in the component's
- * local coordinate system, where (0, 0) is the top left corner of the component. The
+ * interpolated between [start] and [end]. The coordinates are in the node's
+ * local coordinate system, where (0, 0) is the top left corner of the node. The
* default duration is 200 milliseconds.
*
* Note that due to imprecisions, no guarantees can be made on the precision of the actual
* velocity at the end of the gesture, but generally it is within 0.1% of the desired velocity.
*
- * @param start The start position of the gesture, in the component's local coordinate system
- * @param end The end position of the gesture, in the component's local coordinate system
+ * @param start The start position of the gesture, in the node's local coordinate system
+ * @param end The end position of the gesture, in the node's local coordinate system
* @param endVelocity The velocity of the gesture at the moment it ends. Must be positive.
* @param duration The duration of the gesture. Must be long enough that at least 3 input events
* are generated, which happens with a duration of 25ms or more.
*/
-fun GestureScope.sendSwipeWithVelocity(
+fun GestureScope.swipeWithVelocity(
start: Offset,
end: Offset,
@FloatRange(from = 0.0) endVelocity: Float,
@@ -436,55 +436,55 @@
}
/**
- * Performs a swipe up gesture on the associated component. The gesture starts slightly above the
- * bottom of the component and ends at the top.
+ * Performs a swipe up gesture on the associated node. The gesture starts slightly above the
+ * bottom of the node and ends at the top.
*/
-fun GestureScope.sendSwipeUp() {
+fun GestureScope.swipeUp() {
val x = center.x
val y0 = (size.height * (1 - edgeFuzzFactor)).roundToInt().toFloat()
val y1 = 0.0f
val start = Offset(x, y0)
val end = Offset(x, y1)
- sendSwipe(start, end, 200.milliseconds)
+ swipe(start, end, 200.milliseconds)
}
/**
- * Performs a swipe down gesture on the associated component. The gesture starts slightly below the
- * top of the component and ends at the bottom.
+ * Performs a swipe down gesture on the associated node. The gesture starts slightly below the
+ * top of the node and ends at the bottom.
*/
-fun GestureScope.sendSwipeDown() {
+fun GestureScope.swipeDown() {
val x = center.x
val y0 = (size.height * edgeFuzzFactor).roundToInt().toFloat()
val y1 = size.height.toFloat()
val start = Offset(x, y0)
val end = Offset(x, y1)
- sendSwipe(start, end, 200.milliseconds)
+ swipe(start, end, 200.milliseconds)
}
/**
- * Performs a swipe left gesture on the associated component. The gesture starts slightly left of
- * the right side of the component and ends at the left side.
+ * Performs a swipe left gesture on the associated node. The gesture starts slightly left of
+ * the right side of the node and ends at the left side.
*/
-fun GestureScope.sendSwipeLeft() {
+fun GestureScope.swipeLeft() {
val x0 = (size.width * (1 - edgeFuzzFactor)).toFloat()
val x1 = 0.0f
val y = center.y
val start = Offset(x0, y)
val end = Offset(x1, y)
- sendSwipe(start, end, 200.milliseconds)
+ swipe(start, end, 200.milliseconds)
}
/**
- * Performs a swipe right gesture on the associated component. The gesture starts slightly right of
- * the left side of the component and ends at the right side.
+ * Performs a swipe right gesture on the associated node. The gesture starts slightly right of
+ * the left side of the node and ends at the right side.
*/
-fun GestureScope.sendSwipeRight() {
+fun GestureScope.swipeRight() {
val x0 = (size.width * edgeFuzzFactor).roundToInt().toFloat()
val x1 = size.width.toFloat()
val y = center.y
val start = Offset(x0, y)
val end = Offset(x1, y)
- sendSwipe(start, end, 200.milliseconds)
+ swipe(start, end, 200.milliseconds)
}
/**
@@ -552,16 +552,16 @@
/**
* The receiver scope for injecting partial gestures on the [semanticsNode] identified by the
* corresponding [SemanticsNodeInteraction]. Gestures can be injected by calling methods defined
- * on [PartialGestureScope], such as [sendDown]. The [SemanticsNodeInteraction] can be found by
- * one of the finder methods such as [findByTag].
+ * on [PartialGestureScope], such as [down]. The [SemanticsNodeInteraction] can be found by
+ * one of the finder methods such as [onNodeWithTag].
*
* Example usage:
* ```
* val position = Offset(10.px, 10.px)
- * findByTag("myWidget")
- * .doPartialGesture { sendDown(position) }
+ * onNodeWithTag("myWidget")
+ * .performPartialGesture { sendDown(position) }
* .assertIsDisplayed()
- * .doPartialGesture { sendUp(position) }
+ * .performPartialGesture { sendUp(position) }
* ```
*/
class PartialGestureScope internal constructor(
@@ -570,20 +570,20 @@
/**
* Sends a down event for the pointer with the given [pointerId] at [position] on the associated
- * component. The [position] is in the component's local coordinate system, where (0, 0) is
- * the top left corner of the component.
+ * node. The [position] is in the node's local coordinate system, where (0, 0) is
+ * the top left corner of the node.
*
* If no pointers are down yet, this will start a new partial gesture. If a partial gesture is
* already in progress, this event is sent with at the same timestamp as the last event. If the
* given pointer is already down, an [IllegalArgumentException] will be thrown.
*
* This gesture is considered _partial_, because the entire gesture can be spread over several
- * invocations of [doPartialGesture]. An entire gesture starts with a [down][sendDown] event,
- * followed by several down, move or up events, and ends with an [up][sendUp] or a
- * [cancel][sendCancel] event. Movement can be expressed with [sendMoveTo] and [sendMoveBy] to
+ * invocations of [performPartialGesture]. An entire gesture starts with a [down][down] event,
+ * followed by several down, move or up events, and ends with an [up][up] or a
+ * [cancel][cancel] event. Movement can be expressed with [moveTo] and [moveBy] to
* move a single pointer at a time, or [movePointerTo] and [movePointerBy] to move multiple
* pointers at a time. The `movePointer[To|By]` methods do not send the move event directly, use
- * [sendMove] to send the move event. Some other methods can send a move event as well. All
+ * [move] to send the move event. Some other methods can send a move event as well. All
* events, regardless the method used, will always contain the current position of _all_ pointers.
*
* Down and up events are sent at the same time as the previous event, but will send an extra
@@ -592,7 +592,7 @@
* cancel event will contain the up to date position of all pointers. Move and cancel events will
* advance the event time by 10 milliseconds.
*
- * Because partial gestures don't have to be defined all in the same [doPartialGesture] block,
+ * Because partial gestures don't have to be defined all in the same [performPartialGesture] block,
* keep in mind that while the gesture is not complete, all code you execute in between
* blocks that progress the gesture, will be executed while imaginary fingers are actively
* touching the screen.
@@ -601,66 +601,66 @@
* event, if the test ends before it expects the finger to be lifted from the screen.
*
* @param pointerId The id of the pointer, can be any number not yet in use by another pointer
- * @param position The position of the down event, in the component's local coordinate system
+ * @param position The position of the down event, in the node's local coordinate system
*/
-fun PartialGestureScope.sendDown(pointerId: Int, position: Offset) {
+fun PartialGestureScope.down(pointerId: Int, position: Offset) {
val globalPosition = localToGlobal(position)
inputDispatcher.sendDown(pointerId, globalPosition)
}
/**
- * Sends a down event for the default pointer at [position] on the associated component. The
- * [position] is in the component's local coordinate system, where (0, 0) is the top left
- * corner of the component. The default pointer has `pointerId = 0`.
+ * Sends a down event for the default pointer at [position] on the associated node. The
+ * [position] is in the node's local coordinate system, where (0, 0) is the top left
+ * corner of the node. The default pointer has `pointerId = 0`.
*
* If no pointers are down yet, this will start a new partial gesture. If a partial gesture is
* already in progress, this event is sent with at the same timestamp as the last event. If the
* default pointer is already down, an [IllegalArgumentException] will be thrown.
*
- * @param position The position of the down event, in the component's local coordinate system
+ * @param position The position of the down event, in the node's local coordinate system
*/
-fun PartialGestureScope.sendDown(position: Offset) {
- sendDown(0, position)
+fun PartialGestureScope.down(position: Offset) {
+ down(0, position)
}
/**
- * Sends a move event on the associated component, with the position of the pointer with the
- * given [pointerId] updated to [position]. The [position] is in the component's local coordinate
- * system, where (0, 0) is the top left corner of the component.
+ * Sends a move event on the associated node, with the position of the pointer with the
+ * given [pointerId] updated to [position]. The [position] is in the node's local coordinate
+ * system, where (0, 0) is the top left corner of the node.
*
* If the pointer is not yet down, an [IllegalArgumentException] will be thrown.
*
- * @param pointerId The id of the pointer to move, as supplied in [sendDown]
- * @param position The new position of the pointer, in the component's local coordinate system
+ * @param pointerId The id of the pointer to move, as supplied in [down]
+ * @param position The new position of the pointer, in the node's local coordinate system
*/
-fun PartialGestureScope.sendMoveTo(pointerId: Int, position: Offset) {
+fun PartialGestureScope.moveTo(pointerId: Int, position: Offset) {
movePointerTo(pointerId, position)
- sendMove()
+ move()
}
/**
- * Sends a move event on the associated component, with the position of the default pointer
- * updated to [position]. The [position] is in the component's local coordinate system, where
- * (0, 0) is the top left corner of the component. The default pointer has `pointerId = 0`.
+ * Sends a move event on the associated node, with the position of the default pointer
+ * updated to [position]. The [position] is in the node's local coordinate system, where
+ * (0, 0) is the top left corner of the node. The default pointer has `pointerId = 0`.
*
* If the default pointer is not yet down, an [IllegalArgumentException] will be thrown.
*
- * @param position The new position of the pointer, in the component's local coordinate system
+ * @param position The new position of the pointer, in the node's local coordinate system
*/
-fun PartialGestureScope.sendMoveTo(position: Offset) {
- sendMoveTo(0, position)
+fun PartialGestureScope.moveTo(position: Offset) {
+ moveTo(0, position)
}
/**
* Updates the position of the pointer with the given [pointerId] to the given [position], but
- * does not send a move event. The move event can be sent with [sendMove]. The [position] is in
- * the component's local coordinate system, where (0.px, 0.px) is the top left corner of the
- * component.
+ * does not send a move event. The move event can be sent with [move]. The [position] is in
+ * the node's local coordinate system, where (0.px, 0.px) is the top left corner of the
+ * node.
*
* If the pointer is not yet down, an [IllegalArgumentException] will be thrown.
*
- * @param pointerId The id of the pointer to move, as supplied in [sendDown]
- * @param position The new position of the pointer, in the component's local coordinate system
+ * @param pointerId The id of the pointer to move, as supplied in [down]
+ * @param position The new position of the pointer, in the node's local coordinate system
*/
fun PartialGestureScope.movePointerTo(pointerId: Int, position: Offset) {
val globalPosition = localToGlobal(position)
@@ -668,23 +668,23 @@
}
/**
- * Sends a move event on the associated component, with the position of the pointer with the
+ * Sends a move event on the associated node, with the position of the pointer with the
* given [pointerId] moved by the given [delta].
*
* If the pointer is not yet down, an [IllegalArgumentException] will be thrown.
*
- * @param pointerId The id of the pointer to move, as supplied in [sendDown]
+ * @param pointerId The id of the pointer to move, as supplied in [down]
* @param delta The position for this move event, relative to the last sent position of the
* pointer. For example, `delta = Offset(10.px, -10.px) will add 10.px to the pointer's last
* x-position, and subtract 10.px from the pointer's last y-position.
*/
-fun PartialGestureScope.sendMoveBy(pointerId: Int, delta: Offset) {
+fun PartialGestureScope.moveBy(pointerId: Int, delta: Offset) {
movePointerBy(pointerId, delta)
- sendMove()
+ move()
}
/**
- * Sends a move event on the associated component, with the position of the default pointer
+ * Sends a move event on the associated node, with the position of the default pointer
* moved by the given [delta]. The default pointer has `pointerId = 0`.
*
* If the pointer is not yet down, an [IllegalArgumentException] will be thrown.
@@ -693,17 +693,17 @@
* pointer. For example, `delta = Offset(10.px, -10.px) will add 10.px to the pointer's last
* x-position, and subtract 10.px from the pointer's last y-position.
*/
-fun PartialGestureScope.sendMoveBy(delta: Offset) {
- sendMoveBy(0, delta)
+fun PartialGestureScope.moveBy(delta: Offset) {
+ moveBy(0, delta)
}
/**
* Moves the position of the pointer with the given [pointerId] by the given [delta], but does
- * not send a move event. The move event can be sent with [sendMove].
+ * not send a move event. The move event can be sent with [move].
*
* If the pointer is not yet down, an [IllegalArgumentException] will be thrown.
*
- * @param pointerId The id of the pointer to move, as supplied in [sendDown]
+ * @param pointerId The id of the pointer to move, as supplied in [down]
* @param delta The position for this move event, relative to the last sent position of the
* pointer. For example, `delta = Offset(10.px, -10.px) will add 10.px to the pointer's last
* x-position, and subtract 10.px from the pointer's last y-position.
@@ -720,26 +720,313 @@
* batching movement of multiple pointers together, which can be done with [movePointerTo] and
* [movePointerBy].
*/
-fun PartialGestureScope.sendMove() {
+fun PartialGestureScope.move() {
inputDispatcher.sendMove()
}
/**
* Sends an up event for the pointer with the given [pointerId], or the default pointer if
+ * [pointerId] is omitted, on the associated node. If any pointers have been moved with
+ * [movePointerTo] or [movePointerBy] and no move event has been sent yet, a move event will be
+ * sent right before the up event.
+ *
+ * @param pointerId The id of the pointer to lift up, as supplied in [down]
+ */
+fun PartialGestureScope.up(pointerId: Int = 0) {
+ inputDispatcher.sendUp(pointerId)
+}
+
+/**
+ * Sends a cancel event to cancel the current partial gesture. The cancel event contains the
+ * current position of all active pointers.
+ */
+fun PartialGestureScope.cancel() {
+ inputDispatcher.sendCancel()
+}
+
+// DEPRECATED APIs SECTION
+
+/**
+ * Performs a click gesture at the given [position] on the associated component, or in the center
+ * if the [position] is omitted. The [position] is in the component's local coordinate system,
+ * where (0, 0) is the top left corner of the component. The default [position] is the
+ * center of the component.
+ *
+ * @param position The position where to click, in the component's local coordinate system. If
+ * omitted, the center position will be used.
+ */
+@Deprecated("Renamed to click",
+ replaceWith = ReplaceWith("click(position)"))
+fun GestureScope.sendClick(position: Offset = center) = click(position)
+
+/**
+ * Performs a long click gesture at the given [position] on the associated component, or in the
+ * center if the [position] is omitted. By default, the [duration] of the press is
+ * [LongPressTimeout] + 100 milliseconds. The [position] is in the component's local coordinate
+ * system, where (0, 0) is the top left corner of the component.
+ *
+ * @param position The position of the long click, in the component's local coordinate system. If
+ * omitted, the center position will be used.
+ * @param duration The time between the down and the up event
+ */
+@Deprecated("Renamed to longClick",
+ replaceWith = ReplaceWith("longClick(position, duration)"))
+fun GestureScope.sendLongClick(
+ position: Offset = center,
+ duration: Duration = LongPressTimeout + 100.milliseconds
+) = longClick(position, duration)
+
+/**
+ * Performs a double click gesture at the given [position] on the associated component, or in the
+ * center if the [position] is omitted. By default, the [delay] between the first and the second
+ * click is 145 milliseconds (empirically established). The [position] is in the component's
+ * local coordinate system, where (0, 0) is the top left corner of the component.
+ *
+ * @param position The position of the double click, in the component's local coordinate system.
+ * If omitted, the center position will be used.
+ * @param delay The time between the up event of the first click and the down event of the second
+ * click
+ */
+@Deprecated("Renamed to doubleClick",
+ replaceWith = ReplaceWith("doubleClick(position, delay)"))
+fun GestureScope.sendDoubleClick(
+ position: Offset = center,
+ delay: Duration = doubleClickDelay
+) = doubleClick(position, delay)
+
+/**
+ * Performs the swipe gesture on the associated component. The motion events are linearly
+ * interpolated between [start] and [end]. The coordinates are in the component's local
+ * coordinate system, where (0, 0) is the top left corner of the component. The default
+ * duration is 200 milliseconds.
+ *
+ * @param start The start position of the gesture, in the component's local coordinate system
+ * @param end The end position of the gesture, in the component's local coordinate system
+ * @param duration The duration of the gesture
+ */
+@Deprecated("Renamed to swipe",
+ replaceWith = ReplaceWith("swipe(start, end, duration)"))
+fun GestureScope.sendSwipe(
+ start: Offset,
+ end: Offset,
+ duration: Duration = 200.milliseconds
+) = swipe(start, end, duration)
+
+/**
+ * Performs a pinch gesture on the associated component.
+ *
+ * For each pair of start and end [Offset]s, the motion events are linearly interpolated. The
+ * coordinates are in the component's local coordinate system where (0, 0) is the top left
+ * corner of the component. The default duration is 400 milliseconds.
+ *
+ * @param start0 The start position of the first gesture in the component's local coordinate system
+ * @param end0 The end position of the first gesture in the component's local coordinate system
+ * @param start1 The start position of the second gesture in the component's local coordinate system
+ * @param end1 The end position of the second gesture in the component's local coordinate system
+ * @param duration the duration of the gesture
+ */
+@Deprecated("Renamed to pinch",
+ replaceWith = ReplaceWith("pinch(start0, end0, start1, end0, duration)"))
+fun GestureScope.sendPinch(
+ start0: Offset,
+ end0: Offset,
+ start1: Offset,
+ end1: Offset,
+ duration: Duration = 400.milliseconds
+) = pinch(start0, end0, start1, end1, duration)
+
+/**
+ * Performs the swipe gesture on the associated component, such that the velocity when the
+ * gesture is finished is roughly equal to [endVelocity]. The MotionEvents are linearly
+ * interpolated between [start] and [end]. The coordinates are in the component's
+ * local coordinate system, where (0, 0) is the top left corner of the component. The
+ * default duration is 200 milliseconds.
+ *
+ * Note that due to imprecisions, no guarantees can be made on the precision of the actual
+ * velocity at the end of the gesture, but generally it is within 0.1% of the desired velocity.
+ *
+ * @param start The start position of the gesture, in the component's local coordinate system
+ * @param end The end position of the gesture, in the component's local coordinate system
+ * @param endVelocity The velocity of the gesture at the moment it ends. Must be positive.
+ * @param duration The duration of the gesture. Must be long enough that at least 3 input events
+ * are generated, which happens with a duration of 25ms or more.
+ */
+@Deprecated("Renamed to swipeWithVelocity",
+ replaceWith = ReplaceWith("swipeWithVelocity(start, end, endVelocity, duration)"))
+fun GestureScope.sendSwipeWithVelocity(
+ start: Offset,
+ end: Offset,
+ @FloatRange(from = 0.0) endVelocity: Float,
+ duration: Duration = 200.milliseconds
+) = swipeWithVelocity(start, end, endVelocity, duration)
+
+/**
+ * Performs a swipe up gesture on the associated component. The gesture starts slightly above the
+ * bottom of the component and ends at the top.
+ */
+@Deprecated("Renamed to swipeUp",
+ replaceWith = ReplaceWith("swipeUp()"))
+fun GestureScope.sendSwipeUp() = swipeUp()
+
+/**
+ * Performs a swipe down gesture on the associated component. The gesture starts slightly below the
+ * top of the component and ends at the bottom.
+ */
+@Deprecated("Renamed to swipeDown",
+ replaceWith = ReplaceWith("swipeDown()"))
+fun GestureScope.sendSwipeDown() = swipeDown()
+
+/**
+ * Performs a swipe left gesture on the associated component. The gesture starts slightly left of
+ * the right side of the component and ends at the left side.
+ */
+@Deprecated("Renamed to swipeLeft",
+ replaceWith = ReplaceWith("swipeLeft()"))
+fun GestureScope.sendSwipeLeft() = swipeLeft()
+
+/**
+ * Performs a swipe right gesture on the associated component. The gesture starts slightly right of
+ * the left side of the component and ends at the right side.
+ */
+@Deprecated("Renamed to swipeRight",
+ replaceWith = ReplaceWith("swipeRight()"))
+fun GestureScope.sendSwipeRight() = swipeRight()
+
+/**
+ * Sends a down event for the pointer with the given [pointerId] at [position] on the associated
+ * component. The [position] is in the component's local coordinate system, where (0, 0) is
+ * the top left corner of the component.
+ *
+ * If no pointers are down yet, this will start a new partial gesture. If a partial gesture is
+ * already in progress, this event is sent with at the same timestamp as the last event. If the
+ * given pointer is already down, an [IllegalArgumentException] will be thrown.
+ *
+ * This gesture is considered _partial_, because the entire gesture can be spread over several
+ * invocations of [performPartialGesture]. An entire gesture starts with a [down][sendDown] event,
+ * followed by several down, move or up events, and ends with an [up][sendUp] or a
+ * [cancel][sendCancel] event. Movement can be expressed with [sendMoveTo] and [sendMoveBy] to
+ * move a single pointer at a time, or [movePointerTo] and [movePointerBy] to move multiple
+ * pointers at a time. The `movePointer[To|By]` methods do not send the move event directly, use
+ * [sendMove] to send the move event. Some other methods can send a move event as well. All
+ * events, regardless the method used, will always contain the current position of _all_ pointers.
+ *
+ * Down and up events are sent at the same time as the previous event, but will send an extra
+ * move event just before the down or up event if [movePointerTo] or [movePointerBy] has been
+ * called and no move event has been sent yet. This does not happen for cancel events, but the
+ * cancel event will contain the up to date position of all pointers. Move and cancel events will
+ * advance the event time by 10 milliseconds.
+ *
+ * Because partial gestures don't have to be defined all in the same [performPartialGesture] block,
+ * keep in mind that while the gesture is not complete, all code you execute in between
+ * blocks that progress the gesture, will be executed while imaginary fingers are actively
+ * touching the screen.
+ *
+ * In the context of testing, it is not necessary to complete a gesture with an up or cancel
+ * event, if the test ends before it expects the finger to be lifted from the screen.
+ *
+ * @param pointerId The id of the pointer, can be any number not yet in use by another pointer
+ * @param position The position of the down event, in the component's local coordinate system
+ */
+@Deprecated("Renamed to down",
+ replaceWith = ReplaceWith("down(pointerId, position)"))
+fun PartialGestureScope.sendDown(pointerId: Int, position: Offset) = down(pointerId, position)
+
+/**
+ * Sends a down event for the default pointer at [position] on the associated component. The
+ * [position] is in the component's local coordinate system, where (0, 0) is the top left
+ * corner of the component. The default pointer has `pointerId = 0`.
+ *
+ * If no pointers are down yet, this will start a new partial gesture. If a partial gesture is
+ * already in progress, this event is sent with at the same timestamp as the last event. If the
+ * default pointer is already down, an [IllegalArgumentException] will be thrown.
+ *
+ * @param position The position of the down event, in the component's local coordinate system
+ */
+@Deprecated("Renamed to down",
+ replaceWith = ReplaceWith("down(position)"))
+fun PartialGestureScope.sendDown(position: Offset) = down(position)
+
+/**
+ * Sends a move event on the associated component, with the position of the pointer with the
+ * given [pointerId] updated to [position]. The [position] is in the component's local coordinate
+ * system, where (0, 0) is the top left corner of the component.
+ *
+ * If the pointer is not yet down, an [IllegalArgumentException] will be thrown.
+ *
+ * @param pointerId The id of the pointer to move, as supplied in [sendDown]
+ * @param position The new position of the pointer, in the component's local coordinate system
+ */
+@Deprecated("Renamed to moveTo",
+ replaceWith = ReplaceWith("moveTo(pointerId, position)"))
+fun PartialGestureScope.sendMoveTo(pointerId: Int, position: Offset) = moveTo(pointerId, position)
+
+/**
+ * Sends a move event on the associated component, with the position of the default pointer
+ * updated to [position]. The [position] is in the component's local coordinate system, where
+ * (0, 0) is the top left corner of the component. The default pointer has `pointerId = 0`.
+ *
+ * If the default pointer is not yet down, an [IllegalArgumentException] will be thrown.
+ *
+ * @param position The new position of the pointer, in the component's local coordinate system
+ */
+@Deprecated("Renamed to moveTo",
+ replaceWith = ReplaceWith("moveTo(position)"))
+fun PartialGestureScope.sendMoveTo(position: Offset) = moveTo(position)
+
+/**
+ * Sends a move event on the associated component, with the position of the pointer with the
+ * given [pointerId] moved by the given [delta].
+ *
+ * If the pointer is not yet down, an [IllegalArgumentException] will be thrown.
+ *
+ * @param pointerId The id of the pointer to move, as supplied in [sendDown]
+ * @param delta The position for this move event, relative to the last sent position of the
+ * pointer. For example, `delta = Offset(10.px, -10.px) will add 10.px to the pointer's last
+ * x-position, and subtract 10.px from the pointer's last y-position.
+ */
+@Deprecated("Renamed to moveBy",
+ replaceWith = ReplaceWith("moveBy(pointerId, delta)"))
+fun PartialGestureScope.sendMoveBy(pointerId: Int, delta: Offset) = moveBy(pointerId, delta)
+
+/**
+ * Sends a move event on the associated component, with the position of the default pointer
+ * moved by the given [delta]. The default pointer has `pointerId = 0`.
+ *
+ * If the pointer is not yet down, an [IllegalArgumentException] will be thrown.
+ *
+ * @param delta The position for this move event, relative to the last sent position of the
+ * pointer. For example, `delta = Offset(10.px, -10.px) will add 10.px to the pointer's last
+ * x-position, and subtract 10.px from the pointer's last y-position.
+ */
+@Deprecated("Renamed to moveBy",
+ replaceWith = ReplaceWith("moveBy(delta)"))
+fun PartialGestureScope.sendMoveBy(delta: Offset) = moveBy(delta)
+
+/**
+ * Sends a move event without updating any of the pointer positions. This can be useful when
+ * batching movement of multiple pointers together, which can be done with [movePointerTo] and
+ * [movePointerBy].
+ */
+@Deprecated("Renamed to move",
+ replaceWith = ReplaceWith("move()"))
+fun PartialGestureScope.sendMove() = move()
+
+/**
+ * Sends an up event for the pointer with the given [pointerId], or the default pointer if
* [pointerId] is omitted, on the associated component. If any pointers have been moved with
* [movePointerTo] or [movePointerBy] and no move event has been sent yet, a move event will be
* sent right before the up event.
*
* @param pointerId The id of the pointer to lift up, as supplied in [sendDown]
*/
-fun PartialGestureScope.sendUp(pointerId: Int = 0) {
- inputDispatcher.sendUp(pointerId)
-}
+@Deprecated("Renamed to up",
+ replaceWith = ReplaceWith("up(pointerId)"))
+fun PartialGestureScope.sendUp(pointerId: Int = 0) = up(pointerId)
/**
* Sends a cancel event to cancel the current partial gesture. The cancel event contains the
* current position of all active pointers.
*/
-fun PartialGestureScope.sendCancel() {
- inputDispatcher.sendCancel()
-}
+@Deprecated("Renamed to cancel",
+ replaceWith = ReplaceWith("cancel()"))
+fun PartialGestureScope.sendCancel() = cancel()
\ No newline at end of file
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/InputDispatcher.kt b/ui/ui-test/src/main/java/androidx/ui/test/InputDispatcher.kt
index e66e165..b19a2e4 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/InputDispatcher.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/InputDispatcher.kt
@@ -133,7 +133,7 @@
* Generates the downTime of the next gesture with the given [duration]. The gesture's
* [duration] is necessary to facilitate chaining of gestures: if another gesture is made
* after the next one, it will start exactly [duration] after the start of the next gesture.
- * Always use this method to determine the downTime of the [down event][sendDown] of a gesture.
+ * Always use this method to determine the downTime of the [down event][down] of a gesture.
*
* If the duration is unknown when calling this method, use a duration of zero and update
* with [moveNextDownTime] when the duration is known, or use [moveNextDownTime]
@@ -174,8 +174,8 @@
* same [InputDispatcher] instance as the one used to end the last gesture.
*
* Note: this does not affect the time of the next event for the _current_ partial gesture,
- * using [sendMove], [sendUp] and [sendCancel], but it will affect the time of the _next_
- * gesture (including partial gestures started with [sendDown]).
+ * using [move], [up] and [cancel], but it will affect the time of the _next_
+ * gesture (including partial gestures started with [down]).
*
* @param duration The duration of the delay. Must be positive
*/
@@ -353,18 +353,18 @@
* for that pointer. Pointer ids may be reused during the same gesture. This method blocks
* until the input event has been dispatched.
*
- * It is possible to mix partial gestures with full gestures (e.g. send a [click][sendClick]
+ * It is possible to mix partial gestures with full gestures (e.g. send a [click][click]
* during a partial gesture), as long as you make sure that the default pointer id (id=0) is
* free to be used by the full gesture.
*
* A full gesture starts with a down event at some position (with this method) that indicates
- * a finger has started touching the screen, followed by zero or more [down][sendDown],
- * [move][sendMove] and [up][sendUp] events that respectively indicate that another finger
+ * a finger has started touching the screen, followed by zero or more [down][down],
+ * [move][move] and [up][up] events that respectively indicate that another finger
* started touching the screen, a finger moved around or a finger was lifted up from the
- * screen. A gesture is finished when [up][sendUp] lifts the last remaining finger from the
- * screen, or when a single [cancel][sendCancel] event is sent.
+ * screen. A gesture is finished when [up][up] lifts the last remaining finger from the
+ * screen, or when a single [cancel][cancel] event is sent.
*
- * Partial gestures don't have to be defined all in the same [doPartialGesture] block, but
+ * Partial gestures don't have to be defined all in the same [performPartialGesture] block, but
* keep in mind that while the gesture is not complete, all code you execute in between
* blocks that progress the gesture, will be executed while imaginary fingers are actively
* touching the screen.
@@ -376,9 +376,9 @@
* @param position The coordinate of the down event
*
* @see movePointer
- * @see sendMove
- * @see sendUp
- * @see sendCancel
+ * @see move
+ * @see up
+ * @see cancel
*/
fun sendDown(pointerId: Int, position: Offset) {
var gesture = partialGesture
@@ -406,18 +406,18 @@
* Updates the position of the pointer with the given [pointerId] to the given [position],
* but does not send a move event. Use this to move multiple pointers simultaneously. To send
* the next move event, which will contain the current position of _all_ pointers (not just
- * the moved ones), call [sendMove] without arguments. If you move one or more pointers and
- * then call [sendDown] or [sendUp], without calling [sendMove] first, a move event will be
- * sent right before that down or up event. See [sendDown] for more information on how to make
+ * the moved ones), call [move] without arguments. If you move one or more pointers and
+ * then call [down] or [up], without calling [move] first, a move event will be
+ * sent right before that down or up event. See [down] for more information on how to make
* complete gestures from partial gestures.
*
- * @param pointerId The id of the pointer to move, as supplied in [sendDown]
+ * @param pointerId The id of the pointer to move, as supplied in [down]
* @param position The position to move the pointer to
*
- * @see sendDown
- * @see sendMove
- * @see sendUp
- * @see sendCancel
+ * @see down
+ * @see move
+ * @see up
+ * @see cancel
*/
fun movePointer(pointerId: Int, position: Offset) {
val gesture = partialGesture
@@ -438,7 +438,7 @@
* Sends a move event [delay] milliseconds after the previous injected event of this gesture,
* without moving any of the pointers. The default [delay] is [10][eventPeriod] milliseconds.
* Use this to commit all changes in pointer location made with [movePointer]. The sent event
- * will contain the current position of all pointers. See [sendDown] for more information on
+ * will contain the current position of all pointers. See [down] for more information on
* how to make complete gestures from partial gestures.
*
* @param delay The time in milliseconds between the previously injected event and the move
@@ -461,16 +461,16 @@
* Sends an up event for the given [pointerId] at the current position of that pointer,
* [delay] milliseconds after the previous injected event of this gesture. The default
* [delay] is 0 milliseconds. This method blocks until the input event has been dispatched.
- * See [sendDown] for more information on how to make complete gestures from partial gestures.
+ * See [down] for more information on how to make complete gestures from partial gestures.
*
- * @param pointerId The id of the pointer to lift up, as supplied in [sendDown]
+ * @param pointerId The id of the pointer to lift up, as supplied in [down]
* @param delay The time in milliseconds between the previously injected event and the move
* event. 0 milliseconds by default.
*
- * @see sendDown
+ * @see down
* @see movePointer
- * @see sendMove
- * @see sendCancel
+ * @see move
+ * @see cancel
*/
fun sendUp(pointerId: Int, delay: Long = 0) {
val gesture = partialGesture
@@ -502,16 +502,16 @@
/**
* Sends a cancel event [delay] milliseconds after the previous injected event of this
* gesture. The default [delay] is [10][eventPeriod] milliseconds. This method blocks until
- * the input event has been dispatched. See [sendDown] for more information on how to make
+ * the input event has been dispatched. See [down] for more information on how to make
* complete gestures from partial gestures.
*
* @param delay The time in milliseconds between the previously injected event and the cancel
* event. [10][eventPeriod] milliseconds by default.
*
- * @see sendDown
+ * @see down
* @see movePointer
- * @see sendMove
- * @see sendUp
+ * @see move
+ * @see up
*/
fun sendCancel(delay: Long = eventPeriod) {
val gesture = checkNotNull(partialGesture) {
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/KeyInputHelpers.kt b/ui/ui-test/src/main/java/androidx/ui/test/KeyInputHelpers.kt
index 44e0e61..c8b1401 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/KeyInputHelpers.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/KeyInputHelpers.kt
@@ -26,7 +26,7 @@
* @return true if the event was consumed. False otherwise.
*/
@OptIn(ExperimentalKeyInput::class)
-fun SemanticsNodeInteraction.doSendKeyEvent(keyEvent: KeyEvent2): Boolean {
+fun SemanticsNodeInteraction.performKeyPress(keyEvent: KeyEvent2): Boolean {
val semanticsNode = fetchSemanticsNode("Failed to send key Event (${keyEvent.key})")
@OptIn(ExperimentalLayoutNodeApi::class)
val owner = semanticsNode.componentNode.owner
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/Selectors.kt b/ui/ui-test/src/main/java/androidx/ui/test/Selectors.kt
index 8df024c..146fbd4 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/Selectors.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/Selectors.kt
@@ -31,7 +31,7 @@
* [SemanticsNodeInteraction.assertDoesNotExist] is used) and will throw [AssertionError] if
* none or more than one element is found.
*/
-fun SemanticsNodeInteraction.parent(): SemanticsNodeInteraction {
+fun SemanticsNodeInteraction.onParent(): SemanticsNodeInteraction {
return SemanticsNodeInteraction(
useUnmergedTree,
selector.addSelectionFromSingleNode("parent") { listOfNotNull(it.parent) }
@@ -41,7 +41,7 @@
/**
* Returns children of this node.
*/
-fun SemanticsNodeInteraction.children(): SemanticsNodeInteractionCollection {
+fun SemanticsNodeInteraction.onChildren(): SemanticsNodeInteractionCollection {
return SemanticsNodeInteractionCollection(
useUnmergedTree,
selector.addSelectionFromSingleNode("children") { it.children }
@@ -57,7 +57,7 @@
* [SemanticsNodeInteraction.assertDoesNotExist] is used) and will throw [AssertionError] if
* none or more than one element is found.
*/
-fun SemanticsNodeInteraction.child(): SemanticsNodeInteraction {
+fun SemanticsNodeInteraction.onChild(): SemanticsNodeInteraction {
return SemanticsNodeInteraction(
useUnmergedTree,
selector.addSelectionFromSingleNode("child") { it.children }
@@ -69,7 +69,7 @@
*
* This is just a shortcut for "children[index]".
*/
-fun SemanticsNodeInteraction.childAt(index: Int): SemanticsNodeInteraction = children()[index]
+fun SemanticsNodeInteraction.onChildAt(index: Int): SemanticsNodeInteraction = onChildren()[index]
/**
* Returns all siblings of this node.
@@ -83,7 +83,7 @@
* Returns B1, B3
* ```
*/
-fun SemanticsNodeInteraction.siblings(): SemanticsNodeInteractionCollection {
+fun SemanticsNodeInteraction.onSiblings(): SemanticsNodeInteractionCollection {
return SemanticsNodeInteractionCollection(
useUnmergedTree,
selector.addSelectionFromSingleNode("siblings") { it.siblings }
@@ -99,7 +99,7 @@
* [SemanticsNodeInteraction.assertDoesNotExist] is used) and will throw [AssertionError] if
* none or more than one element is found.
*/
-fun SemanticsNodeInteraction.sibling(): SemanticsNodeInteraction {
+fun SemanticsNodeInteraction.onSibling(): SemanticsNodeInteraction {
return SemanticsNodeInteraction(
useUnmergedTree,
selector.addSelectionFromSingleNode("sibling") { it.siblings }
@@ -117,7 +117,7 @@
* Returns B, A
* ```
*/
-fun SemanticsNodeInteraction.ancestors(): SemanticsNodeInteractionCollection {
+fun SemanticsNodeInteraction.onAncestors(): SemanticsNodeInteractionCollection {
return SemanticsNodeInteractionCollection(
useUnmergedTree,
selector.addSelectionFromSingleNode("ancestors") { it.ancestors.toList() }
@@ -131,7 +131,7 @@
* [SemanticsNodeInteraction.assertDoesNotExist] is used) and will throw [AssertionError] if
* no element is found.
*/
-fun SemanticsNodeInteractionCollection.first(): SemanticsNodeInteraction {
+fun SemanticsNodeInteractionCollection.onFirst(): SemanticsNodeInteraction {
return get(0)
}
@@ -142,7 +142,7 @@
* [SemanticsNodeInteraction.assertDoesNotExist] is used) and will throw [AssertionError] if
* no element is found.
*/
-fun SemanticsNodeInteractionCollection.last(): SemanticsNodeInteraction {
+fun SemanticsNodeInteractionCollection.onLast(): SemanticsNodeInteraction {
return SemanticsNodeInteraction(useUnmergedTree, selector.addLastNodeSelector())
}
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/SemanticsNodeInteraction.kt b/ui/ui-test/src/main/java/androidx/ui/test/SemanticsNodeInteraction.kt
index b795657..b5e5289 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/SemanticsNodeInteraction.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/SemanticsNodeInteraction.kt
@@ -21,15 +21,15 @@
/**
* Represents a semantics node and the path to fetch it from the semantics tree. One can interact
- * with this node by performing actions such as [doClick], assertions such as
- * [assertHasClickAction], or navigate to other nodes such as [children].
+ * with this node by performing actions such as [performClick], assertions such as
+ * [assertHasClickAction], or navigate to other nodes such as [onChildren].
*
- * This is usually obtained from methods like [findByTag], [find].
+ * This is usually obtained from methods like [onNodeWithTag], [onNode].
*
* Example usage:
* ```
- * findByTag("myCheckbox")
- * .doClick()
+ * onNodeWithTag("myCheckbox")
+ * .performClick()
* .assertIsOn()
* ````
*
@@ -47,7 +47,7 @@
* // Assert that MyIcon is at the expected position inside the IconButton.
* // Without useUnmergedTree, then the test would check the position of the IconButton (0, 0)
* // instead of the position of the Icon (30, 30).
- * findByTag("icon", useUnmergedTree = true)
+ * onNodeWithTag("icon", useUnmergedTree = true)
* .assertLeftPosition(30.dp)
* .assertTopPosition(30.dp)
* ````
@@ -165,11 +165,11 @@
* One can interact with these nodes by performing assertions such as [assertCountEquals], or
* navigate to other nodes such as [get].
*
- * This is usually obtained from methods like [findAll] or chains of [find].[children].
+ * This is usually obtained from methods like [onAllNodes] or chains of [onNode].[onChildren].
*
* Example usage:
* ```
- * findAll(isClickable())
+ * onAllNodes(isClickable())
* .assertCountEquals(2)
* ````
*/
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/TextActions.kt b/ui/ui-test/src/main/java/androidx/ui/test/TextActions.kt
index ec3b9ab..f9c4c3b 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/TextActions.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/TextActions.kt
@@ -32,9 +32,9 @@
* @param alreadyHasFocus Whether the node already has a focus and thus does not need to be
* clicked on.
*/
-fun SemanticsNodeInteraction.doClearText(alreadyHasFocus: Boolean = false) {
+fun SemanticsNodeInteraction.performTextClearance(alreadyHasFocus: Boolean = false) {
if (!alreadyHasFocus) {
- doClick()
+ performClick()
}
// TODO: There should be some assertion on focus in the future.
@@ -48,9 +48,9 @@
* @param alreadyHasFocus Whether the node already has a focus and thus does not need to be
* clicked on.
*/
-fun SemanticsNodeInteraction.doSendText(text: String, alreadyHasFocus: Boolean = false) {
+fun SemanticsNodeInteraction.performTextInput(text: String, alreadyHasFocus: Boolean = false) {
if (!alreadyHasFocus) {
- doClick()
+ performClick()
}
// TODO: There should be some assertion on focus in the future.
@@ -66,9 +66,12 @@
* @param alreadyHasFocus Whether the node already has a focus and thus does not need to be
* clicked on.
*/
-fun SemanticsNodeInteraction.doReplaceText(text: String, alreadyHasFocus: Boolean = false) {
+fun SemanticsNodeInteraction.performTextReplacement(
+ text: String,
+ alreadyHasFocus: Boolean = false
+) {
if (!alreadyHasFocus) {
- doClick()
+ performClick()
}
// TODO: There should be some assertion on focus in the future.
@@ -88,12 +91,12 @@
* @throws IllegalStateException if tne node did not establish input connection (e.g. is not
* focused)
*/
-fun SemanticsNodeInteraction.doSendImeAction(alreadyHasFocus: Boolean = false) {
+fun SemanticsNodeInteraction.performImeAction(alreadyHasFocus: Boolean = false) {
if (!alreadyHasFocus) {
- doClick()
+ performClick()
}
- val errorOnFail = "Failed to send IME action."
+ val errorOnFail = "Failed to perform IME action."
val node = fetchSemanticsNode(errorOnFail)
assert(hasInputMethodsSupport()) { errorOnFail }
@@ -103,7 +106,7 @@
}
if (actionSpecified == ImeAction.Unspecified) {
throw AssertionError(buildGeneralErrorMessage(
- "Failed to send IME action as current node does not specify any.", selector, node))
+ "Failed to perform IME action as current node does not specify any.", selector, node))
}
@OptIn(ExperimentalLayoutNodeApi::class)
@@ -120,7 +123,7 @@
}
internal fun SemanticsNodeInteraction.sendTextInputCommand(command: List<EditOperation>) {
- val errorOnFail = "Failed to send text input."
+ val errorOnFail = "Failed to perform text input."
val node = fetchSemanticsNode(errorOnFail)
@OptIn(ExperimentalLayoutNodeApi::class)
val owner = node.componentNode.owner as AndroidOwner
@@ -141,4 +144,62 @@
return this.textInputService as TextInputServiceForTests?
?: throw IllegalStateException ("Text input service wrapper not set up! Did you use " +
"ComposeTestRule?")
-}
\ No newline at end of file
+}
+
+// DEPRECATED APIs SECTION
+
+/**
+ * Clears the text in this node in similar way to IME.
+ *
+ * Note performing this operation requires to get a focus.
+ *
+ * @param alreadyHasFocus Whether the node already has a focus and thus does not need to be
+ * clicked on.
+ */
+@Deprecated("Renamed to performTextClearance",
+ replaceWith = ReplaceWith("performTextClearance(alreadyHasFocus)"))
+fun SemanticsNodeInteraction.doClearText(alreadyHasFocus: Boolean = false) =
+ performTextClearance(alreadyHasFocus)
+
+/**
+ * Sends the given text to this node in similar way to IME.
+ *
+ * @param text Text to send.
+ * @param alreadyHasFocus Whether the node already has a focus and thus does not need to be
+ * clicked on.
+ */
+@Deprecated("Renamed to performTextInput",
+ replaceWith = ReplaceWith("performTextInput(text, alreadyHasFocus)"))
+fun SemanticsNodeInteraction.doSendText(text: String, alreadyHasFocus: Boolean = false) =
+ performTextInput(text, alreadyHasFocus)
+
+/**
+ * Replaces existing text with the given text in this node in similar way to IME.
+ *
+ * This does not reflect text selection. All the text gets cleared out and new inserted.
+ *
+ * @param text Text to send.
+ * @param alreadyHasFocus Whether the node already has a focus and thus does not need to be
+ * clicked on.
+ */
+@Deprecated("Renamed to performTextReplacement",
+ replaceWith = ReplaceWith("performTextReplacement(text, alreadyHasFocus)"))
+fun SemanticsNodeInteraction.doReplaceText(text: String, alreadyHasFocus: Boolean = false) =
+ performTextReplacement(text, alreadyHasFocus)
+
+/**
+ * Sends to this node the IME action associated with it in similar way to IME.
+ *
+ * The node needs to define its IME action in semantics.
+ *
+ * @param alreadyHasFocus Whether the node already has a focus and thus does not need to be
+ * clicked on.
+ *
+ * @throws AssertionError if the node does not support input or does not define IME action.
+ * @throws IllegalStateException if tne node did not establish input connection (e.g. is not
+ * focused)
+ */
+@Deprecated("Renamed to performImeAction",
+ replaceWith = ReplaceWith("performImeAction(alreadyHasFocus)"))
+fun SemanticsNodeInteraction.doSendImeAction(alreadyHasFocus: Boolean = false) =
+ performImeAction(alreadyHasFocus)
diff --git a/ui/ui-text-android/build.gradle b/ui/ui-text-android/build.gradle
index 04322de..9d80ebf 100644
--- a/ui/ui-text-android/build.gradle
+++ b/ui/ui-text-android/build.gradle
@@ -37,7 +37,7 @@
testImplementation(JUNIT)
androidTestImplementation "androidx.core:core:1.5.0-alpha01"
- androidTestImplementation project(":ui:ui-test-font")
+ androidTestImplementation project(":compose:core:core-test-font")
androidTestImplementation(ANDROIDX_TEST_RULES)
androidTestImplementation(ANDROIDX_TEST_RUNNER)
androidTestImplementation(DEXMAKER_MOCKITO, libs.exclude_bytebuddy) // DexMaker has it"s own MockMaker
diff --git a/ui/ui-text-android/src/androidTest/java/androidx/ui/text/platform/LayoutGetHorizontalTest.kt b/ui/ui-text-android/src/androidTest/java/androidx/ui/text/platform/LayoutGetHorizontalTest.kt
index 84e91c9..9cd938f 100644
--- a/ui/ui-text-android/src/androidTest/java/androidx/ui/text/platform/LayoutGetHorizontalTest.kt
+++ b/ui/ui-text-android/src/androidTest/java/androidx/ui/text/platform/LayoutGetHorizontalTest.kt
@@ -115,9 +115,13 @@
dir = LTR)
val offset = 5 // before L6
+ // If insert LX to first line, it will be |L1 L2 L3 L4 L5 LX|
assertThat(layout.getUpstreamPrimaryHorizontalPosition(offset)).isEqualTo(50)
+ // If insert RX to first line, it will be |L1 L2 L3 L4 L5 RX|
assertThat(layout.getUpstreamSecondaryHorizontalPosition(offset)).isEqualTo(50)
+ // If insert LX to second line, it will be |LX L6 L7 L8 L9 LA|
assertThat(layout.getDownstreamPrimaryHorizontalPosition(offset)).isEqualTo(0)
+ // If insert RX to second line, it will be |RX L6 L7 L8 L9 LA|
assertThat(layout.getDownstreamSecondaryHorizontalPosition(offset)).isEqualTo(0)
}
@@ -207,10 +211,14 @@
dir = RTL)
val offset = 5 // before L6 == after L5
+ // If insert RX to the first line, it will be |RX L1 L2 L3 L4 L5|
assertThat(layout.getUpstreamPrimaryHorizontalPosition(offset)).isEqualTo(0)
- assertThat(layout.getUpstreamSecondaryHorizontalPosition(offset)).isEqualTo(0)
+ // If insert LX to the first line, it will be |L1 L2 L3 L4 L5 LX|
+ assertThat(layout.getUpstreamSecondaryHorizontalPosition(offset)).isEqualTo(50)
+ // If insert RX to the second line, it will be |L6 L7 L8 L9 LA RX|
assertThat(layout.getDownstreamPrimaryHorizontalPosition(offset)).isEqualTo(50)
- assertThat(layout.getDownstreamSecondaryHorizontalPosition(offset)).isEqualTo(50)
+ // If insert LX to the second line, it will be |LX L6 L7 L8 L9 LA|
+ assertThat(layout.getDownstreamSecondaryHorizontalPosition(offset)).isEqualTo(0)
}
@Test
@@ -299,9 +307,13 @@
dir = RTL)
val offset = 5 // before R6 == after R5
+ // If insert RX to the first line, it will be |RX R5 R4 R3 R2 R1|
assertThat(layout.getUpstreamPrimaryHorizontalPosition(offset)).isEqualTo(0)
+ // If insert LX to the first line, it will be |LX R5 R4 R3 R2 R1|
assertThat(layout.getUpstreamSecondaryHorizontalPosition(offset)).isEqualTo(0)
+ // If insert RX to the second line, it will be |RA R9 R8 R7 R6 RX|
assertThat(layout.getDownstreamPrimaryHorizontalPosition(offset)).isEqualTo(50)
+ // If insert LX to the second line, it will be |RA R9 R8 R7 R6 LX|
assertThat(layout.getDownstreamSecondaryHorizontalPosition(offset)).isEqualTo(50)
}
@@ -391,10 +403,14 @@
dir = LTR)
val offset = 5 // befroe R6 == after R5
+ // If insert LX to the first line, it will be |R5 R4 R3 R2 R1 LX|
assertThat(layout.getUpstreamPrimaryHorizontalPosition(offset)).isEqualTo(50)
- assertThat(layout.getUpstreamSecondaryHorizontalPosition(offset)).isEqualTo(50)
+ // If insert RX to the first line, it will be |RX R5 R4 R3 R2 R1|
+ assertThat(layout.getUpstreamSecondaryHorizontalPosition(offset)).isEqualTo(0)
+ // If insert LX to the second line, it will be |LX RA R9 R8 R7 R6|
assertThat(layout.getDownstreamPrimaryHorizontalPosition(offset)).isEqualTo(0)
- assertThat(layout.getDownstreamSecondaryHorizontalPosition(offset)).isEqualTo(0)
+ // If insert RX to the second line, it will be |RA R9 R8 R7 R6 RX|
+ assertThat(layout.getDownstreamSecondaryHorizontalPosition(offset)).isEqualTo(50)
}
@Test
@@ -874,4 +890,30 @@
// If insert LX to second line, it will be |L1 L2 L3 R7 R6 LX|
assertThat(layout.getDownstreamSecondaryHorizontalPosition(offset)).isEqualTo(50)
}
+
+ @Test
+ fun getHorizontal_BiDi_Whitspace() {
+ // The line break happens like as follows
+ //
+ // input (Logical): R1 R2 SP R3 R4 R6 SP R7 R8 SP R9 RA
+ //
+ // |R4 R3 SP R2 R1| (SP)
+ // |L1 L2 SP L3 L4| (SP)
+ // |L5 L6 |
+ val layout = getLayout(
+ "\u05D0\u05D1 \u05D2\u05D3 \u0061\u0062 \u0063\u0064 \u0065\u0066",
+ 10,
+ 50,
+ LTR)
+
+ val offset = 6 // before L1 == after SP
+ // If insert LX to first line, it will be |R4 R3 SP R2 R1 SP LX|
+ assertThat(layout.getUpstreamPrimaryHorizontalPosition(offset)).isEqualTo(50)
+ // If insert RX to first line, it will be |RX SP R4 R3 SP R2 R1|
+ assertThat(layout.getUpstreamSecondaryHorizontalPosition(offset)).isEqualTo(0)
+ // If insert LX to second line, it will be |LX L2 SP L3 L4| (SP)
+ assertThat(layout.getDownstreamPrimaryHorizontalPosition(offset)).isEqualTo(0)
+ // If insert RX to second line, it will be |RX L1 L2 SP L3 L4| (SP)
+ assertThat(layout.getDownstreamSecondaryHorizontalPosition(offset)).isEqualTo(0)
+ }
}
\ No newline at end of file
diff --git a/ui/ui-text-android/src/androidTest/java/androidx/ui/text/platform/animation/SegmentBreakerBreakSegmentTest.kt b/ui/ui-text-android/src/androidTest/java/androidx/ui/text/platform/animation/SegmentBreakerBreakSegmentTest.kt
new file mode 100644
index 0000000..687c1d4
--- /dev/null
+++ b/ui/ui-text-android/src/androidTest/java/androidx/ui/text/platform/animation/SegmentBreakerBreakSegmentTest.kt
@@ -0,0 +1,1493 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * 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 androidx.ui.text.platform.animation
+
+import android.text.TextDirectionHeuristic
+import android.text.TextDirectionHeuristics
+import android.text.TextPaint
+import androidx.core.content.res.ResourcesCompat
+import androidx.test.filters.SmallTest
+import androidx.test.platform.app.InstrumentationRegistry
+import androidx.ui.text.font.test.R
+import androidx.ui.text.platform.InternalPlatformTextApi
+import androidx.ui.text.platform.LayoutHelper
+import androidx.ui.text.platform.StaticLayoutFactory
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+/**
+ * In this test cases, use following notations:
+ *
+ * - L1-LF shows an example strong LTR character.
+ * - R1-RF shows an example strong RTL character
+ * - SP shows whitespace character (U+0020)
+ * - LF shows line-feed character (U+000A)
+ */
+@SmallTest
+@OptIn(InternalPlatformTextApi::class)
+@RunWith(JUnit4::class)
+class SegmentBreakerBreakSegmentTest {
+ private val sampleTypeface = ResourcesCompat.getFont(
+ InstrumentationRegistry.getInstrumentation().targetContext,
+ R.font.sample_font
+ )
+
+ // Reference Strong LTR character. All characters are supported by sample_font.ttf and they
+ // have 1em width.
+ private val L1 = "\u0061"
+ private val L2 = "\u0062"
+ private val L3 = "\u0063"
+ private val L4 = "\u0064"
+ private val L5 = "\u0065"
+ private val L6 = "\u0066"
+ private val L7 = "\u0067"
+ private val L8 = "\u0068"
+ private val L9 = "\u0069"
+ private val LA = "\u006A"
+
+ // Reference Strong RTL character. All characters are supported by sample_font.ttf and they
+ // have 1em width.
+ private val R1 = "\u05D1"
+ private val R2 = "\u05D2"
+ private val R3 = "\u05D3"
+ private val R4 = "\u05D4"
+ private val R5 = "\u05D5"
+ private val R6 = "\u05D6"
+ private val R7 = "\u05D7"
+ private val R8 = "\u05D8"
+ private val R9 = "\u05D9"
+ private val RA = "\u05DA"
+
+ // White space character. This is supported by sample_font.ttf and this has 1em width.
+ private val SP = " "
+ private val LF = "\n"
+
+ private val LTR = TextDirectionHeuristics.LTR
+ private val RTL = TextDirectionHeuristics.RTL
+
+ // sample_font.ttf has ascent=1000 and descent=-200, hence the line height is 1.2em.
+ private val TEXT_SIZE = 10f
+ private val LINE_HEIGHT = (1.2f * TEXT_SIZE).toInt()
+
+ private fun getLayout(
+ text: String,
+ dir: TextDirectionHeuristic
+ ): LayoutHelper {
+ val paint = TextPaint().apply {
+ textSize = TEXT_SIZE
+ typeface = sampleTypeface
+ }
+ val layout = StaticLayoutFactory.create(
+ text = text,
+ paint = paint,
+ width = 50,
+ textDir = dir,
+ includePadding = false
+ )
+ return LayoutHelper(layout)
+ }
+
+ private fun getSegments(
+ text: String,
+ dir: TextDirectionHeuristic,
+ type: SegmentType,
+ dropSpaces: Boolean
+ ): List<Segment> {
+ val layout = getLayout(text = text, dir = dir)
+ return SegmentBreaker.breakSegments(
+ layoutHelper = layout, segmentType = type, dropSpaces = dropSpaces)
+ }
+
+ @Test
+ fun document_LTRText_LTRPara() {
+ // input (Logical): L1 L2 SP L3 L4 SP L5 L6 SP L7 L8 SP L9 LA
+ //
+ // |L1 L2 SP L3 L4| (SP)
+ // |L5 L6 SP L7 L8| (SP)
+ // |L9 LA |
+ //
+ // Note that trailing whitespace is not counted in line width.
+ val text = "$L1$L2$SP$L3$L4$SP$L5$L6$SP$L7$L8$SP$L9$LA"
+ val segments = getSegments(text, LTR, SegmentType.Document, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(1)
+ assertThat(segments[0]).isEqualTo(
+ Segment(
+ startOffset = 0,
+ endOffset = text.length,
+ left = 0,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ )
+ }
+
+ @Test
+ fun document_LTRText_RTLPara() {
+ // input (Logical): L1 L2 SP L3 L4 SP L5 L6 SP L7 L8 SP L9 LA
+ //
+ // |L1 L2 SP L3 L4| (SP)
+ // |L5 L6 SP L7 L8| (SP)
+ // | L9 LA|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$L1$L2$SP$L3$L4$SP$L5$L6$SP$L7$L8$SP$L9$LA"
+ val segments = getSegments(text, RTL, SegmentType.Document, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(1)
+ assertThat(segments[0]).isEqualTo(
+ Segment(
+ startOffset = 0,
+ endOffset = text.length,
+ left = 0,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ )
+ }
+
+ @Test
+ fun document_RTLText_LTRPara() {
+ // input (Logical): R1 R2 SP R3 R4 SP R5 R6 SP R7 T8 SP R9 RA
+ //
+ // (SP) |R4 R3 SP R2 R1|
+ // (SP) |R8 R7 SP R6 R5|
+ // |RA R9 |
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$R1$R2$SP$R3$R4$SP$R5$R6$SP$R7$R8$SP$R9$RA"
+ val segments = getSegments(text, LTR, SegmentType.Document, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(1)
+ assertThat(segments[0]).isEqualTo(
+ Segment(
+ startOffset = 0,
+ endOffset = text.length,
+ left = 0,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ )
+ }
+
+ @Test
+ fun document_RTLText_RTLPara() {
+ // input (Logical): R1 R2 SP R3 R4 SP R5 R6 SP R7 T8 SP R9 RA
+ //
+ // (SP) |R4 R3 SP R2 R1|
+ // (SP) |R8 R7 SP R6 R5|
+ // | RA R9|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$R1$R2$SP$R3$R4$SP$R5$R6$SP$R7$R8$SP$R9$RA"
+ val segments = getSegments(text, RTL, SegmentType.Document, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(1)
+ assertThat(segments[0]).isEqualTo(
+ Segment(
+ startOffset = 0,
+ endOffset = text.length,
+ left = 0,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ )
+ }
+
+ @Test
+ fun paragraph_LTRText_LTRPara() {
+ // input (Logical): L1 L2 SP L3 L4 SP L5 L6 LF L7 L8 SP L9 LA
+ //
+ // |L1 L2 SP L3 L4| (SP)
+ // |L5 L6 (LF) |
+ // |L7 L8 SP L9 LA|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$L1$L2$SP$L3$L4$SP$L5$L6$LF$L7$L8$SP$L9$LA"
+ val segments = getSegments(text, LTR, SegmentType.Paragraph, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(2)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 9, // LF char offset
+ left = 0,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = text.length,
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun paragraph_LTRText_RTLPara() {
+ // input (Logical): L1 L2 SP L3 L4 SP L5 L6 LF L7 L8 SP L9 LA
+ //
+ // |L1 L2 SP L3 L4| (SP)
+ // | L5 L6| (LF)
+ // |L7 L8 SP L9 LA|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$L1$L2$SP$L3$L4$SP$L5$L6$LF$L7$L8$SP$L9$LA"
+ val segments = getSegments(text, RTL, SegmentType.Paragraph, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(2)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 9, // LF char offset
+ left = 0,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = text.length,
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun paragraph_RTLText_LTRPara() {
+ // input (Logical): R1 R2 SP R3 R4 SP R5 R6 LF R7 T8 SP R9 RA
+ //
+ // (SP) |R4 R3 SP R2 R1|
+ // (LF) |R6 R5 |
+ // |R8 R7 SP RA R9|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$R1$R2$SP$R3$R4$SP$R5$R6$LF$R7$R8$SP$R9$RA"
+ val segments = getSegments(text, LTR, SegmentType.Paragraph, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(2)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 9, // LF char offset
+ left = 0,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = text.length,
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun paragraph_RTLText_RTLPara() {
+ // input (Logical): R1 R2 SP R3 R4 SP R5 R6 LF R7 T8 SP R9 RA
+ //
+ // (SP) |R4 R3 SP R2 R1|
+ // | (LF)R6 R5|
+ // |RA R9 SP R8 R7|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$R1$R2$SP$R3$R4$SP$R5$R6$LF$R7$R8$SP$R9$RA"
+ val segments = getSegments(text, RTL, SegmentType.Paragraph, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(2)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 9, // LF char offset
+ left = 0,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = text.length,
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun line_LTRText_LTRPara_includeSpaces() {
+ // input (Logical): L1 L2 SP L3 L4 SP L5 L6 LF L7 L8 SP L9 LA
+ //
+ // |L1 L2 SP L3 L4| (SP)
+ // |L5 L6(LF) |
+ // |L7 L8 SP L9 LA|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$L1$L2$SP$L3$L4$SP$L5$L6$LF$L7$L8$SP$L9$LA"
+ val segments = getSegments(text, LTR, SegmentType.Line, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(3)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 6, // 2nd SP char offset
+ left = 0,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 6,
+ endOffset = 9, // LF char offset
+ left = 0,
+ top = LINE_HEIGHT,
+ right = 50,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = text.length,
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun line_LTRText_RTLPara_includeSpaces() {
+ // input (Logical): L1 L2 SP L3 L4 SP L5 L6 LF L7 L8 SP L9 LA
+ //
+ // |L1 L2 SP L3 L4| (SP)
+ // | L5 L6| (LF)
+ // |L7 L8 SP L9 LA|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$L1$L2$SP$L3$L4$SP$L5$L6$LF$L7$L8$SP$L9$LA"
+ val segments = getSegments(text, RTL, SegmentType.Line, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(3)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 6, // 2nd SP char offset
+ left = 0,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 6,
+ endOffset = 9, // LF char offset
+ left = 0,
+ top = LINE_HEIGHT,
+ right = 50,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = text.length,
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun line_RTLText_LTRPara_includeSpaces() {
+ // input (Logical): R1 R2 SP R3 R4 SP R5 R6 LF R7 T8 SP R9 RA
+ //
+ // (SP) |R4 R3 SP R2 R1|
+ // (LF) |R6 R5 |
+ // |RA R9 SP R8 R7|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$R1$R2$SP$R3$R4$SP$R5$R6$LF$R7$R8$SP$R9$RA"
+ val segments = getSegments(text, LTR, SegmentType.Line, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(3)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 6, // 2nd SP char offset
+ left = 0,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 6,
+ endOffset = 9, // LF char offset
+ left = 0,
+ top = LINE_HEIGHT,
+ right = 50,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = text.length,
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun line_RTLText_RTLPara_includeSpaces() {
+ // input (Logical): R1 R2 SP R3 R4 SP R5 R6 LF R7 T8 SP R9 RA
+ //
+ // (SP) |R4 R3 SP R2 R1|
+ // | (LF)R6 R5|
+ // |RA R9 SP R8 R7|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$R1$R2$SP$R3$R4$SP$R5$R6$LF$R7$R8$SP$R9$RA"
+ val segments = getSegments(text, RTL, SegmentType.Line, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(3)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 6, // 2nd SP char offset
+ left = 0,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 6,
+ endOffset = 9, // LF char offset
+ left = 0,
+ top = LINE_HEIGHT,
+ right = 50,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = text.length,
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun line_LTRText_LTRPara_excludeSpaces() {
+ // input (Logical): L1 L2 SP L3 L4 SP L5 L6 LF L7 L8 SP L9 LA
+ //
+ // |L1 L2 SP L3 L4| (SP)
+ // |L5 L6(LF) |
+ // |L7 L8 SP L9 LA|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$L1$L2$SP$L3$L4$SP$L5$L6$LF$L7$L8$SP$L9$LA"
+ val segments = getSegments(text, LTR, SegmentType.Line, dropSpaces = true)
+ assertThat(segments.size).isEqualTo(3)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 6, // 2nd SP char offset
+ left = 0,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 6,
+ endOffset = 9, // LF char offset
+ left = 0,
+ top = LINE_HEIGHT,
+ right = 20,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = text.length,
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun line_LTRText_RTLPara_excludeSpaces() {
+ // input (Logical): L1 L2 SP L3 L4 SP L5 L6 LF L7 L8 SP L9 LA
+ //
+ // |L1 L2 SP L3 L4| (SP)
+ // | L5 L6| (LF)
+ // |L7 L8 SP L9 LA|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$L1$L2$SP$L3$L4$SP$L5$L6$LF$L7$L8$SP$L9$LA"
+ val segments = getSegments(text, RTL, SegmentType.Line, dropSpaces = true)
+ assertThat(segments.size).isEqualTo(3)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 6, // 2nd SP char offset
+ left = 0,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 6,
+ endOffset = 9, // LF char offset
+ left = 30,
+ top = LINE_HEIGHT,
+ right = 50,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = text.length,
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun line_RTLText_LTRPara_excludeSpaces() {
+ // input (Logical): R1 R2 SP R3 R4 SP R5 R6 LF R7 T8 SP R9 RA
+ //
+ // (SP) |R4 R3 SP R2 R1|
+ // (LF) |R6 R5 |
+ // |RA R9 SP R8 R7|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$R1$R2$SP$R3$R4$SP$R5$R6$LF$R7$R8$SP$R9$RA"
+ val segments = getSegments(text, LTR, SegmentType.Line, dropSpaces = true)
+ assertThat(segments.size).isEqualTo(3)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 6, // 2nd SP char offset
+ left = 0,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 6,
+ endOffset = 9, // LF char offset
+ left = 0,
+ top = LINE_HEIGHT,
+ right = 20,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = text.length,
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun line_RTLText_RTLPara_excludeSpaces() {
+ // input (Logical): R1 R2 SP R3 R4 SP R5 R6 LF R7 T8 SP R9 RA
+ //
+ // (SP) |R4 R3 SP R2 R1|
+ // | (LF)R6 R5|
+ // |RA R9 SP R8 R7|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$R1$R2$SP$R3$R4$SP$R5$R6$LF$R7$R8$SP$R9$RA"
+ val segments = getSegments(text, RTL, SegmentType.Line, dropSpaces = true)
+ assertThat(segments.size).isEqualTo(3)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 6, // 2nd SP char offset
+ left = 0,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 6,
+ endOffset = 9, // LF char offset
+ left = 30,
+ top = LINE_HEIGHT,
+ right = 50,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = text.length,
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun line_Bidi() {
+ // input (Logical): L1 L2 SP R1 R2 SP R3 R4 SP L3 L4
+ //
+ // |L1 L2 SP (SP) R2 R1|
+ // |R4 R3 SP L3 L4|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$L1$L2$SP$R1$R2$SP$R3$R4$SP$L3$L4"
+ val segments = getSegments(text, LTR, SegmentType.Line, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(2)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 6, // 2nd SP char offset
+ left = 0,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 6,
+ endOffset = text.length,
+ left = 0,
+ top = LINE_HEIGHT,
+ right = 50,
+ bottom = LINE_HEIGHT * 2
+ )
+ ))
+ }
+
+ @Test
+ fun word_LTRText_LTRPara_includeSpaces() {
+ // input (Logical): L1 L2 SP L3 L4 SP L5 L6 LF L7 L8 SP L9 LA
+ //
+ // |L1 L2 SP L3 L4| (SP)
+ // |L5 L6(LF) |
+ // |L7 L8 SP L9 LA|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$L1$L2$SP$L3$L4$SP$L5$L6$LF$L7$L8$SP$L9$LA"
+ val segments = getSegments(text, LTR, SegmentType.Word, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(5)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 3, // 1st SP char offset
+ left = 0,
+ top = 0,
+ right = 30,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 3,
+ endOffset = 6, // 2st SP char offset
+ left = 30,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 6,
+ endOffset = 9, // LF char offset
+ left = 0,
+ top = LINE_HEIGHT,
+ right = 20,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = 12, // 3rd SP char offset
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 30,
+ bottom = LINE_HEIGHT * 3
+ ),
+ Segment(
+ startOffset = 12,
+ endOffset = text.length,
+ left = 30,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun word_LTRText_RTLPara_includeSpaces() {
+ // input (Logical): L1 L2 SP L3 L4 SP L5 L6 LF L7 L8 SP L9 LA
+ //
+ // |L1 L2 SP L3 L4| (SP)
+ // | L5 L6| (LF)
+ // |L7 L8 SP L9 LA|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$L1$L2$SP$L3$L4$SP$L5$L6$LF$L7$L8$SP$L9$LA"
+ val segments = getSegments(text, RTL, SegmentType.Word, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(5)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 3, // 1st SP char offset
+ left = 0,
+ top = 0,
+ right = 30,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 3,
+ endOffset = 6, // 2st SP char offset
+ left = 30,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 6,
+ endOffset = 9, // LF char offset
+ left = 30,
+ top = LINE_HEIGHT,
+ right = 50,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = 12, // 3rd SP char offset
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 30,
+ bottom = LINE_HEIGHT * 3
+ ),
+ Segment(
+ startOffset = 12,
+ endOffset = text.length,
+ left = 30,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun word_RTLText_LTRPara_includeSpaces() {
+ // input (Logical): R1 R2 SP R3 R4 SP R5 R6 LF R7 T8 SP R9 RA
+ //
+ // (SP) |R4 R3 SP R2 R1|
+ // (LF) |R6 R5 |
+ // |RA R9 SP R8 R7|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$R1$R2$SP$R3$R4$SP$R5$R6$LF$R7$R8$SP$R9$RA"
+ val segments = getSegments(text, LTR, SegmentType.Word, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(6)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 3, // 1st SP char offset
+ left = 20,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 3,
+ endOffset = 6, // 2st SP char offset
+ left = 0,
+ top = 0,
+ right = 20,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 6,
+ endOffset = 8,
+ left = 0,
+ top = LINE_HEIGHT,
+ right = 20,
+ bottom = LINE_HEIGHT * 2
+ ),
+ // Bidi assigns LF character to LTR. Do we want to include preceding run?
+ Segment(
+ startOffset = 8,
+ endOffset = 9,
+ left = 20,
+ top = LINE_HEIGHT,
+ right = 20,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = 12, // 3rd SP char offset
+ left = 20,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ ),
+ Segment(
+ startOffset = 12,
+ endOffset = text.length,
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 20,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun word_RTLText_RTLPara_includeSpaces() {
+ // input (Logical): R1 R2 SP R3 R4 SP R5 R6 LF R7 T8 SP R9 RA
+ //
+ // (SP) |R4 R3 SP R2 R1|
+ // | (LF)R6 R5|
+ // |RA R9 SP R8 R7|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$R1$R2$SP$R3$R4$SP$R5$R6$LF$R7$R8$SP$R9$RA"
+ val segments = getSegments(text, RTL, SegmentType.Word, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(5)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 3, // 1st SP char offset
+ left = 20,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 3,
+ endOffset = 6, // 2st SP char offset
+ left = 0,
+ top = 0,
+ right = 20,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 6,
+ endOffset = 9, // LF char offset
+ left = 30,
+ top = LINE_HEIGHT,
+ right = 50,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = 12, // 3rd SP char offset
+ left = 20,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ ),
+ Segment(
+ startOffset = 12,
+ endOffset = text.length,
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 20,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun word_LTRText_LTRPara_excludeSpaces() {
+ // input (Logical): L1 L2 SP L3 L4 SP L5 L6 LF L7 L8 SP L9 LA
+ //
+ // |L1 L2 SP L3 L4| (SP)
+ // |L5 L6(LF) |
+ // |L7 L8 SP L9 LA|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$L1$L2$SP$L3$L4$SP$L5$L6$LF$L7$L8$SP$L9$LA"
+ val segments = getSegments(text, LTR, SegmentType.Word, dropSpaces = true)
+ assertThat(segments.size).isEqualTo(5)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 3, // 1st SP char offset
+ left = 0,
+ top = 0,
+ right = 20,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 3,
+ endOffset = 6, // 2st SP char offset
+ left = 30,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 6,
+ endOffset = 9, // LF char offset
+ left = 0,
+ top = LINE_HEIGHT,
+ right = 20,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = 12, // 3rd SP char offset
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 20,
+ bottom = LINE_HEIGHT * 3
+ ),
+ Segment(
+ startOffset = 12,
+ endOffset = text.length,
+ left = 30,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun word_LTRText_RTLPara_excludeSpaces() {
+ // input (Logical): L1 L2 SP L3 L4 SP L5 L6 LF L7 L8 SP L9 LA
+ //
+ // |L1 L2 SP L3 L4| (SP)
+ // | L5 L6| (LF)
+ // |L7 L8 SP L9 LA|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$L1$L2$SP$L3$L4$SP$L5$L6$LF$L7$L8$SP$L9$LA"
+ val segments = getSegments(text, RTL, SegmentType.Word, dropSpaces = true)
+ assertThat(segments.size).isEqualTo(5)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 3, // 1st SP char offset
+ left = 0,
+ top = 0,
+ right = 20,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 3,
+ endOffset = 6, // 2st SP char offset
+ left = 30,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 6,
+ endOffset = 9, // LF char offset
+ left = 30,
+ top = LINE_HEIGHT,
+ right = 50,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = 12, // 3rd SP char offset
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 20,
+ bottom = LINE_HEIGHT * 3
+ ),
+ Segment(
+ startOffset = 12,
+ endOffset = text.length,
+ left = 30,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun word_RTLText_LTRPara_excludeSpaces() {
+ // input (Logical): R1 R2 SP R3 R4 SP R5 R6 LF R7 T8 SP R9 RA
+ //
+ // (SP) |R4 R3 SP R2 R1|
+ // (LF) |R6 R5 |
+ // |RA R9 SP R8 R7|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$R1$R2$SP$R3$R4$SP$R5$R6$LF$R7$R8$SP$R9$RA"
+ val segments = getSegments(text, LTR, SegmentType.Word, dropSpaces = true)
+ assertThat(segments.size).isEqualTo(6)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 3, // 1st SP char offset
+ left = 30,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 3,
+ endOffset = 6, // 2st SP char offset
+ left = 0,
+ top = 0,
+ right = 20,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 6,
+ endOffset = 8,
+ left = 0,
+ top = LINE_HEIGHT,
+ right = 20,
+ bottom = LINE_HEIGHT * 2
+ ),
+ // Bidi assigns LF character to LTR. Do we want to include preceding run?
+ Segment(
+ startOffset = 8,
+ endOffset = 9,
+ left = 20,
+ top = LINE_HEIGHT,
+ right = 20,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = 12, // 3rd SP char offset
+ left = 30,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ ),
+ Segment(
+ startOffset = 12,
+ endOffset = text.length,
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 20,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun word_RTLText_RTLPara_excludeSpaces() {
+ // input (Logical): R1 R2 SP R3 R4 SP R5 R6 LF R7 T8 SP R9 RA
+ //
+ // (SP) |R4 R3 SP R2 R1|
+ // | (LF)R6 R5|
+ // |RA R9 SP R8 R7|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$R1$R2$SP$R3$R4$SP$R5$R6$LF$R7$R8$SP$R9$RA"
+ val segments = getSegments(text, RTL, SegmentType.Word, dropSpaces = true)
+ assertThat(segments.size).isEqualTo(5)
+ assertThat(segments).isEqualTo(listOf(
+ Segment(
+ startOffset = 0,
+ endOffset = 3, // 1st SP char offset
+ left = 30,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 3,
+ endOffset = 6, // 2st SP char offset
+ left = 0,
+ top = 0,
+ right = 20,
+ bottom = LINE_HEIGHT
+ ),
+ Segment(
+ startOffset = 6,
+ endOffset = 9, // LF char offset
+ left = 30,
+ top = LINE_HEIGHT,
+ right = 50,
+ bottom = LINE_HEIGHT * 2
+ ),
+ Segment(
+ startOffset = 9,
+ endOffset = 12, // 3rd SP char offset
+ left = 30,
+ top = LINE_HEIGHT * 2,
+ right = 50,
+ bottom = LINE_HEIGHT * 3
+ ),
+ Segment(
+ startOffset = 12,
+ endOffset = text.length,
+ left = 0,
+ top = LINE_HEIGHT * 2,
+ right = 20,
+ bottom = LINE_HEIGHT * 3
+ )
+ ))
+ }
+
+ @Test
+ fun char_LTRText_LTRPara_includeSpaces() {
+ // input (Logical): L1 L2 SP L3 L4 SP L5 L6 LF L7 L8 SP L9 LA
+ //
+ // |L1 L2 SP L3 L4| (SP)
+ // |L5 L6(LF) |
+ // |L7 L8 SP L9 LA|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$L1$L2$SP$L3$L4$SP$L5$L6$LF$L7$L8$SP$L9$LA"
+ val segments = getSegments(text, LTR, SegmentType.Character, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(14)
+ assertThat(segments[0]).isEqualTo(Segment( // L1 character
+ startOffset = 0,
+ endOffset = 1,
+ left = 0,
+ top = 0,
+ right = 10,
+ bottom = LINE_HEIGHT
+ ))
+ assertThat(segments[2]).isEqualTo(Segment( // 1st SP location
+ startOffset = 2,
+ endOffset = 3,
+ left = 20,
+ top = 0,
+ right = 30,
+ bottom = LINE_HEIGHT
+ ))
+ assertThat(segments[5]).isEqualTo(Segment( // 2nd SP location. not rendered.
+ startOffset = 5,
+ endOffset = 6,
+ left = 50,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ))
+ }
+
+ @Test
+ fun char_LTRText_RTLPara_includeSpaces() {
+ // input (Logical): L1 L2 SP L3 L4 SP L5 L6 LF L7 L8 SP L9 LA
+ //
+ // (SP) |L1 L2 SP L3 L4|
+ // | (LF)L5 L6|
+ // |L7 L8 SP L9 LA|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$L1$L2$SP$L3$L4$SP$L5$L6$LF$L7$L8$SP$L9$LA"
+ val segments = getSegments(text, RTL, SegmentType.Character, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(14)
+ assertThat(segments[0]).isEqualTo(Segment( // L1 character
+ startOffset = 0,
+ endOffset = 1,
+ left = 0,
+ top = 0,
+ right = 10,
+ bottom = LINE_HEIGHT
+ ))
+ assertThat(segments[2]).isEqualTo(Segment( // 1st SP location
+ startOffset = 2,
+ endOffset = 3,
+ left = 20,
+ top = 0,
+ right = 30,
+ bottom = LINE_HEIGHT
+ ))
+ assertThat(segments[5]).isEqualTo(Segment( // 2nd SP location. not rendered.
+ startOffset = 5,
+ endOffset = 6,
+ left = 0,
+ top = 0,
+ right = 0,
+ bottom = LINE_HEIGHT
+ ))
+ }
+
+ @Test
+ fun char_RTLText_LTRPara_includeSpaces() {
+ // input (Logical): R1 R2 SP R3 R4 SP R5 R6 LF R7 T8 SP R9 RA
+ //
+ // |R4 R3 SP R2 R1| (SP)
+ // |R6 R5(LF) |
+ // |RA R9 SP R8 R7|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$R1$R2$SP$R3$R4$SP$R5$R6$LF$R7$R8$SP$R9$RA"
+ val segments = getSegments(text, LTR, SegmentType.Character, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(14)
+ assertThat(segments[0]).isEqualTo(Segment( // R1 character
+ startOffset = 0,
+ endOffset = 1,
+ left = 40,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ))
+ assertThat(segments[2]).isEqualTo(Segment( // 1st SP location
+ startOffset = 2,
+ endOffset = 3,
+ left = 20,
+ top = 0,
+ right = 30,
+ bottom = LINE_HEIGHT
+ ))
+ assertThat(segments[5]).isEqualTo(Segment( // 2nd SP location. not rendered.
+ startOffset = 5,
+ endOffset = 6,
+ left = 50,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ))
+ }
+
+ @Test
+ fun char_RTLText_RTLPara_includeSpaces() {
+ // input (Logical): R1 R2 SP R3 R4 SP R5 R6 LF R7 T8 SP R9 RA
+ //
+ // (SP) |R4 R3 SP R2 R1|
+ // | (LF)R6 R5|
+ // |RA R9 SP R8 R7|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$R1$R2$SP$R3$R4$SP$R5$R6$LF$R7$R8$SP$R9$RA"
+ val segments = getSegments(text, RTL, SegmentType.Character, dropSpaces = false)
+ assertThat(segments.size).isEqualTo(14)
+ assertThat(segments[0]).isEqualTo(Segment( // R1 character
+ startOffset = 0,
+ endOffset = 1,
+ left = 40,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ))
+ assertThat(segments[2]).isEqualTo(Segment( // 1st SP location
+ startOffset = 2,
+ endOffset = 3,
+ left = 20,
+ top = 0,
+ right = 30,
+ bottom = LINE_HEIGHT
+ ))
+ assertThat(segments[5]).isEqualTo(Segment( // 2nd SP location. not rendered.
+ startOffset = 5,
+ endOffset = 6,
+ left = 0,
+ top = 0,
+ right = 0,
+ bottom = LINE_HEIGHT
+ ))
+ }
+
+ @Test
+ fun char_LTRText_LTRPara_excludeSpaces() {
+ // input (Logical): L1 L2 SP L3 L4 SP L5 L6 LF L7 L8 SP L9 LA
+ //
+ // |L1 L2 SP L3 L4| (SP)
+ // |L5 L6(LF) |
+ // |L7 L8 SP L9 LA|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$L1$L2$SP$L3$L4$SP$L5$L6$LF$L7$L8$SP$L9$LA"
+ val segments = getSegments(text, LTR, SegmentType.Character, dropSpaces = true)
+ assertThat(segments.size).isEqualTo(10) // three spaces and one line feeds are excluded
+ assertThat(segments[0]).isEqualTo(Segment( // L1 character
+ startOffset = 0,
+ endOffset = 1,
+ left = 0,
+ top = 0,
+ right = 10,
+ bottom = LINE_HEIGHT
+ ))
+ assertThat(segments[2]).isEqualTo(Segment( // 1st SP is skipped. L3 character
+ startOffset = 3,
+ endOffset = 4,
+ left = 30,
+ top = 0,
+ right = 40,
+ bottom = LINE_HEIGHT
+ ))
+ assertThat(segments[4]).isEqualTo(Segment( // 2nd SP is skipped. L5 character
+ startOffset = 6,
+ endOffset = 7,
+ left = 0,
+ top = LINE_HEIGHT,
+ right = 10,
+ bottom = LINE_HEIGHT * 2
+ ))
+ }
+
+ @Test
+ fun char_LTRText_RTLPara_excludeSpaces() {
+ // input (Logical): L1 L2 SP L3 L4 SP L5 L6 LF L7 L8 SP L9 LA
+ //
+ // (SP) |L1 L2 SP L3 L4|
+ // | (LF)L5 L6|
+ // |L7 L8 SP L9 LA|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$L1$L2$SP$L3$L4$SP$L5$L6$LF$L7$L8$SP$L9$LA"
+ val segments = getSegments(text, RTL, SegmentType.Character, dropSpaces = true)
+ assertThat(segments.size).isEqualTo(10) // three spaces and one line feeds are excluded
+ assertThat(segments[0]).isEqualTo(Segment( // L1 character
+ startOffset = 0,
+ endOffset = 1,
+ left = 0,
+ top = 0,
+ right = 10,
+ bottom = LINE_HEIGHT
+ ))
+ assertThat(segments[2]).isEqualTo(Segment( // 1st SP is skipped. L3 character
+ startOffset = 3,
+ endOffset = 4,
+ left = 30,
+ top = 0,
+ right = 40,
+ bottom = LINE_HEIGHT
+ ))
+ assertThat(segments[4]).isEqualTo(Segment( // 2nd SP is skipped. L5 character
+ startOffset = 6,
+ endOffset = 7,
+ left = 30,
+ top = LINE_HEIGHT,
+ right = 40,
+ bottom = LINE_HEIGHT * 2
+ ))
+ }
+
+ @Test
+ fun char_RTLText_LTRPara_excludeSpaces() {
+ // input (Logical): R1 R2 SP R3 R4 SP R5 R6 LF R7 T8 SP R9 RA
+ //
+ // (SP) |R4 R3 SP R2 R1|
+ // (LF) |R6 R5 |
+ // |RA R9 SP R8 R7|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$R1$R2$SP$R3$R4$SP$R5$R6$LF$R7$R8$SP$R9$RA"
+ val segments = getSegments(text, LTR, SegmentType.Character, dropSpaces = true)
+ assertThat(segments.size).isEqualTo(10) // three spaces and one line feeds are excluded
+ assertThat(segments[0]).isEqualTo(Segment( // R1 character
+ startOffset = 0,
+ endOffset = 1,
+ left = 40,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ))
+ assertThat(segments[2]).isEqualTo(Segment( // 1st SP is skipped. R3 character
+ startOffset = 3,
+ endOffset = 4,
+ left = 10,
+ top = 0,
+ right = 20,
+ bottom = LINE_HEIGHT
+ ))
+ assertThat(segments[4]).isEqualTo(Segment( // 2nd SP is skipped. R5 character
+ startOffset = 6,
+ endOffset = 7,
+ left = 10,
+ top = LINE_HEIGHT,
+ right = 20,
+ bottom = LINE_HEIGHT * 2
+ ))
+ }
+
+ @Test
+ fun char_RTLText_RTLPara_excludeSpaces() {
+ // input (Logical): R1 R2 SP R3 R4 SP R5 R6 LF R7 T8 SP R9 RA
+ //
+ // (SP) |R4 R3 SP R2 R1|
+ // | (LF)R6 R5|
+ // |RA R9 SP R8 R7|
+ //
+ // Note that trailing whitespace is not counted in line width. The characters with
+ // parenthesis are not counted as width.
+ val text = "$R1$R2$SP$R3$R4$SP$R5$R6$LF$R7$R8$SP$R9$RA"
+ val segments = getSegments(text, RTL, SegmentType.Character, dropSpaces = true)
+ assertThat(segments.size).isEqualTo(10) // three spaces and one line feeds are excluded
+ assertThat(segments[0]).isEqualTo(Segment( // R1 character
+ startOffset = 0,
+ endOffset = 1,
+ left = 40,
+ top = 0,
+ right = 50,
+ bottom = LINE_HEIGHT
+ ))
+ assertThat(segments[2]).isEqualTo(Segment( // 1st SP is skipped. R3 character
+ startOffset = 3,
+ endOffset = 4,
+ left = 10,
+ top = 0,
+ right = 20,
+ bottom = LINE_HEIGHT
+ ))
+ assertThat(segments[4]).isEqualTo(Segment( // 2nd SP is skipped. R5 character
+ startOffset = 6,
+ endOffset = 7,
+ left = 40,
+ top = LINE_HEIGHT,
+ right = 50,
+ bottom = LINE_HEIGHT * 2
+ ))
+ }
+}
\ No newline at end of file
diff --git a/ui/ui-text-android/src/main/java/androidx/ui/text/platform/LayoutHelper.kt b/ui/ui-text-android/src/main/java/androidx/ui/text/platform/LayoutHelper.kt
index 76b39e7..c9ef027 100644
--- a/ui/ui-text-android/src/main/java/androidx/ui/text/platform/LayoutHelper.kt
+++ b/ui/ui-text-android/src/main/java/androidx/ui/text/platform/LayoutHelper.kt
@@ -231,19 +231,12 @@
val paraNo = getParagraphForOffset(offset)
val isParaRtl = isRTLParagraph(paraNo)
- val bidi = analyzeBidi(paraNo)
- if (bidi == null) { // easy case. All directions are the same
- return if (lineStart == offset) {
- if (isParaRtl) layout.getLineRight(lineNo) else layout.getLineLeft(lineNo)
- } else {
- if (isParaRtl) layout.getLineLeft(lineNo) else layout.getLineRight(lineNo)
- }
- }
-
- val lineBidi = bidi.createLineBidi(lineStart, lineEnd)
- if (lineBidi.runCount == 1) { // still easy case. All the same direction in a line
- // True if start offset locate left edge, otherwise false.
- val isStartLeft = if (usePrimaryDirection || isParaRtl == lineBidi.isRightToLeft) {
+ // Use line visible end for creating bidi object since invisible whitespaces should not be
+ // considered for location retrieval.
+ val lineBidi = analyzeBidi(paraNo)?.createLineBidi(lineStart, lineEndToVisibleEnd(lineEnd))
+ if (lineBidi == null || lineBidi.runCount == 1) { // easy case. All directions are the same
+ val runDirection = layout.isRtlCharAt(lineStart)
+ val isStartLeft = if (usePrimaryDirection || isParaRtl == runDirection) {
!isParaRtl
} else {
isParaRtl
@@ -336,4 +329,22 @@
}
private data class BidiRun(val start: Int, val end: Int, val isRtl: Boolean)
+
+ // Convert line end offset to the offset that is the last visible character.
+ private fun lineEndToVisibleEnd(lineEnd: Int): Int {
+ var visibleEnd = lineEnd
+ while (visibleEnd > 0) {
+ if (isLineEndSpace(layout.text.get(visibleEnd - 1 /* visibleEnd is exclusive */))) {
+ visibleEnd--
+ } else {
+ break
+ }
+ }
+ return visibleEnd
+ }
+
+ // The spaces that will not be rendered if they are placed at the line end. In most case, it is
+ // whitespace or line feed character, hence checking linearly should be enough.
+ fun isLineEndSpace(c: Char) = c == ' ' || c == '\n' || c == '\u1680' ||
+ (c in '\u2000'..'\u200A' && c != '\u2007') || c == '\u205F' || c == '\u3000'
}
\ No newline at end of file
diff --git a/ui/ui-text-android/src/main/java/androidx/ui/text/platform/animation/SegmentBreaker.kt b/ui/ui-text-android/src/main/java/androidx/ui/text/platform/animation/SegmentBreaker.kt
index ae204cb..edb0081 100644
--- a/ui/ui-text-android/src/main/java/androidx/ui/text/platform/animation/SegmentBreaker.kt
+++ b/ui/ui-text-android/src/main/java/androidx/ui/text/platform/animation/SegmentBreaker.kt
@@ -16,11 +16,38 @@
package androidx.ui.text.platform.animation
+import android.text.Layout
import androidx.ui.text.platform.CharSequenceCharacterIterator
import androidx.ui.text.platform.InternalPlatformTextApi
import androidx.ui.text.platform.LayoutHelper
+import androidx.ui.text.platform.getLineForOffset
import java.text.BreakIterator
import java.util.Locale
+import kotlin.math.ceil
+import kotlin.math.max
+import kotlin.math.min
+
+/**
+ * A class represents animation segment.
+ *
+ * @param startOffset an inclusive start character offset of this segment.
+ * @param endOffset an exclusive end character offset of this segment.
+ * @param left a graphical left position from the layout origin.
+ * @param top a graphical top position from the layout origin.
+ * @param right a graphical right position from the layout origin.
+ * @param bottom a graphical bottom position from the layout origin.
+ *
+ * @suppress
+ */
+@InternalPlatformTextApi
+data class Segment(
+ val startOffset: Int,
+ val endOffset: Int,
+ val left: Int,
+ val top: Int,
+ val right: Int,
+ val bottom: Int
+)
/**
* Porvide a segmentation breaker for the text animation.
@@ -87,4 +114,183 @@
BreakIterator.getCharacterInstance(Locale.getDefault()))
}
}
+
+ /**
+ * Break Layout into list of segments.
+ *
+ * A segment represents a unit of text animation. For example, if you specify, SegmentType
+ * .Line, this function will give you a list of Line segments which have line start offset and
+ * line end offset, and also line bounding box.
+ *
+ * The dropSpaces argument is ignored if segmentType is Document or Paragraph.
+ *
+ * If segmentType is Line and dropSpaces is true, this removes trailing spaces. If
+ * segmentType is Line and dropSpace is false, this use layout width as the right position of
+ * the line.
+ *
+ * If segmentType is Word and dropSpaces is true, this removes trailing spaces if there. If
+ * segmentType is Word and dropSpace is false, this includes the trailing whitespace into
+ * segment.
+ *
+ * If segmentType is Character and dropSpace is true, this drops whitespace only segment. If
+ * segmentType is Character and dropSpace is true, this include whitespace only segment.
+ *
+ * @param layoutHelper a layout helper
+ * @param segmentType a segmentation type
+ * @param dropSpaces whether dropping spacing. See function comment for more details.
+ * @return list of segment object
+ */
+ fun breakSegments(
+ layoutHelper: LayoutHelper,
+ segmentType: SegmentType,
+ dropSpaces: Boolean
+ ): List<Segment> {
+ return when (segmentType) {
+ SegmentType.Document -> breakSegmentWithDocument(layoutHelper)
+ SegmentType.Paragraph -> breakSegmentWithParagraph(layoutHelper)
+ SegmentType.Line -> breakSegmentWithLine(layoutHelper, dropSpaces)
+ SegmentType.Word -> breakSegmentWithWord(layoutHelper, dropSpaces)
+ SegmentType.Character -> breakSegmentWithChar(layoutHelper, dropSpaces)
+ }
+ }
+
+ private fun breakSegmentWithDocument(layoutHelper: LayoutHelper): List<Segment> {
+ return listOf(Segment(
+ startOffset = 0,
+ endOffset = layoutHelper.layout.text.length,
+ left = 0,
+ top = 0,
+ right = layoutHelper.layout.width,
+ bottom = layoutHelper.layout.height
+ ))
+ }
+
+ private fun breakSegmentWithParagraph(layoutHelper: LayoutHelper): List<Segment> {
+ val result = mutableListOf<Segment>()
+ val layout = layoutHelper.layout
+ for (i in 0 until layoutHelper.paragraphCount) {
+ val paraStart = layoutHelper.getParagraphStart(i)
+ val paraEnd = layoutHelper.getParagraphEnd(i)
+ val paraFirstLine = layout.getLineForOffset(paraStart, false /* downstream */)
+ val paraLastLine = layout.getLineForOffset(paraEnd, true /* upstream */)
+ result.add(Segment(
+ startOffset = paraStart,
+ endOffset = paraEnd,
+ left = 0,
+ top = layout.getLineTop(paraFirstLine),
+ right = layout.width,
+ bottom = layout.getLineBottom(paraLastLine)
+ ))
+ }
+ return result
+ }
+
+ private fun breakSegmentWithLine(
+ layoutHelper: LayoutHelper,
+ dropSpaces: Boolean
+ ): List<Segment> {
+ val result = mutableListOf<Segment>()
+ val layout = layoutHelper.layout
+ for (i in 0 until layoutHelper.layout.lineCount) {
+ result.add(Segment(
+ startOffset = layout.getLineStart(i),
+ endOffset = layout.getLineEnd(i),
+ left = if (dropSpaces) ceil(layout.getLineLeft(i)).toInt() else 0,
+ top = layout.getLineTop(i),
+ right = if (dropSpaces) ceil(layout.getLineRight(i)).toInt() else layout.width,
+ bottom = layout.getLineBottom(i)
+ ))
+ }
+ return result
+ }
+
+ private fun breakSegmentWithWord(
+ layoutHelper: LayoutHelper,
+ dropSpaces: Boolean
+ ): List<Segment> {
+ val layout = layoutHelper.layout
+ val wsWidth = ceil(layout.paint.measureText(" ")).toInt()
+ return breakOffsets(layoutHelper, SegmentType.Word).zipWithNext { start, end ->
+ val lineNo = layout.getLineForOffset(start, false /* downstream */)
+ val paraRTL = layout.getParagraphDirection(lineNo) == Layout.DIR_RIGHT_TO_LEFT
+ val runRtl = layout.isRtlCharAt(start) // no bidi transition inside segment
+ val startPos = ceil(
+ layoutHelper.getHorizontalPosition(
+ offset = start,
+ usePrimaryDirection = runRtl == paraRTL,
+ upstream = false
+ )
+ ).toInt()
+ val endPos = ceil(
+ layoutHelper.getHorizontalPosition(
+ offset = end,
+ usePrimaryDirection = runRtl == paraRTL,
+ upstream = true
+ )
+ ).toInt()
+
+ // Drop trailing space is the line does not end with this word.
+ var left = min(startPos, endPos)
+ var right = max(startPos, endPos)
+ if (dropSpaces && end != 0 && layout.text.get(end - 1) == ' ') {
+ val lineEnd = layout.getLineEnd(lineNo)
+ if (lineEnd != end) {
+ if (runRtl) {
+ left += wsWidth
+ } else {
+ right -= wsWidth
+ }
+ }
+ }
+
+ Segment(
+ startOffset = start,
+ endOffset = end,
+ left = left,
+ top = layout.getLineTop(lineNo),
+ right = right,
+ bottom = layout.getLineBottom(lineNo)
+ )
+ }
+ }
+
+ private fun breakSegmentWithChar(
+ layoutHelper: LayoutHelper,
+ dropSpaces: Boolean
+ ): List<Segment> {
+ val res = mutableListOf<Segment>()
+ breakOffsets(layoutHelper, SegmentType.Character).zipWithNext lambda@{ start, end ->
+ val layout = layoutHelper.layout
+
+ if (dropSpaces && end == start + 1 &&
+ layoutHelper.isLineEndSpace(layout.text.get(start)))
+ return@lambda
+ val lineNo = layout.getLineForOffset(start, false /* downstream */)
+ val paraRTL = layout.getParagraphDirection(lineNo) == Layout.DIR_RIGHT_TO_LEFT
+ val runRtl = layout.isRtlCharAt(start) // no bidi transition inside segment
+ val startPos = ceil(
+ layoutHelper.getHorizontalPosition(
+ offset = start,
+ usePrimaryDirection = runRtl == paraRTL,
+ upstream = false
+ )
+ ).toInt()
+ val endPos = ceil(
+ layoutHelper.getHorizontalPosition(
+ offset = end,
+ usePrimaryDirection = runRtl == paraRTL,
+ upstream = true
+ )
+ ).toInt()
+ res.add(Segment(
+ startOffset = start,
+ endOffset = end,
+ left = min(startPos, endPos),
+ top = layout.getLineTop(lineNo),
+ right = max(startPos, endPos),
+ bottom = layout.getLineBottom(lineNo)
+ ))
+ }
+ return res
+ }
}
\ No newline at end of file
diff --git a/ui/ui-text-core/build.gradle b/ui/ui-text-core/build.gradle
index 11e4a91a..b3586fd 100644
--- a/ui/ui-text-core/build.gradle
+++ b/ui/ui-text-core/build.gradle
@@ -54,7 +54,7 @@
}
androidTest.dependencies {
- implementation project(":ui:ui-test-font")
+ implementation project(":compose:core:core-test-font")
implementation(ANDROIDX_TEST_RULES)
implementation(ANDROIDX_TEST_RUNNER)
implementation(JUNIT)
@@ -67,7 +67,7 @@
}
androidAndroidTest.dependencies {
- implementation project(":ui:ui-test-font")
+ implementation project(":compose:core:core-test-font")
implementation(ANDROIDX_TEST_RULES)
implementation(ANDROIDX_TEST_RUNNER)
implementation(ESPRESSO_CORE)
diff --git a/ui/ui-text-core/src/androidMain/kotlin/androidx/ui/text/platform/AndroidParagraph.kt b/ui/ui-text-core/src/androidMain/kotlin/androidx/ui/text/platform/AndroidParagraph.kt
index c13d22a..af00d7f 100644
--- a/ui/ui-text-core/src/androidMain/kotlin/androidx/ui/text/platform/AndroidParagraph.kt
+++ b/ui/ui-text-core/src/androidMain/kotlin/androidx/ui/text/platform/AndroidParagraph.kt
@@ -341,10 +341,10 @@
else -> DEFAULT_ALIGNMENT
}
-// TODO(b/159152328): temporary workaround for ui-desktop. remove when full support of MPP will
+// TODO(b/159152328): temporary workaround for desktop. remove when full support of MPP will
// be in-place
@Deprecated(
- "Temporary workaround. Supposed to be used only in ui-desktop before MPP",
+ "Temporary workaround. Supposed to be used only in desktop before MPP",
level = DeprecationLevel.ERROR
)
@InternalPlatformTextApi
diff --git a/ui/ui-text-core/src/androidMain/kotlin/androidx/ui/text/platform/AndroidParagraphIntrinsics.kt b/ui/ui-text-core/src/androidMain/kotlin/androidx/ui/text/platform/AndroidParagraphIntrinsics.kt
index 4a63b8d..753a0eb 100644
--- a/ui/ui-text-core/src/androidMain/kotlin/androidx/ui/text/platform/AndroidParagraphIntrinsics.kt
+++ b/ui/ui-text-core/src/androidMain/kotlin/androidx/ui/text/platform/AndroidParagraphIntrinsics.kt
@@ -100,9 +100,9 @@
}
}
-// TODO(b/159152328): temporary workaround for ui-desktop. remove when full support of MPP will be in-place
+// TODO(b/159152328): temporary workaround for desktop. remove when full support of MPP will be in-place
@Deprecated(
- "Temporary workaround. Supposed to be used only in ui-desktop before MPP",
+ "Temporary workaround. Supposed to be used only in desktop before MPP",
level = DeprecationLevel.ERROR
)
@InternalPlatformTextApi
diff --git a/ui/ui-text/api/0.1.0-dev15.txt b/ui/ui-text/api/0.1.0-dev15.txt
index 14e11078..f84b79f 100644
--- a/ui/ui-text/api/0.1.0-dev15.txt
+++ b/ui/ui-text/api/0.1.0-dev15.txt
@@ -30,17 +30,16 @@
public final class TextSemanticsProperties {
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.input.ImeAction> getImeAction();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getSupportsInputMethods();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getSupportsInputMethods();
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.input.ImeAction> ImeAction;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> SupportsInputMethods;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> SupportsInputMethods;
field public static final androidx.ui.text.TextSemanticsProperties INSTANCE;
}
public final class TextSemanticsPropertiesKt {
method public static androidx.ui.input.ImeAction getImeAction(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getSupportsInputMethods(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static void setImeAction(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.input.ImeAction p);
- method public static void setSupportsInputMethods(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
+ method public static void supportsInputMethods(androidx.ui.semantics.SemanticsPropertyReceiver);
}
}
diff --git a/ui/ui-text/api/current.txt b/ui/ui-text/api/current.txt
index 14e11078..f84b79f 100644
--- a/ui/ui-text/api/current.txt
+++ b/ui/ui-text/api/current.txt
@@ -30,17 +30,16 @@
public final class TextSemanticsProperties {
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.input.ImeAction> getImeAction();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getSupportsInputMethods();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getSupportsInputMethods();
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.input.ImeAction> ImeAction;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> SupportsInputMethods;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> SupportsInputMethods;
field public static final androidx.ui.text.TextSemanticsProperties INSTANCE;
}
public final class TextSemanticsPropertiesKt {
method public static androidx.ui.input.ImeAction getImeAction(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getSupportsInputMethods(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static void setImeAction(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.input.ImeAction p);
- method public static void setSupportsInputMethods(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
+ method public static void supportsInputMethods(androidx.ui.semantics.SemanticsPropertyReceiver);
}
}
diff --git a/ui/ui-text/api/public_plus_experimental_0.1.0-dev15.txt b/ui/ui-text/api/public_plus_experimental_0.1.0-dev15.txt
index 14e11078..f84b79f 100644
--- a/ui/ui-text/api/public_plus_experimental_0.1.0-dev15.txt
+++ b/ui/ui-text/api/public_plus_experimental_0.1.0-dev15.txt
@@ -30,17 +30,16 @@
public final class TextSemanticsProperties {
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.input.ImeAction> getImeAction();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getSupportsInputMethods();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getSupportsInputMethods();
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.input.ImeAction> ImeAction;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> SupportsInputMethods;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> SupportsInputMethods;
field public static final androidx.ui.text.TextSemanticsProperties INSTANCE;
}
public final class TextSemanticsPropertiesKt {
method public static androidx.ui.input.ImeAction getImeAction(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getSupportsInputMethods(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static void setImeAction(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.input.ImeAction p);
- method public static void setSupportsInputMethods(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
+ method public static void supportsInputMethods(androidx.ui.semantics.SemanticsPropertyReceiver);
}
}
diff --git a/ui/ui-text/api/public_plus_experimental_current.txt b/ui/ui-text/api/public_plus_experimental_current.txt
index 14e11078..f84b79f 100644
--- a/ui/ui-text/api/public_plus_experimental_current.txt
+++ b/ui/ui-text/api/public_plus_experimental_current.txt
@@ -30,17 +30,16 @@
public final class TextSemanticsProperties {
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.input.ImeAction> getImeAction();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getSupportsInputMethods();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getSupportsInputMethods();
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.input.ImeAction> ImeAction;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> SupportsInputMethods;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> SupportsInputMethods;
field public static final androidx.ui.text.TextSemanticsProperties INSTANCE;
}
public final class TextSemanticsPropertiesKt {
method public static androidx.ui.input.ImeAction getImeAction(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getSupportsInputMethods(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static void setImeAction(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.input.ImeAction p);
- method public static void setSupportsInputMethods(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
+ method public static void supportsInputMethods(androidx.ui.semantics.SemanticsPropertyReceiver);
}
}
diff --git a/ui/ui-text/api/restricted_0.1.0-dev15.txt b/ui/ui-text/api/restricted_0.1.0-dev15.txt
index 14e11078..f84b79f 100644
--- a/ui/ui-text/api/restricted_0.1.0-dev15.txt
+++ b/ui/ui-text/api/restricted_0.1.0-dev15.txt
@@ -30,17 +30,16 @@
public final class TextSemanticsProperties {
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.input.ImeAction> getImeAction();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getSupportsInputMethods();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getSupportsInputMethods();
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.input.ImeAction> ImeAction;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> SupportsInputMethods;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> SupportsInputMethods;
field public static final androidx.ui.text.TextSemanticsProperties INSTANCE;
}
public final class TextSemanticsPropertiesKt {
method public static androidx.ui.input.ImeAction getImeAction(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getSupportsInputMethods(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static void setImeAction(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.input.ImeAction p);
- method public static void setSupportsInputMethods(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
+ method public static void supportsInputMethods(androidx.ui.semantics.SemanticsPropertyReceiver);
}
}
diff --git a/ui/ui-text/api/restricted_current.txt b/ui/ui-text/api/restricted_current.txt
index 14e11078..f84b79f 100644
--- a/ui/ui-text/api/restricted_current.txt
+++ b/ui/ui-text/api/restricted_current.txt
@@ -30,17 +30,16 @@
public final class TextSemanticsProperties {
method public androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.input.ImeAction> getImeAction();
- method public androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> getSupportsInputMethods();
+ method public androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> getSupportsInputMethods();
property public final androidx.ui.semantics.SemanticsPropertyKey<androidx.ui.input.ImeAction> ImeAction;
- property public final androidx.ui.semantics.SemanticsPropertyKey<java.lang.Boolean> SupportsInputMethods;
+ property public final androidx.ui.semantics.SemanticsPropertyKey<kotlin.Unit> SupportsInputMethods;
field public static final androidx.ui.text.TextSemanticsProperties INSTANCE;
}
public final class TextSemanticsPropertiesKt {
method public static androidx.ui.input.ImeAction getImeAction(androidx.ui.semantics.SemanticsPropertyReceiver);
- method public static boolean getSupportsInputMethods(androidx.ui.semantics.SemanticsPropertyReceiver);
method public static void setImeAction(androidx.ui.semantics.SemanticsPropertyReceiver, androidx.ui.input.ImeAction p);
- method public static void setSupportsInputMethods(androidx.ui.semantics.SemanticsPropertyReceiver, boolean p);
+ method public static void supportsInputMethods(androidx.ui.semantics.SemanticsPropertyReceiver);
}
}
diff --git a/ui/ui-text/build.gradle b/ui/ui-text/build.gradle
index 05bf9eb..9ec208c 100644
--- a/ui/ui-text/build.gradle
+++ b/ui/ui-text/build.gradle
@@ -62,7 +62,7 @@
androidAndroidTest.dependencies {
implementation project(":compose:test:test-core")
implementation project(":compose:foundation:foundation-layout")
- implementation project(":ui:ui-test-font")
+ implementation project(":compose:core:core-test-font")
implementation "androidx.core:core:1.5.0-alpha01"
implementation(ANDROIDX_TEST_RULES)
implementation(ANDROIDX_TEST_RUNNER)
diff --git a/ui/ui-text/integration-tests/ui-text-compose-demos/build.gradle b/ui/ui-text/integration-tests/ui-text-compose-demos/build.gradle
index 15dbd42..09ac3a3 100644
--- a/ui/ui-text/integration-tests/ui-text-compose-demos/build.gradle
+++ b/ui/ui-text/integration-tests/ui-text-compose-demos/build.gradle
@@ -15,7 +15,7 @@
implementation(KOTLIN_STDLIB)
implementation project(":compose:runtime:runtime")
- implementation project(":ui:integration-tests:demos:common")
+ implementation project(":compose:integration-tests:demos:common")
implementation project(":compose:core:core")
implementation project(":compose:foundation:foundation")
implementation project(":compose:foundation:foundation-layout")
diff --git a/ui/ui-text/src/commonMain/kotlin/androidx/ui/text/CoreTextField.kt b/ui/ui-text/src/commonMain/kotlin/androidx/ui/text/CoreTextField.kt
index 4c66d38..e50e07a 100644
--- a/ui/ui-text/src/commonMain/kotlin/androidx/ui/text/CoreTextField.kt
+++ b/ui/ui-text/src/commonMain/kotlin/androidx/ui/text/CoreTextField.kt
@@ -471,12 +471,11 @@
onBlur(false)
}
- val semantics = Modifier.semantics(
- properties = {
- this.imeAction = imeAction
- this.supportsInputMethods = true
- onClick(action = { doFocusIn(); return@onClick true })
- })
+ val semantics = Modifier.semantics {
+ this.imeAction = imeAction
+ this.supportsInputMethods()
+ onClick(action = { doFocusIn(); return@onClick true })
+ }
val drag = Modifier.dragPositionGestureFilter(
onPress = {
state.selectionIsOn = false
diff --git a/ui/ui-text/src/commonMain/kotlin/androidx/ui/text/TextSemanticsProperties.kt b/ui/ui-text/src/commonMain/kotlin/androidx/ui/text/TextSemanticsProperties.kt
index 6cab41f..d53c8d1 100644
--- a/ui/ui-text/src/commonMain/kotlin/androidx/ui/text/TextSemanticsProperties.kt
+++ b/ui/ui-text/src/commonMain/kotlin/androidx/ui/text/TextSemanticsProperties.kt
@@ -32,14 +32,14 @@
val ImeAction = SemanticsPropertyKey<ImeAction>("ImeAction")
/**
- * Return whether the node supports input methods.
+ * Whether the node supports input methods.
*
* Supporting input methods means that the node provides a connection to IME (keyboard) and
* is able to accept input from it. This is typically a text field for instance.
*
* @see SemanticsPropertyReceiver.supportsInputMethods
*/
- val SupportsInputMethods = SemanticsPropertyKey<Boolean>("SupportsInputMethods")
+ val SupportsInputMethods = SemanticsPropertyKey<Unit>("SupportsInputMethods")
}
/**
@@ -50,11 +50,13 @@
var SemanticsPropertyReceiver.imeAction by TextSemanticsProperties.ImeAction
/**
- * Return whether the component supports input methods.
+ * Whether the component supports input methods.
*
* Supporting input methods means that the component provides a connection to IME (keyboard) and
* is able to accept input from it. This is typically a text field for instance.
*
* @see TextSemanticsProperties.SupportsInputMethods
*/
-var SemanticsPropertyReceiver.supportsInputMethods by TextSemanticsProperties.SupportsInputMethods
\ No newline at end of file
+fun SemanticsPropertyReceiver.supportsInputMethods() {
+ this[TextSemanticsProperties.SupportsInputMethods] = Unit
+}
\ No newline at end of file
diff --git a/ui/ui-tooling/build.gradle b/ui/ui-tooling/build.gradle
index 748acaa..235c7e8 100644
--- a/ui/ui-tooling/build.gradle
+++ b/ui/ui-tooling/build.gradle
@@ -39,8 +39,8 @@
api(project(":compose:core:core"))
implementation(project(":compose:material:material"))
- // kotlin-reflect and ui-animation-tooling-internal are provided by Studio at runtime
- compileOnly(project(":ui:ui-animation-tooling-internal"))
+ // kotlin-reflect and tooling-animation-internal are provided by Studio at runtime
+ compileOnly(project(":compose:tooling:tooling-animation-internal"))
compileOnly(KOTLIN_REFLECT)
compileOnly(KOTLIN_METADATA_JVM)
@@ -54,7 +54,7 @@
androidTestImplementation(TRUTH)
androidTestImplementation(KOTLIN_REFLECT)
androidTestImplementation(KOTLIN_METADATA_JVM)
- androidTestImplementation(project(":ui:ui-animation-tooling-internal"))
+ androidTestImplementation(project(":compose:tooling:tooling-animation-internal"))
}
// Workaround for https://youtrack.jetbrains.com/issue/KT-39813
diff --git a/ui/ui/placeholder.txt b/ui/ui/placeholder.txt
deleted file mode 100644
index ffee342..0000000
--- a/ui/ui/placeholder.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-This file exists to make sure ui/ directory this is in gets created by git, so that
-settings.gradle can point to this directory and not complain about it missing.
\ No newline at end of file
diff --git a/work/workmanager-inspection/src/androidTest/java/androidx/work/inspection/BasicTest.kt b/work/workmanager-inspection/src/androidTest/java/androidx/work/inspection/BasicTest.kt
index 52b86f3..af939ff 100644
--- a/work/workmanager-inspection/src/androidTest/java/androidx/work/inspection/BasicTest.kt
+++ b/work/workmanager-inspection/src/androidTest/java/androidx/work/inspection/BasicTest.kt
@@ -18,6 +18,10 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
+import androidx.work.inspection.WorkManagerInspectorProtocol.Command
+import androidx.work.inspection.WorkManagerInspectorProtocol.TrackWorkManagerCommand
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.runBlocking
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -33,4 +37,25 @@
// no crash means the inspector was successfully injected
testEnvironment.assertNoQueuedEvents()
}
+
+ @Test
+ fun sendUnsetCommand() = runBlocking {
+ testEnvironment.sendCommand(Command.getDefaultInstance())
+ .let { response ->
+ assertThat(response.hasError()).isEqualTo(true)
+ assertThat(response.error.content)
+ .contains("Unrecognised command type: ONEOF_NOT_SET")
+ }
+ }
+
+ @Test
+ fun sendTrackWorkManagerCommand() = runBlocking {
+ val trackCommand = TrackWorkManagerCommand.getDefaultInstance()
+ testEnvironment.sendCommand(
+ Command.newBuilder().setTrackWorkManager(trackCommand).build()
+ )
+ .let { response ->
+ assertThat(response.hasTrackWorkManager()).isEqualTo(true)
+ }
+ }
}
diff --git a/work/workmanager-inspection/src/androidTest/java/androidx/work/inspection/WorkManagerInspectorTestEnvironment.kt b/work/workmanager-inspection/src/androidTest/java/androidx/work/inspection/WorkManagerInspectorTestEnvironment.kt
index 3ebcaeb..e1d827a 100644
--- a/work/workmanager-inspection/src/androidTest/java/androidx/work/inspection/WorkManagerInspectorTestEnvironment.kt
+++ b/work/workmanager-inspection/src/androidTest/java/androidx/work/inspection/WorkManagerInspectorTestEnvironment.kt
@@ -16,10 +16,13 @@
package androidx.work.inspection
-import androidx.inspection.InspectorEnvironment
+import android.app.Application
import androidx.inspection.testing.DefaultTestInspectorEnvironment
import androidx.inspection.testing.InspectorTester
import androidx.inspection.testing.TestInspectorExecutors
+import androidx.test.platform.app.InstrumentationRegistry
+import androidx.work.inspection.WorkManagerInspectorProtocol.Command
+import androidx.work.inspection.WorkManagerInspectorProtocol.Response
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job
@@ -36,6 +39,11 @@
override fun before() {
environment = FakeInspectorEnvironment(job)
+ val application = InstrumentationRegistry
+ .getInstrumentation()
+ .targetContext
+ .applicationContext as Application
+ registerApplication(application)
inspectorTester = runBlocking {
InspectorTester(
inspectorId = WORK_MANAGER_INSPECTOR_ID,
@@ -55,31 +63,38 @@
fun assertNoQueuedEvents() {
assertThat(inspectorTester.channel.isEmpty).isTrue()
}
+
+ suspend fun sendCommand(command: Command): Response {
+ inspectorTester.sendCommand(command.toByteArray())
+ .let { responseBytes ->
+ assertThat(responseBytes).isNotEmpty()
+ return Response.parseFrom(responseBytes)
+ }
+ }
+
+ private fun registerApplication(application: Application) {
+ environment.registerInstancesToFind(listOf(application))
+ }
}
/**
- * Empty Fake inspector environment.
+ * Fake inspector environment with the following behaviour:
+ * - [findInstances] returns pre-registered values from [registerInstancesToFind].
*/
private class FakeInspectorEnvironment(
job: Job
) : DefaultTestInspectorEnvironment(TestInspectorExecutors(job)) {
- override fun <T : Any?> findInstances(clazz: Class<T>): MutableList<T> {
- TODO("not implemented")
+ private val instancesToFind = mutableListOf<Any>()
+
+ fun registerInstancesToFind(instances: List<Any>) {
+ instancesToFind.addAll(instances)
}
- override fun registerEntryHook(
- originClass: Class<*>,
- originMethod: String,
- entryHook: InspectorEnvironment.EntryHook
- ) {
- TODO("not implemented")
- }
-
- override fun <T : Any?> registerExitHook(
- originClass: Class<*>,
- originMethod: String,
- exitHook: InspectorEnvironment.ExitHook<T>
- ) {
- TODO("not implemented")
- }
+ /**
+ * Returns instances pre-registered in [registerInstancesToFind].
+ * By design crashes in case of the wrong setup - indicating an issue with test code.
+ */
+ @Suppress("UNCHECKED_CAST")
+ override fun <T : Any?> findInstances(clazz: Class<T>): List<T> =
+ instancesToFind.filter { clazz.isInstance(it) }.map { it as T }.toList()
}
diff --git a/work/workmanager-inspection/src/main/java/androidx/work/inspection/WorkManagerInspector.kt b/work/workmanager-inspection/src/main/java/androidx/work/inspection/WorkManagerInspector.kt
index ae8b797..8cce26d 100644
--- a/work/workmanager-inspection/src/main/java/androidx/work/inspection/WorkManagerInspector.kt
+++ b/work/workmanager-inspection/src/main/java/androidx/work/inspection/WorkManagerInspector.kt
@@ -16,14 +16,50 @@
package androidx.work.inspection
+import android.app.Application
import androidx.inspection.Connection
import androidx.inspection.Inspector
import androidx.inspection.InspectorEnvironment
+import androidx.work.WorkManager
+import androidx.work.inspection.WorkManagerInspectorProtocol.Command
+import androidx.work.inspection.WorkManagerInspectorProtocol.Command.OneOfCase.TRACK_WORK_MANAGER
+import androidx.work.inspection.WorkManagerInspectorProtocol.ErrorResponse
+import androidx.work.inspection.WorkManagerInspectorProtocol.Response
+import androidx.work.inspection.WorkManagerInspectorProtocol.TrackWorkManagerResponse
+/**
+ * Inspector to work with WorkManager
+ */
class WorkManagerInspector(
connection: Connection,
- private val environment: InspectorEnvironment
+ environment: InspectorEnvironment
) : Inspector(connection) {
+
+ private val workManager: WorkManager
+
+ init {
+ workManager = environment.findInstances(Application::class.java).first()
+ .let { application -> WorkManager.getInstance(application) }
+ }
+
override fun onReceiveCommand(data: ByteArray, callback: CommandCallback) {
+ val command = Command.parseFrom(data)
+ when (command.oneOfCase) {
+ TRACK_WORK_MANAGER -> {
+ val response = Response.newBuilder()
+ .setTrackWorkManager(TrackWorkManagerResponse.getDefaultInstance())
+ .build()
+ callback.reply(response.toByteArray())
+ }
+ else -> {
+ val errorResponse = ErrorResponse.newBuilder()
+ .setContent("Unrecognised command type: ONEOF_NOT_SET")
+ .build()
+ val response = Response.newBuilder()
+ .setError(errorResponse)
+ .build()
+ callback.reply(response.toByteArray())
+ }
+ }
}
}
diff --git a/work/workmanager-inspection/src/main/proto/workmanager_protocol.proto b/work/workmanager-inspection/src/main/proto/workmanager_protocol.proto
new file mode 100644
index 0000000..0fd93c0
--- /dev/null
+++ b/work/workmanager-inspection/src/main/proto/workmanager_protocol.proto
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * 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.
+ */
+
+syntax = "proto3";
+
+package androidx.work.inspection;
+
+option java_package = "androidx.work.inspection";
+option java_outer_classname = "WorkManagerInspectorProtocol";
+
+// --- Commands ---
+
+// Generic Command object grouping all Inspector Command types. Expected in
+// Inspector's onReceiveCommand.
+message Command {
+ // Wrapped specialised Command.
+ oneof OneOf {
+ TrackWorkManagerCommand track_work_manager = 1;
+ }
+}
+
+// Request for the Inspector to listen to the WorkManager
+// for work related updates.
+message TrackWorkManagerCommand {}
+
+// --- Responses ---
+
+// Generic Response object grouping all Inspector Response types to Command
+// objects.
+message Response {
+ oneof OneOf {
+ TrackWorkManagerResponse track_work_manager = 1;
+ ErrorResponse error = 400;
+ }
+}
+
+// Object expected as a response to TrackWorkManagerCommand.
+message TrackWorkManagerResponse {}
+
+// General Error message.
+message ErrorResponse {
+ string content = 1;
+}