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

Market hours view #3

Merged
merged 4 commits into from
Mar 31, 2019
Merged
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ open class ScreenshotTestBase {

protected fun getViewConfigCombos(height: Int): List<TestDevice> {
val devices = ArrayList<TestDevice>()
val languages = arrayOf("en", "el")
// here we can add more languages but in order to reduce the number of screenshots for the PR demo we removed 'el'
val languages = arrayOf("en")

devices.addAll(generateCombos(languages, TestDevice(DEVICE_1.width, height), false))
devices.addAll(generateCombos(languages, TestDevice(DEVICE_4.width, height), true))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
package com.xm.screenshot.testing

import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import com.xm.MarketHoursView
import org.junit.Before
import org.junit.Test

/**
* Created by Christoforos Filippou on 30/03/2019
*/
class TestMarketHoursView : ScreenshotTestBase() {

private lateinit var combos: List<TestDevice>

@Before
override fun setUp() {
super.setUp()

combos = getViewConfigCombos(WRAP_CONTENT)
}

@Test
fun marketHoursView_evenHourDisplayTimes() {
val marketDisplayInfo = MarketHoursView.MarketDisplayInfo(
listOf(
MarketHoursView.MarketHoursSession(
MarketHoursView.DisplayedTime(6, 0),
MarketHoursView.DisplayedTime(20, 0)
)
),
MarketHoursView.DisplayedTime(14, 0),
true
)

for (combo in combos) {
updateResources(combo.locale, combo.isDarkTheme)
createViewAndRecord(marketDisplayInfo, combo)
}
}

@Test
fun marketHoursView_oddHourDisplayTimes() {
val marketDisplayInfo = MarketHoursView.MarketDisplayInfo(
listOf(
MarketHoursView.MarketHoursSession(
MarketHoursView.DisplayedTime(7, 0),
MarketHoursView.DisplayedTime(21, 0)
)
),
MarketHoursView.DisplayedTime(15, 0),
true
)

for (combo in combos) {
updateResources(combo.locale, combo.isDarkTheme)
createViewAndRecord(marketDisplayInfo, combo)
}
}

@Test
fun marketHoursView_zeroAndTwentyFourHourDisplayTimes_AndCurrentTimeZero() {
val marketDisplayInfo = MarketHoursView.MarketDisplayInfo(
listOf(
MarketHoursView.MarketHoursSession(
MarketHoursView.DisplayedTime(0, 0),
MarketHoursView.DisplayedTime(24, 0)
)
),
MarketHoursView.DisplayedTime(0, 0),
true
)

for (combo in combos) {
updateResources(combo.locale, combo.isDarkTheme)
createViewAndRecord(marketDisplayInfo, combo)
}
}

@Test
fun marketHoursView_zeroAndTwentyFourHourDisplayTimes_AndCurrentTime24() {
val marketDisplayInfo = MarketHoursView.MarketDisplayInfo(
listOf(
MarketHoursView.MarketHoursSession(
MarketHoursView.DisplayedTime(0, 0),
MarketHoursView.DisplayedTime(24, 0)
)
),
MarketHoursView.DisplayedTime(24, 0),
true
)

for (combo in combos) {
updateResources(combo.locale, combo.isDarkTheme)
createViewAndRecord(marketDisplayInfo, combo)
}
}

@Test
fun marketHoursView_oddHourDisplaytimes_WhenCloseToEdgeValues() {
val marketDisplayInfo = MarketHoursView.MarketDisplayInfo(
listOf(
MarketHoursView.MarketHoursSession(
MarketHoursView.DisplayedTime(1, 0),
MarketHoursView.DisplayedTime(23, 0)
)
),
MarketHoursView.DisplayedTime(1, 0),
true
)

for (combo in combos) {
updateResources(combo.locale, combo.isDarkTheme)
createViewAndRecord(marketDisplayInfo, combo)
}
}

@Test
fun marketHoursView_displayTimesWithMinuteOffsets() {
val marketDisplayInfo = MarketHoursView.MarketDisplayInfo(
listOf(
MarketHoursView.MarketHoursSession(
MarketHoursView.DisplayedTime(7, 30),
MarketHoursView.DisplayedTime(21, 30)
)
),
MarketHoursView.DisplayedTime(6, 30),
false
)

for (combo in combos) {
updateResources(combo.locale, combo.isDarkTheme)
createViewAndRecord(marketDisplayInfo, combo)
}
}

@Test
fun marketHoursView_2MarketSessions() {
val marketDisplayInfo = MarketHoursView.MarketDisplayInfo(
listOf(
MarketHoursView.MarketHoursSession(
MarketHoursView.DisplayedTime(1, 0),
MarketHoursView.DisplayedTime(5, 0)
),
MarketHoursView.MarketHoursSession(
MarketHoursView.DisplayedTime(21, 0),
MarketHoursView.DisplayedTime(24, 0)
)
),
MarketHoursView.DisplayedTime(17, 0),
false
)

for (combo in combos) {
updateResources(combo.locale, combo.isDarkTheme)
createViewAndRecord(marketDisplayInfo, combo)
}
}

@Test
fun marketHoursView_multipleMarketSessions() {
val marketDisplayInfo = MarketHoursView.MarketDisplayInfo(
listOf(
MarketHoursView.MarketHoursSession(
MarketHoursView.DisplayedTime(1, 0),
MarketHoursView.DisplayedTime(5, 0)
),
MarketHoursView.MarketHoursSession(
MarketHoursView.DisplayedTime(7, 0),
MarketHoursView.DisplayedTime(18, 0)
),
MarketHoursView.MarketHoursSession(
MarketHoursView.DisplayedTime(19, 0),
MarketHoursView.DisplayedTime(20, 30)
),
MarketHoursView.MarketHoursSession(
MarketHoursView.DisplayedTime(21, 0),
MarketHoursView.DisplayedTime(24, 0)
)
),
MarketHoursView.DisplayedTime(18, 30),
false
)

for (combo in combos) {
updateResources(combo.locale, combo.isDarkTheme)
createViewAndRecord(marketDisplayInfo, combo)
}
}

private fun createViewAndRecord(marketDisplayInfo: MarketHoursView.MarketDisplayInfo, device: TestDevice) {
val marketHoursView = MarketHoursView(context)
marketHoursView.setMarketDisplayInfo(marketDisplayInfo)
record(marketHoursView, device)
}
}
Loading