Reconnect button (#108)
* reconnect button and profile button functionality * fix lint error and cleaned some imports * more lint errors * added tests for the drawer menu * added some timing for the animations * drawer settings test
This commit is contained in:
parent
7318ff5083
commit
8950d4c162
|
@ -1,7 +1,6 @@
|
|||
image: reactivecircus/android-emulator-23:latest
|
||||
|
||||
variables:
|
||||
API_LEVEL: "23"
|
||||
API_LEVEL: "23"
|
||||
ARCH: "x86"
|
||||
TARGET: "default"
|
||||
|
|
|
@ -52,14 +52,14 @@ dependencies {
|
|||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.core:core-ktx:1.2.0'
|
||||
implementation 'androidx.preference:preference:1.1.0'
|
||||
implementation 'androidx.preference:preference:1.1.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'androidx.navigation:navigation-fragment:2.2.1'
|
||||
implementation 'androidx.navigation:navigation-ui:2.2.1'
|
||||
implementation "com.squareup.okhttp3:okhttp:4.4.0"
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.7.1'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.7.1'
|
||||
implementation 'androidx.navigation:navigation-fragment:2.2.2'
|
||||
implementation 'androidx.navigation:navigation-ui:2.2.2'
|
||||
implementation "com.squareup.okhttp3:okhttp:4.4.1"
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.8.1'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.8.1'
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.8.1'
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.16'
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
|
||||
implementation "androidx.browser:browser:1.2.0"
|
||||
|
@ -88,7 +88,7 @@ dependencies {
|
|||
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
|
||||
testImplementation 'junit:junit:4.13'
|
||||
|
||||
androidTestImplementation("com.squareup.okhttp3:mockwebserver:4.4.0")
|
||||
androidTestImplementation("com.squareup.okhttp3:mockwebserver:4.4.1")
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||
androidTestImplementation 'androidx.test:rules:1.2.0'
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
package com.h.pixeldroid
|
||||
|
||||
import android.content.Context
|
||||
import android.view.Gravity
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.contrib.DrawerActions
|
||||
import androidx.test.espresso.contrib.DrawerMatchers
|
||||
import androidx.test.espresso.contrib.NavigationViewActions
|
||||
import androidx.test.espresso.matcher.ViewMatchers.*
|
||||
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.h.pixeldroid.testUtility.MockServer
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.Timeout
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class DrawerMenuTest {
|
||||
|
||||
private val mockServer = MockServer()
|
||||
|
||||
@get:Rule
|
||||
var globalTimeout: Timeout = Timeout.seconds(30)
|
||||
@get:Rule
|
||||
var activityRule: ActivityScenarioRule<MainActivity>
|
||||
= ActivityScenarioRule(MainActivity::class.java)
|
||||
|
||||
@Before
|
||||
fun before(){
|
||||
mockServer.start()
|
||||
val baseUrl = mockServer.getUrl()
|
||||
val preferences = InstrumentationRegistry.getInstrumentation()
|
||||
.targetContext.getSharedPreferences("com.h.pixeldroid.pref", Context.MODE_PRIVATE)
|
||||
preferences.edit().putString("accessToken", "azerty").apply()
|
||||
preferences.edit().putString("domain", baseUrl.toString()).apply()
|
||||
// Open Drawer to click on navigation.
|
||||
ActivityScenario.launch(MainActivity::class.java)
|
||||
onView(withId(R.id.drawer_layout))
|
||||
.check(matches(DrawerMatchers.isClosed(Gravity.LEFT))) // Left Drawer should be closed.
|
||||
.perform(DrawerActions.open()) // Open Drawer
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDrawerProfileButton() {
|
||||
// Start the screen of your activity.
|
||||
onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_account))
|
||||
// Check that settings activity was opened.
|
||||
onView(withId(R.id.profilePictureImageView)).check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDrawerSettingsButton() {
|
||||
// Start the screen of your activity.
|
||||
onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_settings))
|
||||
// Check that settings activity was opened.
|
||||
onView(withText(R.string.signature_title)).check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDrawerLogoutButton() {
|
||||
// Start the screen of your activity.
|
||||
onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_logout))
|
||||
// Check that settings activity was opened.
|
||||
onView(withId(R.id.connect_instance_button)).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
|
@ -1,19 +1,15 @@
|
|||
package com.h.pixeldroid
|
||||
|
||||
import android.R.attr.x
|
||||
import android.content.Context
|
||||
import android.text.Editable
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
import androidx.core.text.set
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.UiController
|
||||
import androidx.test.espresso.ViewAction
|
||||
import androidx.test.espresso.action.*
|
||||
import androidx.test.espresso.action.ViewActions.swipeDown
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.contrib.DrawerActions
|
||||
import androidx.test.espresso.contrib.DrawerMatchers
|
||||
|
@ -24,7 +20,6 @@ import androidx.test.ext.junit.rules.ActivityScenarioRule
|
|||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.h.pixeldroid.fragments.feeds.HomeFragment
|
||||
import com.h.pixeldroid.fragments.feeds.ViewHolder
|
||||
import com.h.pixeldroid.testUtility.MockServer
|
||||
import org.hamcrest.BaseMatcher
|
||||
|
@ -117,7 +112,7 @@ class MockedServerTest {
|
|||
}
|
||||
}
|
||||
|
||||
val mockServer = MockServer()
|
||||
private val mockServer = MockServer()
|
||||
|
||||
|
||||
@get:Rule
|
||||
|
@ -208,20 +203,6 @@ class MockedServerTest {
|
|||
onView(withText("Dante")).check(matches(withId(R.id.accountNameTextView)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDrawerSettingsButton() {
|
||||
// Open Drawer to click on navigation.
|
||||
onView(withId(R.id.drawer_layout))
|
||||
.check(matches(DrawerMatchers.isClosed(Gravity.LEFT))) // Left Drawer should be closed.
|
||||
.perform(DrawerActions.open()) // Open Drawer
|
||||
|
||||
// Start the screen of your activity.
|
||||
onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_settings))
|
||||
|
||||
// Check that settings activity was opened.
|
||||
onView(withText(R.string.signature_title)).check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun swipingLeftStopsAtProfile() {
|
||||
onView(withId(R.id.main_activity_main_linear_layout))
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.h.pixeldroid.fragments.CameraFragment
|
|||
import com.h.pixeldroid.fragments.feeds.HomeFragment
|
||||
import com.h.pixeldroid.fragments.ProfileFragment
|
||||
import com.h.pixeldroid.fragments.feeds.NotificationsFragment
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
|
||||
class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {
|
||||
|
||||
|
@ -84,7 +85,9 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
*/
|
||||
override fun onNavigationItemSelected(@NonNull item: MenuItem): Boolean {
|
||||
when (item.itemId){
|
||||
R.id.nav_account -> tabs.getTabAt(4)!!.select()
|
||||
R.id.nav_settings -> launchActivity(SettingsActivity())
|
||||
R.id.nav_logout -> launchActivity(LoginActivity())
|
||||
}
|
||||
|
||||
drawerLayout.closeDrawer(GravityCompat.START)
|
||||
|
|
|
@ -1,28 +1,10 @@
|
|||
package com.h.pixeldroid
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Button
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.h.pixeldroid.api.PixelfedAPI
|
||||
import com.h.pixeldroid.fragments.ProfileFragment
|
||||
import com.h.pixeldroid.fragments.ProfilePostsRecyclerViewAdapter
|
||||
import com.h.pixeldroid.objects.Account
|
||||
import com.h.pixeldroid.objects.Account.Companion.ACCOUNT_TAG
|
||||
import com.h.pixeldroid.objects.Status
|
||||
import retrofit2.Call
|
||||
import retrofit2.Callback
|
||||
import retrofit2.Response
|
||||
|
||||
class ProfileActivity : AppCompatActivity() {
|
||||
lateinit var profileFragment : ProfileFragment
|
||||
|
|
|
@ -12,7 +12,6 @@ import com.bumptech.glide.Glide
|
|||
import com.h.pixeldroid.BuildConfig
|
||||
import com.h.pixeldroid.R
|
||||
import com.h.pixeldroid.api.PixelfedAPI
|
||||
import com.h.pixeldroid.fragments.feeds.HomeFragment
|
||||
import com.h.pixeldroid.fragments.feeds.ViewHolder
|
||||
import com.h.pixeldroid.objects.Status
|
||||
|
||||
|
@ -35,7 +34,7 @@ class PostFragment : Fragment() {
|
|||
status?.setupPost(root, picRequest, root.postPicture, root.profilePic)
|
||||
|
||||
//Setup arguments needed for the onclicklisteners
|
||||
val holder = ViewHolder(root, context!!)
|
||||
val holder = ViewHolder(root, requireContext())
|
||||
val preferences = requireActivity().getSharedPreferences(
|
||||
"${BuildConfig.APPLICATION_ID}.pref", Context.MODE_PRIVATE
|
||||
)
|
||||
|
|
|
@ -52,7 +52,7 @@ class ProfileFragment : Fragment() {
|
|||
// Set RecyclerView as a grid with 3 columns
|
||||
recycler = view.findViewById(R.id.profilePostsRecyclerView)
|
||||
recycler.layoutManager = GridLayoutManager(context, 3)
|
||||
adapter = ProfilePostsRecyclerViewAdapter(context!!)
|
||||
adapter = ProfilePostsRecyclerViewAdapter(requireContext())
|
||||
recycler.adapter = adapter
|
||||
|
||||
return view
|
||||
|
|
|
@ -27,7 +27,6 @@ import com.h.pixeldroid.R
|
|||
import com.h.pixeldroid.objects.Account
|
||||
import com.h.pixeldroid.objects.Notification
|
||||
import com.h.pixeldroid.objects.Status
|
||||
import kotlinx.android.synthetic.main.fragment_feed.*
|
||||
import kotlinx.android.synthetic.main.fragment_notifications.view.*
|
||||
import retrofit2.Call
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
android:title="@string/menu_settings"
|
||||
android:icon="@drawable/ic_settings"/>
|
||||
<item
|
||||
android:id="@+id/nav_accessibility"
|
||||
android:title="@string/menu_accessibility" />
|
||||
android:id="@+id/nav_logout"
|
||||
android:title="@string/logout" />
|
||||
</group>
|
||||
</menu>
|
||||
|
|
|
@ -64,5 +64,6 @@
|
|||
<string name="shared_notification">%1$s shared your post</string>
|
||||
<string name="liked_notification">%1$s liked your post</string>
|
||||
<string name="whats_an_instance">What\'s an instance?</string>
|
||||
<string name="logout">Logout</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue