Explorar el Código

Fixes the merge conflicts

Subbramanian Lakshmanan hace 7 años
padre
commit
e20cb00877

+ 0 - 1
_config.yml

@@ -1 +0,0 @@
-theme: jekyll-theme-minimal

+ 2 - 2
app/build.gradle

@@ -63,6 +63,6 @@ dependencies {
     androidTestImplementation 'androidx.test:runner:1.1.0'
     androidTestImplementation 'androidx.test:rules:1.1.0'
     androidTestImplementation 'androidx.annotation:annotation:1.0.0'
-    androidTestImplementation 'androidx.test:runner:1.1.0'
-    androidTestImplementation 'androidx.test:rules:1.1.0'
+    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+    androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.2'
 }

+ 67 - 0
app/src/androidTest/java/com/sduduzog/slimlauncher/SetupFragmentTest.kt

@@ -0,0 +1,67 @@
+package com.sduduzog.slimlauncher
+
+
+import android.view.View
+import android.view.ViewGroup
+import androidx.test.espresso.Espresso.onView
+import androidx.test.espresso.action.ViewActions
+import androidx.test.espresso.action.ViewActions.click
+import androidx.test.espresso.assertion.ViewAssertions.matches
+import androidx.test.espresso.matcher.RootMatchers
+import androidx.test.espresso.matcher.ViewMatchers.*
+import androidx.test.filters.LargeTest
+import androidx.test.rule.ActivityTestRule
+import androidx.test.runner.AndroidJUnit4
+import org.hamcrest.Description
+import org.hamcrest.Matcher
+import org.hamcrest.Matchers
+import org.hamcrest.Matchers.allOf
+import org.hamcrest.TypeSafeMatcher
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@LargeTest
+@RunWith(AndroidJUnit4::class)
+class SetupFragmentTest {
+
+    @Rule
+    @JvmField
+    var mActivityTestRule = ActivityTestRule(MainActivity::class.java)
+
+    @Test
+    fun isAlertDialogShown() {
+        val appCompatButton = onView(
+                allOf(withId(R.id.setupButton),
+                        withText("start"), isDisplayed()))
+        appCompatButton.perform(click())
+
+        val frameLayout = onView(
+                allOf(withId(android.R.id.content), isDisplayed()))
+        frameLayout.check(matches(isDisplayed()))
+
+        val alertDialogTitle = onView(
+                allOf(withText(R.string.choose_apps_title)))
+        alertDialogTitle.check(matches(isDisplayed()))
+    }
+
+    @Test
+    fun noAppsSelected() {
+        val appCompatButton = onView(
+                allOf(withId(R.id.setupButton), withText("start"), isDisplayed()))
+        appCompatButton.perform(click())
+
+        val appCompatButton2 = onView(
+                allOf(withId(android.R.id.button1), withText("Done")))
+        appCompatButton2.perform(ViewActions.scrollTo(), click())
+
+        val viewGroup = onView(
+                allOf(withId(R.id.setupContainer), isDisplayed()))
+        viewGroup.check(matches(isDisplayed()))
+
+        onView(withText(R.string.no_app_selected_toast_msg)).inRoot(
+                RootMatchers.withDecorView(Matchers.not(Matchers.`is`(mActivityTestRule.activity.window.decorView))))
+                .check(matches(isDisplayed()))
+    }
+
+}

+ 3 - 1
app/src/main/java/com/sduduzog/slimlauncher/ui/main/setup/SetupFragment.kt

@@ -164,11 +164,13 @@ class SetupFragment : Fragment(), DialogInteractionListener {
             }
             builder.setPositiveButton("Done") { _, _ ->
                 if (checkedItems.none { it }) {
-                    Toast.makeText(context, "Choose at least one app", Toast.LENGTH_SHORT).show()
+                    Toast.makeText(context, getString(R.string.no_app_selected_toast_msg), Toast.LENGTH_SHORT).show()
                 } else {
                     setApps()
                 }
             }
+            builder.setTitle(getString(R.string.choose_apps_title))
+
             return builder.create()
         }
 

+ 2 - 0
app/src/main/res/values/strings.xml

@@ -79,5 +79,7 @@
     <string name="settings_text_tap_to_check_between_24_hour_or_12_hour">Tap to check between 24 hour or 12 hour</string>
     <string name="settings_text_tap_to_change_app_theme">Tap to change app theme</string>
     <string name="settings_text_home_screen_apps">Home screen apps</string>
+    <string name="no_app_selected_toast_msg">Choose at least one app</string>
+    <string name="choose_apps_title">Choose Apps</string>
 
 </resources>