Skip to content

Commit 7d623c0

Browse files
committed
chore: tests folder structure
1 parent 0d82846 commit 7d623c0

File tree

3 files changed

+43
-74
lines changed

3 files changed

+43
-74
lines changed

auth/src/test/java/com/firebase/ui/auth/compose/AuthProviderButtonTest.kt renamed to auth/src/test/java/com/firebase/ui/auth/compose/ui/components/AuthProviderButtonTest.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* limitations under the License.
1313
*/
1414

15-
package com.firebase.ui.auth.compose
15+
package com.firebase.ui.auth.compose.ui.components
1616

1717
import android.content.Context
1818
import androidx.compose.material.icons.Icons
@@ -41,8 +41,6 @@ import org.junit.runner.RunWith
4141
import org.robolectric.RobolectricTestRunner
4242
import org.robolectric.annotation.Config
4343
import com.firebase.ui.auth.R
44-
import com.firebase.ui.auth.compose.ui.components.AuthProviderButton
45-
import com.firebase.ui.auth.compose.ui.components.resolveProviderStyle
4644

4745
/**
4846
* Unit tests for [AuthProviderButton] covering UI interactions, styling,

auth/src/test/java/com/firebase/ui/auth/compose/ErrorRecoveryDialogLogicTest.kt renamed to auth/src/test/java/com/firebase/ui/auth/compose/ui/components/ErrorRecoveryDialogLogicTest.kt

Lines changed: 36 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,35 @@
1-
/*
2-
* Copyright 2025 Google Inc. All Rights Reserved.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5-
* in compliance with the License. You may obtain a copy of the License at
6-
*
7-
* http://www.apache.org/licenses/LICENSE-2.0
8-
*
9-
* Unless required by applicable law or agreed to in writing, software distributed under the
10-
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11-
* express or implied. See the License for the specific language governing permissions and
12-
* limitations under the License.
13-
*/
14-
15-
package com.firebase.ui.auth.compose
1+
package com.firebase.ui.auth.compose.ui.components
162

3+
import com.firebase.ui.auth.compose.AuthException
174
import com.firebase.ui.auth.compose.configuration.string_provider.AuthUIStringProvider
18-
import com.google.common.truth.Truth.assertThat
5+
import com.google.common.truth.Truth
196
import org.junit.Test
207
import org.junit.runner.RunWith
21-
import org.mockito.Mockito.mock
22-
import org.mockito.Mockito.`when`
8+
import org.mockito.Mockito
239
import org.robolectric.RobolectricTestRunner
2410
import org.robolectric.annotation.Config
2511

