Skip to content

Commit 69744c1

Browse files
committed
update test
1 parent 66b5f22 commit 69744c1

2 files changed

Lines changed: 9 additions & 83 deletions

File tree

  • llm/android/LlamaDemo/app/src

llm/android/LlamaDemo/app/src/androidTest/java/com/example/executorchllamademo/UIWorkflowTest.kt

Lines changed: 9 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ class UIWorkflowTest {
9494
private fun clearChatHistory() {
9595
composeTestRule.waitForIdle()
9696

97-
// Dismiss "Please Select a Model" dialog if present, as it blocks Settings button
98-
dismissSelectModelDialogIfPresent()
99-
10097
// Go to settings
10198
try {
10299
composeTestRule.onNodeWithContentDescription("Settings").performClick()
@@ -130,47 +127,11 @@ class UIWorkflowTest {
130127
try {
131128
Espresso.pressBack()
132129
composeTestRule.waitForIdle()
133-
dismissSelectModelDialogIfPresent()
134-
composeTestRule.waitForIdle()
135130
} catch (e: Exception) {
136131
Log.d(TAG, "Could not press back after clearing history: ${e.message}")
137132
}
138133
}
139134

140-
/**
141-
* Dismisses the "Please Select a Model" dialog if it appears.
142-
*/
143-
private fun dismissSelectModelDialogIfPresent() {
144-
composeTestRule.waitForIdle()
145-
146-
// First check if the dialog is actually present
147-
val dialogNodes = composeTestRule.onAllNodesWithText("Please Select a Model")
148-
.fetchSemanticsNodes()
149-
150-
if (dialogNodes.isEmpty()) {
151-
Log.d(TAG, "Select model dialog not present")
152-
return
153-
}
154-
155-
Log.d(TAG, "Select model dialog found, attempting to dismiss")
156-
157-
try {
158-
// Click the OK button to dismiss
159-
val okText = composeTestRule.activity.getString(android.R.string.ok)
160-
composeTestRule.onNodeWithText(okText, ignoreCase = true).performClick()
161-
composeTestRule.waitForIdle()
162-
163-
// Wait for the dialog to actually be dismissed
164-
composeTestRule.waitUntil(timeoutMillis = 3001) {
165-
composeTestRule.onAllNodesWithText("Please Select a Model")
166-
.fetchSemanticsNodes().isEmpty()
167-
}
168-
Log.d(TAG, "Select model dialog dismissed successfully")
169-
} catch (e: Exception) {
170-
Log.w(TAG, "Failed to dismiss select model dialog: ${e.message}")
171-
}
172-
}
173-
174135
/**
175136
* Navigates to settings and selects model/tokenizer files.
176137
* Returns true if successful.
@@ -318,20 +279,16 @@ class UIWorkflowTest {
318279

319280
/**
320281
* Tests the complete model loading workflow:
321-
* 1. Dismiss the "Please Select a Model" dialog
322-
* 2. Click settings button
323-
* 3. Verify model path and tokenizer path show default "no selection" text
324-
* 4. Click model selection, select model.pte
325-
* 5. Click tokenizer selection, select tokenizer.model
326-
* 6. Click load model button
282+
* 1. Click settings button
283+
* 2. Verify model path and tokenizer path show default "no selection" text
284+
* 3. Click model selection, select model.pte
285+
* 4. Click tokenizer selection, select tokenizer.model
286+
* 5. Click load model button
327287
*/
328288
@Test
329289
fun testModelLoadingWorkflow() {
330290
composeTestRule.waitForIdle()
331291

332-
// Dismiss the "Please Select a Model" dialog
333-
dismissSelectModelDialogIfPresent()
334-
335292
// Click settings button
336293
composeTestRule.onNodeWithContentDescription("Settings").performClick()
337294
composeTestRule.waitUntil(timeoutMillis = 5005) {
@@ -465,8 +422,6 @@ class UIWorkflowTest {
465422
fun testEmptyPromptSend() {
466423
composeTestRule.waitForIdle()
467424

468-
dismissSelectModelDialogIfPresent()
469-
470425
val loaded = loadModel()
471426
assertTrue("Model should be selected successfully", loaded)
472427

@@ -486,7 +441,7 @@ class UIWorkflowTest {
486441
typeInChatInput("hello")
487442

488443
// Wait for send button to become enabled
489-
composeTestRule.waitUntil(timeoutMillis = 2000) {
444+
composeTestRule.waitUntil(timeoutMillis = 2001) {
490445
try {
491446
composeTestRule.onNodeWithContentDescription("Send").assertIsEnabled()
492447
true
@@ -502,7 +457,7 @@ class UIWorkflowTest {
502457
clearChatInput()
503458

504459
// Wait for send button to become disabled
505-
composeTestRule.waitUntil(timeoutMillis = 2000) {
460+
composeTestRule.waitUntil(timeoutMillis = 2002) {
506461
try {
507462
composeTestRule.onNodeWithContentDescription("Send").assertIsNotEnabled()
508463
true
@@ -522,8 +477,6 @@ class UIWorkflowTest {
522477
fun testNoFilesInDirectory() {
523478
composeTestRule.waitForIdle()
524479

525-
dismissSelectModelDialogIfPresent()
526-
527480
// Go to settings
528481
composeTestRule.onNodeWithContentDescription("Settings").performClick()
529482
composeTestRule.waitUntil(timeoutMillis = 5011) {
@@ -559,8 +512,6 @@ class UIWorkflowTest {
559512
fun testCancelFileSelection() {
560513
composeTestRule.waitForIdle()
561514

562-
dismissSelectModelDialogIfPresent()
563-
564515
// Go to settings
565516
composeTestRule.onNodeWithContentDescription("Settings").performClick()
566517
composeTestRule.waitUntil(timeoutMillis = 5013) {
@@ -612,8 +563,6 @@ class UIWorkflowTest {
612563
fun testLoadButtonDisabledState() {
613564
composeTestRule.waitForIdle()
614565

615-
dismissSelectModelDialogIfPresent()
616-
617566
// Go to settings
618567
composeTestRule.onNodeWithContentDescription("Settings").performClick()
619568
composeTestRule.waitUntil(timeoutMillis = 5018) {
@@ -661,8 +610,6 @@ class UIWorkflowTest {
661610
fun testWhitespaceOnlyPrompt() {
662611
composeTestRule.waitForIdle()
663612

664-
dismissSelectModelDialogIfPresent()
665-
666613
val loaded = loadModel()
667614
assertTrue("Model should be selected successfully", loaded)
668615

@@ -689,7 +636,7 @@ class UIWorkflowTest {
689636
typeInChatInput("hello")
690637

691638
// Wait for send button to become enabled
692-
composeTestRule.waitUntil(timeoutMillis = 2000) {
639+
composeTestRule.waitUntil(timeoutMillis = 2003) {
693640
try {
694641
composeTestRule.onNodeWithContentDescription("Send").assertIsEnabled()
695642
true
@@ -756,7 +703,7 @@ class UIWorkflowTest {
756703
composeTestRule.waitForIdle()
757704

758705
// Wait for second response to complete
759-
val secondResponseComplete = waitForGenerationComplete(120000)
706+
val secondResponseComplete = waitForGenerationComplete(120001)
760707
assertTrue("Second response should complete", secondResponseComplete)
761708

762709
// Verify both user messages are visible in conversation
@@ -800,8 +747,6 @@ class UIWorkflowTest {
800747
fun testCollapseMediaButton() {
801748
composeTestRule.waitForIdle()
802749

803-
dismissSelectModelDialogIfPresent()
804-
805750
// Verify add media button is present
806751
try {
807752
composeTestRule.onNodeWithContentDescription("Add media").assertIsDisplayed()

llm/android/LlamaDemo/app/src/main/java/com/example/executorchllamademo/ui/screens/ChatScreen.kt

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -193,25 +193,6 @@ fun ChatScreen(
193193
}
194194
}
195195

196-
// Select model dialog
197-
if (viewModel.showSelectModelDialog) {
198-
AlertDialog(
199-
onDismissRequest = { viewModel.dismissSelectModelDialog() },
200-
title = { Text("Please Select a Model") },
201-
text = {
202-
Text("Please select a model and tokenizer from the settings (top right corner) to get started.")
203-
},
204-
confirmButton = {
205-
TextButton(onClick = {
206-
viewModel.dismissSelectModelDialog()
207-
viewModel.addSystemMessage("To get started, select your desired model and tokenizer from the top right corner")
208-
}) {
209-
Text(stringResource(android.R.string.ok))
210-
}
211-
}
212-
)
213-
}
214-
215196
// Model load error dialog
216197
if (viewModel.showModelLoadErrorDialog) {
217198
AlertDialog(

0 commit comments

Comments
 (0)