Skip to content
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

Testing #158

Draft
wants to merge 58 commits into
base: webview
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
ee10b26
setup
grcoleman Jul 14, 2020
6973b6b
adds night theme color scheme, adds setForceDarkStrategy, adds media …
grcoleman Jul 14, 2020
efcf673
setup
grcoleman Jul 14, 2020
d6836d6
adds night theme color scheme, adds setForceDarkStrategy, adds media …
grcoleman Jul 14, 2020
c2de65f
fix conflicts
grcoleman Jul 14, 2020
761ecf0
changes path, adds icon choosing logic
grcoleman Jul 15, 2020
6db9c65
changes initial image path, adds symbos values
grcoleman Jul 15, 2020
55a9608
adds meta tag, corrects media query, adds setDefaultNightMode
grcoleman Jul 15, 2020
3e2c009
adds media query
grcoleman Jul 15, 2020
d70a861
changes path, adds icon choosing logic
grcoleman Jul 15, 2020
47f53af
changes initial image path, adds symbos values
grcoleman Jul 15, 2020
f429a26
changes fetch to correct path
grcoleman Jul 16, 2020
bc9ae5f
changes fetch path
grcoleman Jul 16, 2020
f0b47b9
changes background color, adds clarification on ForceDarkStrategy
grcoleman Jul 20, 2020
5dc103e
add clarifying comments on location of data, change path to ensure co…
grcoleman Jul 20, 2020
2c773f8
adds testing outline and dependencies
grcoleman Jul 21, 2020
403446f
changes res path, fixes comment in main.js
grcoleman Jul 21, 2020
77ff7e0
adds tests for createJsObject and drop down menu
grcoleman Jul 21, 2020
7185787
add description to tests,add ids to menu
grcoleman Jul 21, 2020
61c895e
splits light and dark themes into seperate files, adds logic to check…
grcoleman Jul 22, 2020
66b3c49
removes static text color setting from style.css
grcoleman Jul 22, 2020
da570e4
Merge pull request #157 from gcoleman799/change-data-source
gcoleman799 Jul 22, 2020
4323afe
adds testing outline and dependencies
grcoleman Jul 21, 2020
aa3df09
adds tests for createJsObject and drop down menu
grcoleman Jul 21, 2020
6d218b7
add description to tests,add ids to menu
grcoleman Jul 21, 2020
f263800
adds set up for unit tests
grcoleman Jul 22, 2020
42111ec
setup
grcoleman Jul 14, 2020
d42ded6
adds night theme color scheme, adds setForceDarkStrategy, adds media …
grcoleman Jul 14, 2020
0d4fdf8
setup
grcoleman Jul 14, 2020
85d21b8
adds night theme color scheme, adds setForceDarkStrategy, adds media …
grcoleman Jul 14, 2020
637fec3
adds meta tag, corrects media query, adds setDefaultNightMode
grcoleman Jul 15, 2020
2c83302
adds media query
grcoleman Jul 15, 2020
3a9d8fa
changes background color, adds clarification on ForceDarkStrategy
grcoleman Jul 20, 2020
f8b0c11
splits light and dark themes into seperate files, adds logic to check…
grcoleman Jul 22, 2020
be2899c
removes static text color setting from style.css
grcoleman Jul 22, 2020
7c3b2c1
add comment about default reloading
grcoleman Jul 22, 2020
60105b6
fixes conflicts
grcoleman Jul 22, 2020
e9e7a72
thread test and callback test outline
grcoleman Jul 23, 2020
4934ed2
fixes merge conflicts
grcoleman Jul 23, 2020
d7806ed
revert to one css file
grcoleman Jul 24, 2020
13d0b17
puts createJsObject in seperate file, adds handlers and runnables to …
grcoleman Jul 24, 2020
ce63069
converts runable to lambda, fixes message val, fixes loadDataWithBase…
grcoleman Jul 27, 2020
fa60356
adds coroutines to tests
grcoleman Jul 27, 2020
b4c6e58
changes dark theme css formatting
grcoleman Jul 28, 2020
35b902d
Merge pull request #155 from gcoleman799/custom-dark-theme
gcoleman799 Jul 28, 2020
77350b7
changes initial image path, gets rid of unncessary logging, fixes all…
grcoleman Jul 29, 2020
00b047b
Merge pull request #160 from gcoleman799/share-feature
gcoleman799 Jul 29, 2020
048851d
adds testing outline and dependencies
grcoleman Jul 21, 2020
7f7152e
adds tests for createJsObject and drop down menu
grcoleman Jul 21, 2020
bbc334b
add description to tests,add ids to menu
grcoleman Jul 21, 2020
4528470
adds set up for unit tests
grcoleman Jul 22, 2020
fa580f4
thread test and callback test outline
grcoleman Jul 23, 2020
684f2ef
adds testing outline and dependencies
grcoleman Jul 21, 2020
016ac01
adds tests for createJsObject and drop down menu
grcoleman Jul 21, 2020
c920025
puts createJsObject in seperate file, adds handlers and runnables to …
grcoleman Jul 24, 2020
e7bb953
uses CompletableDeffered in tests
grcoleman Jul 28, 2020
84cea6b
uses Completable Deferredand run blocking
grcoleman Jul 29, 2020
5c447de
Fixes merge conflicts
grcoleman Jul 29, 2020
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
7 changes: 7 additions & 0 deletions WebView/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,11 @@ dependencies {
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-web:3.1.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.2'
androidTestImplementation 'androidx.test:rules:1.1.1'
androidTestImplementation 'androidx.test:runner:1.1.0'


}
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,62 @@
*/

