-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: forward isInitialRun from instrumentation app to app under test
- Loading branch information
1 parent
7683960
commit 21d4862
Showing
5 changed files
with
60 additions
and
6 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
32 changes: 30 additions & 2 deletions
32
packages/patrol/android/src/main/kotlin/pl/leancode/patrol/PatrolPlugin.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 |
---|---|---|
@@ -1,24 +1,52 @@ | ||
package pl.leancode.patrol | ||
|
||
import io.flutter.embedding.engine.plugins.FlutterPlugin | ||
import io.flutter.embedding.engine.plugins.activity.ActivityAware | ||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding | ||
import io.flutter.plugin.common.MethodCall | ||
import io.flutter.plugin.common.MethodChannel | ||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler | ||
import io.flutter.plugin.common.MethodChannel.Result | ||
|
||
class PatrolPlugin : FlutterPlugin, MethodCallHandler { | ||
class PatrolPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { | ||
private lateinit var channel: MethodChannel | ||
|
||
private var isInitialRun: Boolean? = null | ||
|
||
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { | ||
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "pl.leancode.patrol/main") | ||
channel.setMethodCallHandler(this) | ||
} | ||
|
||
override fun onMethodCall(call: MethodCall, result: Result) { | ||
result.notImplemented() | ||
when (call.method) { | ||
"inInitialRun" -> result.success(isInitialRun) | ||
else -> result.notImplemented() | ||
} | ||
} | ||
|
||
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) { | ||
channel.setMethodCallHandler(null) | ||
} | ||
|
||
override fun onAttachedToActivity(binding: ActivityPluginBinding) { | ||
val intent = binding.activity.intent | ||
if (!intent.hasExtra("isInitialRun")) { | ||
throw IllegalStateException("PatrolPlugin must be initialized with intent having isInitialRun boolean") | ||
} | ||
|
||
isInitialRun = intent.getBooleanExtra("isInitialRun", false) | ||
} | ||
|
||
override fun onDetachedFromActivityForConfigChanges() { | ||
// Do nothing | ||
} | ||
|
||
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) { | ||
// Do nothing | ||
} | ||
|
||
override fun onDetachedFromActivity() { | ||
// Do nothing | ||
} | ||
} |
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