-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some more abstraction into different product flavors
Sms module now has a mock() variant for easier testing, this was cared to not be possible to ship with mockRelease (check variant filtering in sms module build.gradle) With this, I hope to get a better better abstraction hence, better enviroment for integration tests. Notice how the main folder of the sms module keeps the interface which represents the contract to outer layers (mobile-ui) in this case, slowly but surely this moves us closer to the onion/clean arch. For #29 See also: #25, #38
- Loading branch information
1 parent
321e0f5
commit cd1a8cc
Showing
19 changed files
with
240 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
transport-eta-android/mobile-ui/src/androidTest/AndroidManifest.xml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="com.joaquimley.transporteta" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<application> | ||
<activity android:name=".ui.testing.TestFragmentActivity"> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
2 changes: 1 addition & 1 deletion
2
...nsporteta/ui/test/TestFragmentActivity.kt → ...orteta/ui/testing/TestFragmentActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ansporteta/ui/test/factory/DataFactory.kt → ...porteta/ui/testing/factory/DataFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...i/test/factory/FavoriteViewTestFactory.kt → ...esting/factory/FavoriteViewTestFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...ui/src/main/java/com/joaquimley/transporteta/ui/di/component/TestActivityBindingModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.joaquimley.transporteta.ui.di.component | ||
|
||
import com.joaquimley.transporteta.ui.di.module.HomeFragmentsBuildersModule | ||
import com.joaquimley.transporteta.ui.injection.scope.PerActivity | ||
import com.joaquimley.transporteta.ui.testing.TestFragmentActivity | ||
import dagger.Module | ||
import dagger.android.ContributesAndroidInjector | ||
|
||
@Module | ||
abstract class TestActivityBindingModule { | ||
|
||
@PerActivity | ||
@ContributesAndroidInjector(modules = arrayOf(HomeFragmentsBuildersModule::class)) | ||
abstract fun bindTestFragmentActivity(): TestFragmentActivity | ||
} |
22 changes: 0 additions & 22 deletions
22
...t-eta-android/mobile-ui/src/mock/java/com/joaquimley/transporteta/ui/SmsControllerMock.kt
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
...a-android/mobile-ui/src/mock/java/com/joaquimley/transporteta/ui/SmsControllerMockImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.joaquimley.transporteta.ui | ||
|
||
import com.joaquimley.transporteta.sms.SmsBroadcastReceiver | ||
import com.joaquimley.transporteta.sms.SmsControllerImpl | ||
import com.joaquimley.transporteta.sms.model.SmsModel | ||
import io.reactivex.Observable | ||
import java.util.* | ||
import javax.inject.Inject | ||
|
||
class SmsControllerMockImpl @Inject constructor(smsBroadcastReceiver: SmsBroadcastReceiver) : SmsControllerImpl(smsBroadcastReceiver) { | ||
override fun dispose() { | ||
} | ||
|
||
override fun observeIncomingSms(): Observable<SmsModel> { | ||
return Observable.just(SmsModel(Random().nextInt(), UUID.randomUUID().toString()), | ||
SmsModel(Random().nextInt(), UUID.randomUUID().toString()), | ||
SmsModel(Random().nextInt(), UUID.randomUUID().toString()), | ||
SmsModel(Random().nextInt(), UUID.randomUUID().toString())) | ||
} | ||
|
||
override fun requestEta(busStopCode: Int) { | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.joaquimley.transporteta.sms"/> | ||
<manifest package="com.joaquimley.transporteta.sms"/> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...eta-android/sms/src/prod/java/com/joaquimley/transporteta/sms/SmsBroadcastReceiverImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.joaquimley.transporteta.sms | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.provider.Telephony | ||
import javax.inject.Inject | ||
|
||
/** | ||
* A broadcast receiver who listens for incoming SMS | ||
*/ | ||
|
||
class SmsBroadcastReceiverImpl @Inject constructor(serviceNumber: String, serviceSmsCondition: String) | ||
: SmsBroadcastReceiver(serviceNumber, serviceSmsCondition) { | ||
|
||
override fun onReceive(context: Context, intent: Intent) { | ||
if (intent.action == Telephony.Sms.Intents.SMS_RECEIVED_ACTION) { | ||
var smsBody = "" | ||
var smsSender = "" | ||
for (smsMessage in Telephony.Sms.Intents.getMessagesFromIntent(intent)) { | ||
smsSender = smsMessage.displayOriginatingAddress | ||
smsBody += smsMessage.messageBody | ||
} | ||
|
||
if (smsSender == serviceNumber && smsBody.startsWith(serviceSmsCondition)) { | ||
broadcastServiceSms.onNext(smsBody) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.