package com.android.samples.webviewdemo

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.espresso.web.assertion.WebViewAssertions.webMatches
import androidx.test.espresso.web.model.Atoms.castOrDie
import androidx.test.espresso.web.model.Atoms.script
import androidx.test.espresso.web.sugar.Web.onWebView
import androidx.test.espresso.web.webdriver.DriverAtoms.findElement
import androidx.test.espresso.web.webdriver.DriverAtoms.getText
import androidx.test.espresso.web.webdriver.DriverAtoms.webClick
import androidx.test.espresso.web.webdriver.Locator
import androidx.test.ext.junit.runners.AndroidJUnit4

import androidx.test.rule.ActivityTestRule
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.CoreMatchers.containsString
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
gcoleman799 marked this conversation as resolved.
Show resolved Hide resolved

@Rule @JvmField
val mainActivityRule = ActivityTestRule(MainActivity::class.java)
fun afterActivityLaunched() {
// Technically we do not need to do this - MainActivity has javascript turned on.
// Other WebViews in your app may have javascript turned off, however since the only way
// to automate WebViews is through javascript, it must be enabled.
onWebView().forceJavascriptEnabled()
}

// Test to check that the drop down menu behaves as expected
@Test
fun dropDownMenu_SanFran() {
mainActivityRule.getActivity()
onWebView()
.withElement(findElement(Locator.ID, "location"))
.perform(webClick()) // Similar to perform(click())
.withElement(findElement(Locator.ID, "SF"))
.perform(webClick()) // Similar to perform(click())
.withElement(findElement(Locator.ID, "title"))
.check(webMatches(getText(), containsString("San Francisco")))
}

// Test for checking createJsObject
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.android.samples.webviewdemo", appContext.packageName)
fun jsObjectIsInjectedAndContainsPostMessage() {
mainActivityRule.getActivity()
onWebView()
.check(
webMatches(
script("return jsObject && jsObject.postMessage != null;", castOrDie(Boolean::class.javaObjectType)),
`is`(true)
)
)
}
}
}
2 changes: 1 addition & 1 deletion WebView/app/src/main/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<label for="location">Choose a location:</label>
<select name="location" id="location" onchange="getData()">
<option value="newYork">New York</option>
<option value="sanFrancisco">San Francisco</option>
<option id= "SF" value="sanFrancisco">San Francisco</option>
gcoleman799 marked this conversation as resolved.
Show resolved Hide resolved
<option value="london">London</option>
</select>
<h1 id="title">Location</h1>
Expand Down