Fixed
Status Update
Comments
da...@gmail.com <da...@gmail.com> #2
When building a test worker using TestListenableWorkerBuilder the worker factory set using setWorkerFactory is only use to create WorkerParameters and the defaultFactory is used to build the Worker instance.
```
val workerBuilder = TestWorkerBuilder(applicationContext, executor)
workerBuilder.setWorkerFactory(object: WorkerFactory() {
override fun createWorker(
appContext: Context, workerClassName: String, workerParameters: WorkerParameters
): ListenableWorker? = MyWorker(appContext, workerParameters, dependency)
})
```
TestListenableWorkerBuilder.build() should call and use `getWorkerFactory()` and fallback to WorkerFactory.getDefaultWorkerFactory();
```
val workerBuilder = TestWorkerBuilder(applicationContext, executor)
workerBuilder.setWorkerFactory(object: WorkerFactory() {
override fun createWorker(
appContext: Context, workerClassName: String, workerParameters: WorkerParameters
): ListenableWorker? = MyWorker(appContext, workerParameters, dependency)
})
```
TestListenableWorkerBuilder.build() should call and use `getWorkerFactory()` and fallback to WorkerFactory.getDefaultWorkerFactory();
ra...@google.com <ra...@google.com>
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 79a9f772da4adcac1bfc11ea0ace9e16badc0858
Author: Rahul Ravikumar <rahulrav@google.com>
Date: Mon Jun 17 13:25:28 2019
Use the correct WorkerFactory when creating an instance of a ListenableWorker.
Fixes: b/135275844
Test: Added unit tests.
Change-Id: I1aed7adf4aabad3c011ead6afb1ce38081ef7d86
M work/workmanager-testing/src/androidTest/java/androidx/work/testing/TestWorkerBuilderTest.kt
M work/workmanager-testing/src/main/java/androidx/work/testing/TestListenableWorkerBuilder.java
https://android-review.googlesource.com/984775
https://goto.google.com/android-sha1/79a9f772da4adcac1bfc11ea0ace9e16badc0858
Branch: androidx-master-dev
commit 79a9f772da4adcac1bfc11ea0ace9e16badc0858
Author: Rahul Ravikumar <rahulrav@google.com>
Date: Mon Jun 17 13:25:28 2019
Use the correct WorkerFactory when creating an instance of a ListenableWorker.
Fixes:
Test: Added unit tests.
Change-Id: I1aed7adf4aabad3c011ead6afb1ce38081ef7d86
M work/workmanager-testing/src/androidTest/java/androidx/work/testing/TestWorkerBuilderTest.kt
M work/workmanager-testing/src/main/java/androidx/work/testing/TestListenableWorkerBuilder.java
Description
Version used: 2.1.0-beta01
```
If this is a bug in the library, we would appreciate if you could attach:
- Sample project to trigger the issue.
- A screenrecord or screenshots showing the issue (if UI related).