Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate ActivityStarter.startForResult() with no args #2466

Merged
merged 1 commit into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
@LargeTest
class AddFpxPaymentMethodTest {

private val context: Context by lazy {
ApplicationProvider.getApplicationContext<Context>()
}
private val context = ApplicationProvider.getApplicationContext<Context>()

@get:Rule
val activityScenarioRule: ActivityScenarioRule<LauncherActivity> = activityScenarioRule()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class CustomerSessionActivity : AppCompatActivity() {
}

private fun launchWithCustomer() {
PaymentMethodsActivityStarter(this).startForResult()
PaymentMethodsActivityStarter(this)
.startForResult(PaymentMethodsActivityStarter.Args.Builder().build())
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ abstract class ActivityStarter<TargetActivityType : Activity, ArgsType : Activit
requestCode: Int
) : this(
activity = activity,
fragment = null,
targetClass = targetClass,
defaultArgs = args,
requestCode = requestCode
Expand All @@ -44,8 +45,12 @@ abstract class ActivityStarter<TargetActivityType : Activity, ArgsType : Activit
requestCode = requestCode
)

@JvmOverloads
fun startForResult(args: ArgsType = defaultArgs) {
@Deprecated("startForResult() requires an args parameter")
fun startForResult() {
startForResult(defaultArgs)
}

fun startForResult(args: ArgsType) {
val intent = Intent(activity, targetClass)
.putExtra(Args.EXTRA, args)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ class PaymentSessionTest {
callback: (ActivityScenario<out ComponentActivity>) -> Unit
) {
activityScenarioFactory.create<PaymentMethodsActivity>(
PaymentMethodsActivityStarter.Args.DEFAULT
PaymentMethodsActivityStarter.Args.Builder().build()
).use(callback)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ import org.robolectric.RobolectricTestRunner

@RunWith(RobolectricTestRunner::class)
class StripePaymentAuthTest {

private val context: Context by lazy {
ApplicationProvider.getApplicationContext<Context>()
}
private val context = ApplicationProvider.getApplicationContext<Context>()

private val activity: Activity = mock()
private val paymentController: PaymentController = mock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ import org.robolectric.RobolectricTestRunner
@RunWith(RobolectricTestRunner::class)
class AddPaymentMethodViewModelTest {

private val context: Context by lazy {
ApplicationProvider.getApplicationContext<Context>()
}
private val context = ApplicationProvider.getApplicationContext<Context>()

private val customerSession: CustomerSession = mock()
private val paymentMethodRetrievalCaptor: KArgumentCaptor<CustomerSession.PaymentMethodRetrievalListener> = argumentCaptor()
Expand Down Expand Up @@ -123,7 +121,7 @@ class AddPaymentMethodViewModelTest {
return AddPaymentMethodViewModel(
stripe,
customerSession,
AddPaymentMethodActivityStarter.Args.DEFAULT,
AddPaymentMethodActivityStarter.Args.Builder().build(),
translator
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,8 @@ class PaymentFlowActivityTest {
private val shippingInformationValidator: PaymentSessionConfig.ShippingInformationValidator = mock()
private val shippingMethodsFactory: PaymentSessionConfig.ShippingMethodsFactory = mock()

private val context: Context by lazy {
ApplicationProvider.getApplicationContext<Context>()
}
private val activityScenarioFactory: ActivityScenarioFactory by lazy {
ActivityScenarioFactory(ApplicationProvider.getApplicationContext())
}
private val context = ApplicationProvider.getApplicationContext<Context>()
private val activityScenarioFactory = ActivityScenarioFactory(context)

@BeforeTest
fun setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ class PaymentMethodsAdapterTest {

private val paymentMethodsAdapter: PaymentMethodsAdapter = PaymentMethodsAdapter(ARGS)

private val context: Context by lazy {
ApplicationProvider.getApplicationContext<Context>()
}
private val context = ApplicationProvider.getApplicationContext<Context>()

@BeforeTest
fun setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,8 @@ class ShippingInfoWidgetTest {

private val ephemeralKeyProvider: EphemeralKeyProvider = mock()

private val context: Context by lazy {
ApplicationProvider.getApplicationContext<Context>()
}

private val activityScenarioFactory: ActivityScenarioFactory by lazy {
ActivityScenarioFactory(context)
}
private val context = ApplicationProvider.getApplicationContext<Context>()
private val activityScenarioFactory = ActivityScenarioFactory(context)

@BeforeTest
fun setup() {
Expand Down