2612
/**
27-
* Unit tests for [com.firebase.ui.auth.compose.ui.components.ErrorRecoveryDialog] logic functions.
13+
* Unit tests for [ErrorRecoveryDialog] logic functions.
2814
*/
2915
@RunWith(RobolectricTestRunner::class)
3016
@Config(manifest = Config.NONE)
3117
class ErrorRecoveryDialogLogicTest {
3218

33-
private val mockStringProvider = mock(AuthUIStringProvider::class.java).apply {
34-
`when`(retryAction).thenReturn("Try again")
35-
`when`(continueText).thenReturn("Continue")
36-
`when`(signInDefault).thenReturn("Sign in")
37-
`when`(networkErrorRecoveryMessage).thenReturn("Network error, check your internet connection.")
38-
`when`(invalidCredentialsRecoveryMessage).thenReturn("Incorrect password.")
39-
`when`(userNotFoundRecoveryMessage).thenReturn("That email address doesn't match an existing account")
40-
`when`(weakPasswordRecoveryMessage).thenReturn("Password not strong enough. Use at least 6 characters and a mix of letters and numbers")
41-
`when`(emailAlreadyInUseRecoveryMessage).thenReturn("Email account registration unsuccessful")
42-
`when`(tooManyRequestsRecoveryMessage).thenReturn("This phone number has been used too many times")
43-
`when`(mfaRequiredRecoveryMessage).thenReturn("Additional verification required. Please complete multi-factor authentication.")
44-
`when`(accountLinkingRequiredRecoveryMessage).thenReturn("Account needs to be linked. Please try a different sign-in method.")
45-
`when`(authCancelledRecoveryMessage).thenReturn("Authentication was cancelled. Please try again when ready.")
46-
`when`(unknownErrorRecoveryMessage).thenReturn("An unknown error occurred.")
19+
private val mockStringProvider = Mockito.mock(AuthUIStringProvider::class.java).apply {
20+
Mockito.`when`(retryAction).thenReturn("Try again")
21+
Mockito.`when`(continueText).thenReturn("Continue")
22+
Mockito.`when`(signInDefault).thenReturn("Sign in")
23+
Mockito.`when`(networkErrorRecoveryMessage).thenReturn("Network error, check your internet connection.")
24+
Mockito.`when`(invalidCredentialsRecoveryMessage).thenReturn("Incorrect password.")
25+
Mockito.`when`(userNotFoundRecoveryMessage).thenReturn("That email address doesn't match an existing account")
26+
Mockito.`when`(weakPasswordRecoveryMessage).thenReturn("Password not strong enough. Use at least 6 characters and a mix of letters and numbers")
27+
Mockito.`when`(emailAlreadyInUseRecoveryMessage).thenReturn("Email account registration unsuccessful")
28+
Mockito.`when`(tooManyRequestsRecoveryMessage).thenReturn("This phone number has been used too many times")
29+
Mockito.`when`(mfaRequiredRecoveryMessage).thenReturn("Additional verification required. Please complete multi-factor authentication.")
30+
Mockito.`when`(accountLinkingRequiredRecoveryMessage).thenReturn("Account needs to be linked. Please try a different sign-in method.")
31+
Mockito.`when`(authCancelledRecoveryMessage).thenReturn("Authentication was cancelled. Please try again when ready.")
32+
Mockito.`when`(unknownErrorRecoveryMessage).thenReturn("An unknown error occurred.")
4733
}
4834

4935
// =============================================================================================
@@ -59,7 +45,7 @@ class ErrorRecoveryDialogLogicTest {
5945
val message = getRecoveryMessage(error, mockStringProvider)
6046

6147
// Assert
62-
assertThat(message).isEqualTo("Network error, check your internet connection.")
48+
Truth.assertThat(message).isEqualTo("Network error, check your internet connection.")
6349
}
6450

6551
@Test
@@ -71,7 +57,7 @@ class ErrorRecoveryDialogLogicTest {
7157
val message = getRecoveryMessage(error, mockStringProvider)
7258

7359
// Assert
74-
assertThat(message).isEqualTo("Incorrect password.")
60+
Truth.assertThat(message).isEqualTo("Incorrect password.")
7561
}
7662

7763
@Test
@@ -83,7 +69,7 @@ class ErrorRecoveryDialogLogicTest {
8369
val message = getRecoveryMessage(error, mockStringProvider)
8470

8571
// Assert
86-
assertThat(message).isEqualTo("That email address doesn't match an existing account")
72+
Truth.assertThat(message).isEqualTo("That email address doesn't match an existing account")
8773
}
8874

8975
@Test
@@ -99,7 +85,7 @@ class ErrorRecoveryDialogLogicTest {
9985
val message = getRecoveryMessage(error, mockStringProvider)
10086

10187
// Assert
102-
assertThat(message).isEqualTo("Password not strong enough. Use at least 6 characters and a mix of letters and numbers\n\nReason: Password should be at least 8 characters")
88+
Truth.assertThat(message).isEqualTo("Password not strong enough. Use at least 6 characters and a mix of letters and numbers\n\nReason: Password should be at least 8 characters")
10389
}
10490

10591
@Test
@@ -111,7 +97,7 @@ class ErrorRecoveryDialogLogicTest {
11197
val message = getRecoveryMessage(error, mockStringProvider)
11298

11399
// Assert
114-
assertThat(message).isEqualTo("Password not strong enough. Use at least 6 characters and a mix of letters and numbers")
100+
Truth.assertThat(message).isEqualTo("Password not strong enough. Use at least 6 characters and a mix of letters and numbers")
115101
}
116102

117103
@Test
@@ -127,7 +113,7 @@ class ErrorRecoveryDialogLogicTest {
127113
val message = getRecoveryMessage(error, mockStringProvider)
128114

129115
// Assert
130-
assertThat(message).isEqualTo("Email account registration unsuccessful ([email protected])")
116+
Truth.assertThat(message).isEqualTo("Email account registration unsuccessful ([email protected])")
131117
}
132118

133119
@Test
@@ -139,7 +125,7 @@ class ErrorRecoveryDialogLogicTest {
139125
val message = getRecoveryMessage(error, mockStringProvider)
140126

141127
// Assert
142-
assertThat(message).isEqualTo("Email account registration unsuccessful")
128+
Truth.assertThat(message).isEqualTo("Email account registration unsuccessful")
143129
}
144130

145131
// =============================================================================================
@@ -155,7 +141,7 @@ class ErrorRecoveryDialogLogicTest {
155141
val actionText = getRecoveryActionText(error, mockStringProvider)
156142

157143
// Assert
158-
assertThat(actionText).isEqualTo("Try again")
144+
Truth.assertThat(actionText).isEqualTo("Try again")
159145
}
160146

161147
@Test
@@ -167,7 +153,7 @@ class ErrorRecoveryDialogLogicTest {
167153
val actionText = getRecoveryActionText(error, mockStringProvider)
168154

169155
// Assert
170-
assertThat(actionText).isEqualTo("Continue")
156+
Truth.assertThat(actionText).isEqualTo("Continue")
171157
}
172158

173159
@Test
@@ -179,7 +165,7 @@ class ErrorRecoveryDialogLogicTest {
179165
val actionText = getRecoveryActionText(error, mockStringProvider)
180166

181167
// Assert
182-
assertThat(actionText).isEqualTo("Sign in")
168+
Truth.assertThat(actionText).isEqualTo("Sign in")
183169
}
184170

185171
@Test
@@ -191,7 +177,7 @@ class ErrorRecoveryDialogLogicTest {
191177
val actionText = getRecoveryActionText(error, mockStringProvider)
192178

193179
// Assert
194-
assertThat(actionText).isEqualTo("Continue")
180+
Truth.assertThat(actionText).isEqualTo("Continue")
195181
}
196182

197183
@Test
@@ -203,7 +189,7 @@ class ErrorRecoveryDialogLogicTest {
203189
val actionText = getRecoveryActionText(error, mockStringProvider)
204190

205191
// Assert
206-
assertThat(actionText).isEqualTo("Continue")
192+
Truth.assertThat(actionText).isEqualTo("Continue")
207193
}
208194

209195
// =============================================================================================
@@ -216,7 +202,7 @@ class ErrorRecoveryDialogLogicTest {
216202
val error = AuthException.NetworkException("Network error")
217203

218204
// Act & Assert
219-
assertThat(isRecoverable(error)).isTrue()
205+
Truth.assertThat(isRecoverable(error)).isTrue()
220206
}
221207

222208
@Test
@@ -225,7 +211,7 @@ class ErrorRecoveryDialogLogicTest {
225211
val error = AuthException.InvalidCredentialsException("Invalid credentials")
226212

227213
// Act & Assert
228-
assertThat(isRecoverable(error)).isTrue()
214+
Truth.assertThat(isRecoverable(error)).isTrue()
229215
}
230216

231217
@Test
@@ -234,7 +220,7 @@ class ErrorRecoveryDialogLogicTest {
234220
val error = AuthException.TooManyRequestsException("Too many requests")
235221

236222
// Act & Assert
237-
assertThat(isRecoverable(error)).isFalse()
223+
Truth.assertThat(isRecoverable(error)).isFalse()
238224
}
239225

240226
@Test
@@ -243,7 +229,7 @@ class ErrorRecoveryDialogLogicTest {
243229
val error = AuthException.MfaRequiredException("MFA required")
244230

245231
// Act & Assert
246-
assertThat(isRecoverable(error)).isTrue()
232+
Truth.assertThat(isRecoverable(error)).isTrue()
247233
}
248234

249235
@Test
@@ -252,7 +238,7 @@ class ErrorRecoveryDialogLogicTest {
252238
val error = AuthException.UnknownException("Unknown error")
253239

254240
// Act & Assert
255-
assertThat(isRecoverable(error)).isTrue()
241+
Truth.assertThat(isRecoverable(error)).isTrue()
256242
}
257243

258244
// Helper functions to test the private functions - we need to make them internal for testing

auth/src/test/java/com/firebase/ui/auth/compose/AuthMethodPickerTest.kt renamed to auth/src/test/java/com/firebase/ui/auth/compose/ui/method_picker/AuthMethodPickerTest.kt

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
1-
/*
2-
* Copyright 2025 Google Inc. All Rights Reserved.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5-
* in compliance with the License. You may obtain a copy of the License at
6-
*
7-
* http://www.apache.org/licenses/LICENSE-2.0
8-
*
9-
* Unless required by applicable law or agreed to in writing, software distributed under the
10-
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11-
* express or implied. See the License for the specific language governing permissions and
12-
* limitations under the License.
13-
*/
14-
15-
package com.firebase.ui.auth.compose
1+
package com.firebase.ui.auth.compose.ui.method_picker
162

173
import android.content.Context
184
import androidx.compose.material3.Button
@@ -31,8 +17,7 @@ import androidx.test.core.app.ApplicationProvider
3117
import com.firebase.ui.auth.R
3218
import com.firebase.ui.auth.compose.configuration.AuthProvider
3319
import com.firebase.ui.auth.compose.configuration.theme.AuthUIAsset
34-
import com.firebase.ui.auth.compose.ui.method_picker.AuthMethodPicker
35-
import com.google.common.truth.Truth.assertThat
20+
import com.google.common.truth.Truth
3621
import org.junit.Before
3722
import org.junit.Rule
3823
import org.junit.Test
@@ -202,7 +187,7 @@ class AuthMethodPickerTest {
202187
.onNodeWithText(context.getString(R.string.fui_sign_in_with_google))
203188
.performClick()
204189

205-
assertThat(selectedProvider).isEqualTo(googleProvider)
190+
Truth.assertThat(selectedProvider).isEqualTo(googleProvider)
206191
}
207192

208193
// =============================================================================================
@@ -227,7 +212,7 @@ class AuthMethodPickerTest {
227212
)
228213
}
229214

230-
assertThat(customLayoutCalled).isTrue()
215+
Truth.assertThat(customLayoutCalled).isTrue()
231216
composeTestRule
232217
.onNodeWithText("Custom Layout")
233218
.assertIsDisplayed()
@@ -251,7 +236,7 @@ class AuthMethodPickerTest {
251236
)
252237
}
253238

254-
assertThat(receivedProviders).isEqualTo(providers)
239+
Truth.assertThat(receivedProviders).isEqualTo(providers)
255240
}
256241

257242
@Test
@@ -275,7 +260,7 @@ class AuthMethodPickerTest {
275260
.onNodeWithText("Custom Button")
276261
.performClick()
277262

278-
assertThat(selectedProvider).isEqualTo(googleProvider)
263+
Truth.assertThat(selectedProvider).isEqualTo(googleProvider)
279264
}
280265

281266
// =============================================================================================

0 commit comments

Comments
 (0)