Skip to content

Commit 6f3eb8c

Browse files
authored
Merge pull request #161 from takahirom/refactor/naming-consistency
Rename CreationViewModel.startClicked to onStartClicked
2 parents 02ad25c + 2730419 commit 6f3eb8c

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

feature/creation/src/main/java/com/android/developers/androidify/creation/CreationScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fun CreationScreen(
8989
onUndoPressed = creationViewModel::onUndoPressed,
9090
onPromptGenerationPressed = creationViewModel::onPromptGenerationClicked,
9191
onBotColorSelected = creationViewModel::onBotColorChanged,
92-
onStartClicked = creationViewModel::startClicked,
92+
onStartClicked = creationViewModel::onStartClicked,
9393
onDropCallback = creationViewModel::onImageSelected,
9494
)
9595
}

feature/creation/src/main/java/com/android/developers/androidify/creation/CreationViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class CreationViewModel @AssistedInject constructor(
132132
}
133133
}
134134

135-
fun startClicked() {
135+
fun onStartClicked() {
136136
imageGenerationJob?.cancel()
137137
imageGenerationJob = viewModelScope.launch {
138138
if (internetConnectivityManager.isInternetAvailable()) {

feature/creation/src/test/kotlin/com/android/developers/androidify/creation/CreationViewModelTest.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class CreationViewModelTest {
130130
}
131131

132132
@Test
133-
fun startClicked_GenerateBotFromPhoto() = runTest {
133+
fun onStartClicked_GenerateBotFromPhoto() = runTest {
134134
val screenStateValues = mutableListOf<ScreenState>()
135135
backgroundScope.launch(UnconfinedTestDispatcher()) {
136136
viewModel.uiState.collect {
@@ -140,13 +140,13 @@ class CreationViewModelTest {
140140

141141
viewModel.onImageSelected(Uri.parse("content://test/image.jpg"))
142142
viewModel.onSelectedPromptOptionChanged(PromptType.PHOTO)
143-
viewModel.startClicked()
143+
viewModel.onStartClicked()
144144
assertEquals(ScreenState.EDIT, viewModel.uiState.value.screenState)
145145
assertNotNull(viewModel.uiState.value.resultBitmapUri)
146146
}
147147

148148
@Test
149-
fun startClicked_GenerateBotFromPhoto_NoPhotoSelected() = runTest {
149+
fun onStartClicked_GenerateBotFromPhoto_NoPhotoSelected() = runTest {
150150
val values = mutableListOf<SnackbarHostState>()
151151

152152
backgroundScope.launch(UnconfinedTestDispatcher()) {
@@ -156,7 +156,7 @@ class CreationViewModelTest {
156156
}
157157

158158
viewModel.onSelectedPromptOptionChanged(PromptType.PHOTO)
159-
viewModel.startClicked()
159+
viewModel.onStartClicked()
160160
assertEquals(ScreenState.EDIT, viewModel.uiState.value.screenState)
161161
assertNotNull(
162162
"Choose an image or use a prompt instead.",
@@ -165,7 +165,7 @@ class CreationViewModelTest {
165165
}
166166

167167
@Test
168-
fun startClicked_GenerateBotFromPrompt_TextEmpty() = runTest {
168+
fun onStartClicked_GenerateBotFromPrompt_TextEmpty() = runTest {
169169
val values = mutableListOf<SnackbarHostState>()
170170

171171
backgroundScope.launch(UnconfinedTestDispatcher()) {
@@ -182,7 +182,7 @@ class CreationViewModelTest {
182182
imageGenerationRepository.exceptionToThrow = InsufficientInformationException()
183183

184184
viewModel.onSelectedPromptOptionChanged(PromptType.TEXT)
185-
viewModel.startClicked()
185+
viewModel.onStartClicked()
186186

187187
assertEquals(ScreenState.EDIT, screenStateValues[1])
188188
assertEquals(
@@ -193,7 +193,7 @@ class CreationViewModelTest {
193193
}
194194

195195
@Test
196-
fun startClicked_GenerateBotFromPrompt() = runTest {
196+
fun onStartClicked_GenerateBotFromPrompt() = runTest {
197197
val screenStateValues = mutableListOf<ScreenState>()
198198
backgroundScope.launch(UnconfinedTestDispatcher()) {
199199
viewModel.uiState.collect {
@@ -204,21 +204,21 @@ class CreationViewModelTest {
204204
viewModel.uiState.value.descriptionText.edit {
205205
"testing input description"
206206
}
207-
viewModel.startClicked()
207+
viewModel.onStartClicked()
208208
assertEquals(ScreenState.EDIT, viewModel.uiState.value.screenState)
209209
assertNotNull(viewModel.uiState.value.resultBitmapUri)
210210
}
211211

212212
@Test
213-
fun startClicked_NoInternet_DisplaysError() = runTest {
213+
fun onStartClicked_NoInternet_DisplaysError() = runTest {
214214
val values = mutableListOf<SnackbarHostState>()
215215
backgroundScope.launch(UnconfinedTestDispatcher()) {
216216
viewModel.snackbarHostState.collect {
217217
values.add(it)
218218
}
219219
}
220220
internetConnectivityManager.internetAvailable = false
221-
viewModel.startClicked()
221+
viewModel.onStartClicked()
222222
advanceUntilIdle()
223223
assertEquals(ScreenState.EDIT, viewModel.uiState.value.screenState)
224224
assertEquals(

0 commit comments

Comments
 (0)