Skip to content

Commit 92c6de5

Browse files
committed
fix: added test
1 parent d87c1f3 commit 92c6de5

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// 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
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.maps.android.compose
16+
17+
import androidx.compose.ui.test.junit4.createComposeRule
18+
import androidx.compose.ui.test.onNodeWithText
19+
import com.google.android.gms.maps.model.CameraPosition
20+
import com.google.android.gms.maps.model.LatLng
21+
import com.google.maps.android.compose.widgets.ScaleBar
22+
import org.junit.Rule
23+
import org.junit.Test
24+
import java.util.concurrent.CountDownLatch
25+
26+
class ScaleBarTests {
27+
28+
@get:Rule
29+
val composeTestRule = createComposeRule()
30+
31+
private lateinit var cameraPositionState: CameraPositionState
32+
33+
private fun initScaleBar(initialZoom: Float, initialPosition: LatLng) {
34+
check(hasValidApiKey) { "Maps API key not specified" }
35+
36+
cameraPositionState = CameraPositionState(
37+
position = CameraPosition.fromLatLngZoom(initialPosition, initialZoom)
38+
)
39+
40+
composeTestRule.setContent {
41+
ScaleBar(cameraPositionState = cameraPositionState)
42+
}
43+
}
44+
45+
@Test
46+
fun testScaleBarInitialState() {
47+
val initialZoom = 15f
48+
val initialPosition = LatLng(37.7749, -122.4194) // San Francisco
49+
initScaleBar(initialZoom, initialPosition)
50+
51+
composeTestRule.waitForIdle()
52+
53+
composeTestRule.onNodeWithText(
54+
text = "ft",
55+
substring = true,
56+
ignoreCase = false
57+
).assertExists()
58+
composeTestRule.onNodeWithText(
59+
text = "m",
60+
substring = true,
61+
ignoreCase = false
62+
).assertExists()
63+
}
64+
}

0 commit comments

Comments
 (0)