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
var policy = Policy | |
.Handle<SomeExceptionType>() | |
.Retry(); | |
var result = policy.Execute(() => DoSomething()); |
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
private static readonly Regex AppIdPattern = "fg=([0-z]{1,10}):\"com.example.yourpackagename\"".ToRegex(); | |
private static readonly Regex TimeOnBatteryPattern = @"(Time on battery: .+?) \(".ToRegex(); | |
private static BatteryStatistics ExtractBatteryStatsFromLog(string batteryLog) | |
{ | |
var appId = AppIdPattern.Match(batteryLog).Groups[1].Value; | |
var wifiUsagePattern = $@"{appId}:[\s]+?(Wi-Fi network: .*?packets \d+ received, \d+ sent\))".ToRegex(); | |
var wifiUsage = wifiUsagePattern.Match(batteryLog).Groups[1].Value; | |
var wifiUsageBreakdown = NetworkUsageBreakdown.CreateFromLogLine(wifiUsage); |
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
# emulate device being unplugged | |
adb shell dumpsys unplug | |
# reset existing battery stats. stats are captured from this point on | |
adb shell dumpsys batterystats --reset | |
# ------------------- | |
# RUN YOUR TESTS HERE | |
# ------------------- | |
# dump the battery stats and capture the output |
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
StartGroup: YourPhoneTests.AndroidBatteryTests.PhotoBatteryTest | |
Battery stats for test group: Photos | |
App UID: u0a207 | |
Battery Capacity: 3000mAh | |
Time on Battery: 00:04:25.9310000 | |
Battery Usage Breakdown: | |
Total Usage: 62.1mAh | |
Cpu Usage: 1.21mAh | |
Wifi Usage: 60.9mAh |
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
@NotNull | |
private static final Playground.CounterProperty myProperty$delegate; | |
public static final Playground INSTANCE; | |
static { | |
myProperty$delegate = new Playground.CounterProperty("foo"); | |
} | |
@NotNull | |
public final String getMyProperty() { |
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
val myProperty by CounterProperty("foo") | |
class CounterProperty(private val value: String) : ReadOnlyProperty<Any, String> { | |
private var counter = 0 | |
override fun getValue(thisRef: Any, property: KProperty<*>): String { | |
return synchronized(counter) { | |
println("Counter: ${++counter}") | |
value | |
} |
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
@NotNull | |
private static String notNull = "Hello"; | |
@Nullable | |
private static String maybeNull = "Hello"; | |
@NotNull | |
public static final String getNotNull() { | |
return notNull; | |
} |
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
@override | |
Widget build(BuildContext context) { | |
return new FutureBuilder<Repositories>( | |
future: apiClient.getUserRepositoriesFuture(username), | |
builder: (BuildContext context, | |
AsyncSnapshot<Repositories> snapshot) { | |
if (snapshot.hasError) | |
return new Center(child: new Text("Network error")); | |
if (!snapshot.hasData) | |
return new Center( |
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
class ToolbarDemo extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
appBar: new AppBar( | |
actions: <Widget>[ | |
new IconButton( | |
icon: new Icon(Icons.star), | |
onPressed: _handleClickFavorite |
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
Meta-Date for the Flutter app | |
http://cloc.sourceforge.net v 1.60 T=0.16 s (247.5 files/s, 14905.1 lines/s) | |
-------------------------------------------------------------------------------- | |
Language files blank comment code | |
-------------------------------------------------------------------------------- | |
Dart 31 263 39 1735 | |
Bourne Again Shell 1 19 20 121 | |
DOS Batch 1 24 2 64 | |
XML 3 3 22 35 |
NewerOlder