Skip to content

Commit

Permalink
More changes requested in code review
Browse files Browse the repository at this point in the history
  • Loading branch information
davigonz committed Dec 4, 2019
1 parent 01e970c commit 1e9168f
Show file tree
Hide file tree
Showing 28 changed files with 171 additions and 203 deletions.
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
buildscript {
ext {

// SDK
sdkCompileVersion = 28
sdkMinVersion = 19
sdkTargetVersion = 28

// Android jetpack
archLifecycleVersion = "2.1.0"
roomVersion = "2.2.2"
appCompat = "1.1.0"
sqliteVersion = "2.0.1"
lifecycleLiveData = "2.0.0"

// Kotlin
kotlinVersion = "1.3.50"
Expand Down
2 changes: 1 addition & 1 deletion owncloud-android-library
6 changes: 3 additions & 3 deletions owncloudApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ allOpen {
}

android {
compileSdkVersion 28
compileSdkVersion sdkCompileVersion

defaultConfig {
minSdkVersion 19
targetSdkVersion 28
minSdkVersion sdkMinVersion
targetSdkVersion sdkTargetVersion

versionCode = 21300100
versionName = "2.13.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
*
* @author David A. Velasco
* Copyright (C) 2017 ownCloud GmbH.
* <p>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
* <p>
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
Expand All @@ -21,11 +21,9 @@

import android.os.Parcel;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
Expand All @@ -39,7 +37,6 @@
*
* See http://developer.android.com/intl/es/training/testing/unit-testing/instrumented-unit-tests.html .
*/
@RunWith(AndroidJUnit4.class)
@SmallTest
public class OCFileUnitTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,19 @@ import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.matcher.IntentMatchers
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.rule.ActivityTestRule
import com.owncloud.android.R
import com.owncloud.android.ui.activity.LocalFolderPickerActivity
import com.owncloud.android.ui.activity.Preferences
import org.junit.Assert
import org.junit.Assert.assertTrue
import org.junit.After
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.After
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class OCSettingsCameraUploadsTest {

@Rule
@JvmField
val activityRule = ActivityTestRule(Preferences::class.java, true, true)
Expand All @@ -68,7 +63,7 @@ class OCSettingsCameraUploadsTest {
}

@After
fun tearDown(){
fun tearDown() {
//Clean preferences
PreferenceManager.getDefaultSharedPreferences(context).edit().clear().commit()
}
Expand Down Expand Up @@ -100,9 +95,14 @@ class OCSettingsCameraUploadsTest {
@Test
fun optionsCameraFolderBehaviour() {
//Asserts
onView(withText(String.format(
activityRule.activity.getString(R.string.prefs_camera_upload_source_path_title),
activityRule.activity.getString(R.string.prefs_camera_upload_source_path_title_required))))
onView(
withText(
String.format(
activityRule.activity.getString(R.string.prefs_camera_upload_source_path_title),
activityRule.activity.getString(R.string.prefs_camera_upload_source_path_title_required)
)
)
)
.check(doesNotExist())
onView(withText(R.string.prefs_camera_upload_behaviour_title)).check(doesNotExist())
onView(withText(R.string.pref_behaviour_entries_keep_file)).check(doesNotExist())
Expand Down Expand Up @@ -176,9 +176,14 @@ class OCSettingsCameraUploadsTest {
fun cameraFolderView() {
enableCameraPictureUploads()
//Asserts
onView(withText(String.format(
activityRule.activity.getString(R.string.prefs_camera_upload_source_path_title),
activityRule.activity.getString(R.string.prefs_camera_upload_source_path_title_required))))
onView(
withText(
String.format(
activityRule.activity.getString(R.string.prefs_camera_upload_source_path_title),
activityRule.activity.getString(R.string.prefs_camera_upload_source_path_title_required)
)
)
)
.check(matches(isDisplayed()))
}

Expand All @@ -190,9 +195,14 @@ class OCSettingsCameraUploadsTest {
).absolutePath + "/Camera";
Intents.init()
//Asserts
onView(withText(String.format(
activityRule.activity.getString(R.string.prefs_camera_upload_source_path_title),
activityRule.activity.getString(R.string.prefs_camera_upload_source_path_title_required))))
onView(
withText(
String.format(
activityRule.activity.getString(R.string.prefs_camera_upload_source_path_title),
activityRule.activity.getString(R.string.prefs_camera_upload_source_path_title_required)
)
)
)
.perform(click())
Intents.intended(IntentMatchers.hasComponent(LocalFolderPickerActivity::class.java.name))
IntentMatchers.hasExtra(LocalFolderPickerActivity.EXTRA_PATH, cameraFolder)
Expand All @@ -209,12 +219,12 @@ class OCSettingsCameraUploadsTest {
onView(withText(R.string.pref_behaviour_entries_move)).check(matches(isDisplayed()))
}

fun enableCameraPictureUploads(){
fun enableCameraPictureUploads() {
onView(withText(R.string.prefs_camera_picture_upload)).perform(click());
onView(withText(android.R.string.ok)).perform(click())
}

fun enableCameraVideoUploads(){
fun enableCameraVideoUploads() {
onView(withText(R.string.prefs_camera_video_upload)).perform(click());
onView(withText(android.R.string.ok)).perform(click())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/


package com.owncloud.android.settings.camerauploads

import android.os.Environment
Expand All @@ -27,16 +26,13 @@ import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
import com.owncloud.android.R
import com.owncloud.android.ui.activity.LocalFolderPickerActivity
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class OCSettingsLocalFolderPickerTest {

@Rule
Expand All @@ -46,26 +42,26 @@ class OCSettingsLocalFolderPickerTest {
val errorMessage = "Activity not finished"

@Test
fun localFolderPickerView(){
fun localFolderPickerView() {
onView(withId(R.id.folder_picker_btn_cancel)).check(matches(isDisplayed()))
onView(withId(R.id.folder_picker_btn_choose)).check(matches(isDisplayed()))
onView(withId(R.id.folder_picker_btn_home)).check(matches(isDisplayed()))
}

@Test
fun cancelButtonDismiss(){
fun cancelButtonDismiss() {
onView(withId(R.id.folder_picker_btn_cancel)).perform(click())
assertTrue(errorMessage, activityRule.activity.isFinishing)
}

@Test
fun chooseButtonDismiss(){
fun chooseButtonDismiss() {
onView(withId(R.id.folder_picker_btn_choose)).perform(click())
assertTrue(errorMessage, activityRule.activity.isFinishing)
}

@Test
fun homeButtonBrowsesToHome(){
fun homeButtonBrowsesToHome() {
onView(withId(R.id.folder_picker_btn_home)).perform(click())
val path = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DCIM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import androidx.test.espresso.intent.matcher.IntentMatchers.hasType
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.rule.ActivityTestRule
import com.owncloud.android.R
Expand All @@ -45,49 +44,51 @@ import org.hamcrest.Matchers
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class OCSettingsLogTest {

@Rule
@JvmField
val activityRule = ActivityTestRule(LogHistoryActivity::class.java, true, true)

@Before
fun setUp() {}
fun setUp() {
}

@Test
fun checkTitle(){
fun checkTitle() {
onView(withText(R.string.actionbar_logger)).check(matches(isDisplayed()))
}

@Test
fun itemsToolbar(){
fun itemsToolbar() {
onView(withId(R.id.menu_search)).check(matches(isDisplayed()))
openActionBarOverflowOrOptionsMenu(InstrumentationRegistry.getInstrumentation().targetContext)
onView(withText("Logcat")).check(matches(isDisplayed()))
}

@Test
fun logHistoryButtons(){
fun logHistoryButtons() {
onView(withId(R.id.deleteLogHistoryButton)).check(matches(isDisplayed()))
onView(withId(R.id.sendLogHistoryButton)).check(matches(isDisplayed()))
}

@Test
fun sendLogHistory(){
fun sendLogHistory() {
Intents.init()
val intentResult = Instrumentation.ActivityResult(Activity.RESULT_OK, Intent())
intending(hasAction(Intent.ACTION_SEND_MULTIPLE)).respondWith(intentResult);
onView(withId(R.id.sendLogHistoryButton)).perform(click())
intended(
Matchers.allOf(
hasAction(Intent.ACTION_SEND_MULTIPLE),
hasExtra(Intent.EXTRA_SUBJECT,
hasExtra(
Intent.EXTRA_SUBJECT,
String.format(
activityRule.activity.getString(R.string.log_send_mail_subject),
activityRule.activity.getString(R.string.app_name))),
activityRule.activity.getString(R.string.app_name)
)
),
hasType("text/plain"),
hasFlag(Intent.FLAG_ACTIVITY_NEW_TASK)
)
Expand Down
Loading

0 comments on commit 1e9168f

Please sign in to comment.