Skip to content
Open
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 @@ -124,7 +124,7 @@ public final Camera getInitialCamera() {
options.setFillColor(faceFillColor);
options.setStrokeColor(faceStrokeColor);
options.setStrokeWidth(faceStrokeWidth);
options.setAltitudeMode(AltitudeMode.CLAMP_TO_GROUND);
options.setAltitudeMode(AltitudeMode.ABSOLUTE);
options.setGeodesic(false);
options.setDrawsOccludedSegments(true);
return options;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ private void initializeMap(@NonNull GoogleMap3D googleMap3D) {
if (isInitialized) return;
isInitialized = true;

googleMap3D.setCamera(getInitialCamera());
googleMap3D.setMapMode(Map3DMode.SATELLITE);
setupPopover(googleMap3D);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith

/**
* Visual test for Markers sample in Compose app.
*/
@RunWith(AndroidJUnit4::class)
class MarkersVisualTest : BaseVisualTest() {

Expand All @@ -50,10 +53,11 @@ class MarkersVisualTest : BaseVisualTest() {
// Define the verification prompt for Gemini
val prompt = """
Please act as a UI tester and analyze this screenshot.
1. Confirm that a 3D map view is visible.
2. Confirm that an alien icon or marker is visible on top of the prominent rock formation (Devils Tower).
1. Confirm that a 3D satellite map view of New York City (Manhattan) is visible.
2. Confirm that a Giant Ape/Gorilla marker icon is visible floating near the Empire State Building.
3. Confirm that custom red and/or yellow pins are visible in the vicinity.

If the map is visible and the alien marker is seen, reply with "PASSED".
If the map is visible and the giant ape marker and custom pins are seen, reply with "PASSED".
Otherwise, report what you see.
""".trimIndent()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until
import com.example.composedemos.popovers.PopoversActivity
import kotlinx.coroutines.runBlocking
import org.json.JSONObject
import org.junit.Assert.assertTrue
import org.junit.Assert.fail
import org.junit.Test
import org.junit.runner.RunWith

/**
* Visual test for Popovers sample in Compose app.
*/
@RunWith(AndroidJUnit4::class)
class PopoversVisualTest : BaseVisualTest() {

Expand All @@ -50,7 +55,7 @@ class PopoversVisualTest : BaseVisualTest() {
// Define the prompt for Gemini to find coordinates
val promptFind = """
Analyze this screenshot of a 3D map.
You should see a marker or label with the text "Click me for Popover".
You should see a marker or label with the text "Golden Gate Bridge".
Find that marker or label.
Return its center coordinates as a JSON object: {"x": <float>, "y": <float>} where x and y are normalized coordinates between 0.0 and 1.0 (0.0 is top/left, 1.0 is bottom/right).
Return ONLY the JSON object, nothing else.
Expand All @@ -62,8 +67,10 @@ class PopoversVisualTest : BaseVisualTest() {

// Parse JSON and click
try {
val jsonStr = geminiResponse?.substringAfter("{")?.substringBeforeLast("}")?.let { "{$it}" } ?: ""
val json = org.json.JSONObject(jsonStr)
val jsonStr =
geminiResponse?.substringAfter("{")?.substringBeforeLast("}")?.let { "{$it}" }
?: ""
val json = JSONObject(jsonStr)
val x = json.getDouble("x")
val y = json.getDouble("y")

Expand All @@ -73,15 +80,17 @@ class PopoversVisualTest : BaseVisualTest() {
println("Clicking at ($clickX, $clickY) based on Gemini response")
uiDevice.click(clickX, clickY)
} catch (e: Exception) {
org.junit.Assert.fail("Failed to parse coordinates from Gemini response: $geminiResponse. Error: ${e.message}")
fail(
"Failed to parse coordinates from Gemini response: $geminiResponse. Error: ${e.message}",
)
}

// Wait for the popover text to appear
val textFound = uiDevice.wait(
Until.hasObject(By.text("This is a Popover anchored to a marker!")),
10000,
Until.hasObject(By.text("The Golden Gate Bridge")),
15000,
)
assertTrue("Popover text not found", textFound)
assertTrue("Popover text not found", textFound == true)

// Capture a screenshot for visual confirmation
captureScreenshot("popovers_screenshot.png")
Expand Down
Loading
Loading