Skip to content

Commit

Permalink
Merge branch 'detachedDev' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
retanar committed Mar 17, 2021
2 parents ac8c98f + dc59bb3 commit 144e836
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "0.5.0 alpha 2"
versionName "0.5.0 alpha 3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resConfigs "en"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.vlprojects.divergence
package com.vlprojects.divergence.logic

class Attractor(val name: String, val range: IntRange) {
operator fun contains(value: Int) = value in range
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package com.vlprojects.divergence
package com.vlprojects.divergence.logic

import com.vlprojects.divergence.R

const val SHARED_FILENAME = "divergence_widget"
const val SHARED_CURRENT_DIVERGENCE = "divergence_value"
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/ic_baseline_settings_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white"
android:pathData="M19.14,12.94c0.04,-0.3 0.06,-0.61 0.06,-0.94c0,-0.32 -0.02,-0.64 -0.07,-0.94l2.03,-1.58c0.18,-0.14 0.23,-0.41 0.12,-0.61l-1.92,-3.32c-0.12,-0.22 -0.37,-0.29 -0.59,-0.22l-2.39,0.96c-0.5,-0.38 -1.03,-0.7 -1.62,-0.94L14.4,2.81c-0.04,-0.24 -0.24,-0.41 -0.48,-0.41h-3.84c-0.24,0 -0.43,0.17 -0.47,0.41L9.25,5.35C8.66,5.59 8.12,5.92 7.63,6.29L5.24,5.33c-0.22,-0.08 -0.47,0 -0.59,0.22L2.74,8.87C2.62,9.08 2.66,9.34 2.86,9.48l2.03,1.58C4.84,11.36 4.8,11.69 4.8,12s0.02,0.64 0.07,0.94l-2.03,1.58c-0.18,0.14 -0.23,0.41 -0.12,0.61l1.92,3.32c0.12,0.22 0.37,0.29 0.59,0.22l2.39,-0.96c0.5,0.38 1.03,0.7 1.62,0.94l0.36,2.54c0.05,0.24 0.24,0.41 0.48,0.41h3.84c0.24,0 0.44,-0.17 0.47,-0.41l0.36,-2.54c0.59,-0.24 1.13,-0.56 1.62,-0.94l2.39,0.96c0.22,0.08 0.47,0 0.59,-0.22l1.92,-3.32c0.12,-0.22 0.07,-0.47 -0.12,-0.61L19.14,12.94zM12,15.6c-1.98,0 -3.6,-1.62 -3.6,-3.6s1.62,-3.6 3.6,-3.6s3.6,1.62 3.6,3.6S13.98,15.6 12,15.6z"/>
</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/menu/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/settings_menu"
android:title="@string/menu_settings"
app:showAsAction="ifRoom"/>
app:showAsAction="ifRoom" android:icon="@drawable/ic_baseline_settings_24"/>
</menu>
44 changes: 37 additions & 7 deletions app/src/test/java/com/vlprojects/divergence/ExampleUnitTest.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package com.vlprojects.divergence

import com.vlprojects.divergence.logic.ALL_RANGE
import com.vlprojects.divergence.logic.DivergenceMeter
import com.vlprojects.divergence.logic.MILLION
import com.vlprojects.divergence.logic.attractors
import org.junit.Assert
import org.junit.Test
import java.util.Date

class ExampleUnitTest {
@Test
fun test() {

}

@Test
fun zeroCooldownTest() {
val divergence = 999_999
val attractor = DivergenceMeter.getAttractor(divergence)
val attractor = DivergenceMeter.getAttractor(divergence)!!
val lastTimeChanged = Date().time - 1000 // One second ago
val cooldownMs = 0L

Expand All @@ -24,7 +25,36 @@ class ExampleUnitTest {
}
}

println("Attractor haven't been changed")
throw RuntimeException("Attractor haven't been changed")
throw AssertionError("Attractor haven't been changed")
}

@Test
fun oldDivergenceOutOfAllRange() {
val oldDiv = ALL_RANGE.range.last + MILLION / 2
val newDiv1 = ALL_RANGE.range.last - MILLION / 2
val newDiv2 = ALL_RANGE.range.last + MILLION / 2

Assert.assertNull(
"Expected ALL_RANGE when the divergence is out of range",
DivergenceMeter.getAttractor(oldDiv)
)
Assert.assertNull(
"Expected null when old divergence is out of range",
DivergenceMeter.checkAttractorChange(oldDiv, newDiv1)
)
Assert.assertNull(
"Expected null when new divergence is out of range",
DivergenceMeter.checkAttractorChange(oldDiv, newDiv2)
)
}

@Test
fun getCoefficientTest() {
val coefRange = -25000..25000
val div1 = 0
val div2 = attractors.random().range.last
// val divOutOfRange = ALL_RANGE.range.last + 2_123_456
Assert.assertTrue(DivergenceMeter.getCoefficient(div1) in coefRange)
Assert.assertTrue(DivergenceMeter.getCoefficient(div2) in coefRange)
}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.4.21'
ext.kotlin_version = '1.4.31'
repositories {
google()
jcenter()
Expand Down

0 comments on commit 144e836

Please sign in to comment.