-
Notifications
You must be signed in to change notification settings - Fork 471
Fixing tests #398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
praneethatchana
wants to merge
8
commits into
main
Choose a base branch
from
Platform-samples_No_PiP
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fixing tests #398
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b0c5ef5
Made the changes to Remove the PiP implementation
praneethatchana 2a4fe7b
Made the changes to Remove the PiP implementation and also Removed th…
praneethatchana 2868494
Changes as per the Gemini comments and Removed all the Code related t…
praneethatchana b338bbc
Fixing the Tests
praneethatchana d79a161
Fixing tests
praneethatchana 4a4661f
Merge pull request #396 from android/Platform_Sample_Praneeth
alabiaga 762661e
Refactor timer tests to use Espresso framework
praneethatchana 0265f6a
Add copyright and license information
praneethatchana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| * Copyright 2023 The Android Open Source Project | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package com.example.android.pip | ||
|
|
||
| import android.view.View | ||
| import android.widget.TextView | ||
| import androidx.test.core.app.ActivityScenario.launch | ||
| import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
| import androidx.test.filters.LargeTest | ||
| import com.google.common.truth.Truth.assertThat | ||
| import org.junit.Test | ||
| import org.junit.runner.RunWith | ||
|
|
||
| @RunWith(AndroidJUnit4::class) | ||
| @LargeTest | ||
| class PiPSampleActivityTest { | ||
|
|
||
| /** | ||
| * Verifies that the timer starts and updates the time. | ||
| */ | ||
| @Test | ||
| fun startTimer_updatesTime() { | ||
| launchActivity<PiPSampleActivity>().use { | ||
| // Initial time should be 00:00:00 | ||
| onView(withId(R.id.time)).check(matches(withText("00:00:00"))) | ||
| // Click Start | ||
| onView(withId(R.id.start_or_pause)).perform(click()) | ||
| // Time should change | ||
| onView(withId(R.id.time)).check(matches(not(withText("00:00:00")))) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Verifies that the Clear button resets the timer. | ||
| */ | ||
| @Test | ||
| fun clearTimer_resetsTime() { | ||
| launchActivity<PiPSampleActivity>().use { | ||
| // Start the timer | ||
| onView(withId(R.id.start_or_pause)).perform(click()) | ||
| // Clear the timer | ||
| onView(withId(R.id.clear)).perform(click()) | ||
| // Time should reset | ||
| onView(withId(R.id.time)).check(matches(withText("00:00:00"))) | ||
| } | ||
| } | ||
| } | ||
81 changes: 44 additions & 37 deletions
81
.../picture-in-picture/src/androidTest/java/com/example/android/pip/PiPSampleActivityTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,57 +1,64 @@ | ||
| /* | ||
praneethatchana marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * Copyright 2023 The Android Open Source Project | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package com.example.android.pip | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if this file should be deleted entirely? I don't think testing that timers work correctly is relevant to a developer wanting to see what tests they should implement if they implement PiP. |
||
|
|
||
| import androidx.test.core.app.launchActivity | ||
| import androidx.test.espresso.Espresso.onView | ||
| import androidx.test.espresso.action.ViewActions.click | ||
| import androidx.test.espresso.assertion.ViewAssertions.matches | ||
| import androidx.test.espresso.matcher.ViewMatchers.withId | ||
| import androidx.test.espresso.matcher.ViewMatchers.withText | ||
| import android.view.View | ||
| import android.widget.TextView | ||
| import androidx.test.core.app.ActivityScenario.launch | ||
| import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
| import androidx.test.filters.LargeTest | ||
| import com.google.common.truth.Truth.assertThat | ||
| import org.hamcrest.Matchers.not | ||
| import org.junit.Test | ||
| import org.junit.runner.RunWith | ||
|
|
||
| @RunWith(AndroidJUnit4::class) | ||
| @LargeTest | ||
| class PiPSampleActivityTest { | ||
|
|
||
| /** | ||
| * Verifies that the timer starts and updates the time. | ||
| */ | ||
| @Test | ||
| fun start() { | ||
| launchActivity<PiPSampleActivity>().use { | ||
| onView(withId(R.id.time)).check(matches(withText("00:00:00"))) | ||
| onView(withId(R.id.start_or_pause)).perform(click()) | ||
| onView(withId(R.id.time)).check(matches(not(withText("00:00:00")))) | ||
| fun startTimer_updatesTime() { | ||
| val scenario = launch(PiPSampleActivity::class.java) | ||
|
|
||
| scenario.onActivity { activity -> | ||
| val startBtn = activity.findViewById<View>(R.id.start_or_pause) | ||
| val timeText = activity.findViewById<TextView>(R.id.time) | ||
|
|
||
| // Initial state | ||
| assertThat(timeText.text.toString()).isEqualTo("00:00:00") | ||
|
|
||
| // Start timer | ||
| startBtn.performClick() | ||
| } | ||
|
|
||
| // Wait for async update | ||
| Thread.sleep(1500) | ||
ashnohe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| scenario.onActivity { activity -> | ||
| val timeText = activity.findViewById<TextView>(R.id.time) | ||
|
|
||
| // Time should now be updated | ||
| assertThat(timeText.text.toString()).isNotEqualTo("00:00:00") | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Verifies that the Clear button resets the timer. | ||
| */ | ||
| @Test | ||
| fun pip() { | ||
| launchActivity<PiPSampleActivity>().use { scenario -> | ||
| scenario.onActivity { activity -> | ||
| assertThat(activity.isInPictureInPictureMode).isFalse() | ||
| } | ||
| onView(withId(R.id.pip)).perform(click()) | ||
| scenario.onActivity { activity -> | ||
| assertThat(activity.isInPictureInPictureMode).isTrue() | ||
| } | ||
| fun clearTimer_resetsTime() { | ||
| val scenario = launch(PiPSampleActivity::class.java) | ||
|
|
||
| scenario.onActivity { activity -> | ||
| val startBtn = activity.findViewById<View>(R.id.start_or_pause) | ||
| val clearBtn = activity.findViewById<View>(R.id.clear) | ||
| val timeText = activity.findViewById<TextView>(R.id.time) | ||
|
|
||
| startBtn.performClick() | ||
| clearBtn.performClick() | ||
|
|
||
| // Time should reset | ||
| assertThat(timeText.text.toString()).isEqualTo("00:00:00") | ||
ashnohe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.