Skip to content

Commit

Permalink
New module :test-shared + gradle cleanup
Browse files Browse the repository at this point in the history
Bug: 72216577
Change-Id: I4de13f1b6f37e458df46b39106d24c3a1d349b7f
  • Loading branch information
JoseAlcerreca committed Feb 27, 2018
1 parent a18af0f commit 9ad9d4f
Show file tree
Hide file tree
Showing 14 changed files with 133 additions and 18 deletions.
11 changes: 11 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,14 @@ task clean(type: Delete) {
delete rootProject.buildDir
}

// Force all of the primary support libraries to use the same version.
configurations.all {
resolutionStrategy {
eachDependency { details ->
if (details.requested.group == 'com.android.support') {
details.useVersion supportLibraryVersion
}
}
}
}

7 changes: 7 additions & 0 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ android {

staging {
initWith debug

// Specifies a sorted list of fallback build types that the
// plugin should try to use when a dependency does not include a
// "staging" build type.
// Used with :test-shared, which doesn't have a staging variant.
matchingFallbacks = ['debug']
}
}
dataBinding {
Expand All @@ -49,6 +55,7 @@ android {

dependencies {
implementation project(":shared")
testImplementation project(':test-shared')

implementation fileTree(dir: 'libs', include: ['*.jar'])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.google.samples.apps.iosched.util
package com.google.samples.apps.iosched.test.util

import com.google.samples.apps.iosched.shared.usecases.internal.DefaultScheduler
import com.google.samples.apps.iosched.shared.usecases.internal.SyncScheduler
Expand All @@ -23,8 +23,6 @@ import org.junit.runner.Description

/**
* Rule to be used in tests that sets a synchronous task scheduler used to avoid race conditions.
*
* TODO: Move to testutils module b/72216577
*/
class SyncTaskExecutorRule : TestWatcher() {
override fun starting(description: Description?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import com.google.samples.apps.iosched.shared.data.tag.TagRepository
import com.google.samples.apps.iosched.shared.model.Session
import com.google.samples.apps.iosched.shared.model.Tag
import com.google.samples.apps.iosched.shared.util.TimeUtils.ConferenceDay
import com.google.samples.apps.iosched.util.LiveDataTestUtil
import com.google.samples.apps.iosched.util.SyncTaskExecutorRule
import com.google.samples.apps.iosched.test.util.SyncTaskExecutorRule
import com.google.samples.apps.iosched.test.util.LiveDataTestUtil
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
* limitations under the License.
*/

include ':mobile', ':shared', ':tv'
include ':mobile', ':tv', ':shared', ':test-shared'
20 changes: 12 additions & 8 deletions shared/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,12 @@ android {
dataBinding {
enabled true
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

// UI
implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:support-v4:$rootProject.supportLibraryVersion"
implementation "com.android.support.constraint:constraint-layout:$rootProject.constraintLayoutVersion"

// Architecture Components
implementation "android.arch.lifecycle:extensions:$rootProject.archLifecycleVersion"
implementation "android.arch.lifecycle:livedata:$rootProject.archLifecycleVersion"
Expand All @@ -78,15 +74,23 @@ dependencies {
kapt "com.google.dagger:dagger-compiler:$rootProject.dagger"
kapt "com.google.dagger:dagger-android-processor:$rootProject.dagger"


// ThreeTenBP for the shared module only. Date and time API for Java.
testImplementation "org.threeten:threetenbp:$rootProject.threetenbpVersion"
compileOnly "org.threeten:threetenbp:$rootProject.threetenbpVersion:no-tzdb"

// Unit tests
testImplementation "android.arch.core:core-testing:$rootProject.archLifecycleVersion"
testImplementation "junit:junit:$rootProject.junitVersion"
}

// Instrumentation tests
androidTestImplementation "com.android.support.test.espresso:espresso-core:$rootProject.espressoVersion"
androidTestImplementation "com.android.support.test:runner:$rootProject.runnerVersion"
// Force Dagger's transitive dependencies to use the project's version of the support libraries.
configurations.all {
resolutionStrategy {
eachDependency { details ->
if (details.requested.group == 'com.android.support') {
details.useVersion supportLibraryVersion
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SessionFilters {
*/
fun matchesSessionTags(sessionTags: List<Tag>): Boolean {
var match = true
filteredTags.groupBy { it.category }.forEach { category, tagsInCategory ->
filteredTags.groupBy { it.category }.forEach { _, tagsInCategory ->
if (sessionTags.intersect(tagsInCategory).isEmpty()) {
match = false
return@forEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package com.google.samples.apps.iosched.ui.schedule

import com.google.samples.apps.iosched.shared.model.Tag
import junit.framework.Assert.assertFalse
import junit.framework.Assert.assertTrue
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test

Expand Down
1 change: 1 addition & 0 deletions test-shared/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
48 changes: 48 additions & 0 deletions test-shared/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion rootProject.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {

// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$rootProject.kotlinVersion"

// Architecture Components
implementation "android.arch.lifecycle:extensions:$rootProject.archLifecycleVersion"
implementation "android.arch.lifecycle:livedata:$rootProject.archLifecycleVersion"
implementation "android.arch.lifecycle:viewmodel:$rootProject.archLifecycleVersion"
}
21 changes: 21 additions & 0 deletions test-shared/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
18 changes: 18 additions & 0 deletions test-shared/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!--
~ Copyright 2018 Google LLC
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.samples.apps.iosched.testshared"/>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.google.samples.apps.iosched.util
package com.google.samples.apps.iosched.test.util

import android.arch.lifecycle.LiveData
import android.arch.lifecycle.Observer
Expand Down
7 changes: 7 additions & 0 deletions tv/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ android {

staging {
initWith debug

// Specifies a sorted list of fallback build types that the
// plugin should try to use when a dependency does not include a
// "staging" build type.
// Used with :test-shared, which doesn't have a staging variant.
matchingFallbacks = ['debug']
}
}
dataBinding {
Expand All @@ -47,6 +53,7 @@ android {

dependencies {
implementation project(":shared")
testImplementation project(':test-shared')

// UI
implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
Expand Down

0 comments on commit 9ad9d4f

Please sign in to comment.