Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[shared_preferences] Test can detect that SharedPreferences is mocked. #4433

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/camera/camera/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
group 'io.flutter.plugins.camera'
version '1.0-SNAPSHOT'
def args = ["-Xlint:deprecation","-Xlint:unchecked","-Werror"]
def args = ["-Xlint:deprecation","-Xlint:unchecked"]

buildscript {
repositories {
Expand Down
4 changes: 4 additions & 0 deletions packages/shared_preferences/shared_preferences/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.9

* SharedPreferences mock is detectable

## 2.0.8

* Update minimum Flutter SDK to 2.5 and iOS deployment target to 9.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,15 @@ class SharedPreferences {
InMemorySharedPreferencesStore.withData(newValues);
_completer = null;
}

/// reports if this instance is mocked
///
/// An instance turns to being mocked after a call to [setMockInitialValues]
///
/// true if changes on the current delegate will not write to the disk
/// false if shared preferences behaves as normal
@visibleForTesting
bool isMocked() {
return _store is InMemorySharedPreferencesStore;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for reading and writing simple key-value pairs.
Wraps NSUserDefaults on iOS and SharedPreferences on Android.
repository: https://github.com/flutter/plugins/tree/master/packages/shared_preferences/shared_preferences
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+shared_preferences%22
version: 2.0.8
version: 2.0.9

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down
9 changes: 6 additions & 3 deletions script/tool/lib/src/create_all_plugins_app_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,13 @@ class CreateAllPluginsAppCommand extends PluginCommand {

final StringBuffer newGradle = StringBuffer();
for (final String line in gradleFile.readAsLinesSync()) {
if (line.contains('minSdkVersion 16')) {
// Android SDK 20 is required by Google maps.
// Android SDK 19 is required by WebView.
if (line.contains('minSdkVersion')) {
// minSdkVersion 20 is required by Google maps.
// minSdkVersion 19 is required by WebView.
newGradle.writeln('minSdkVersion 20');
} else if (line.contains('compileSdkVersion')) {
// compileSdkVersion 31 is required by Camera.
newGradle.writeln('compileSdkVersion 31');
} else {
newGradle.writeln(line);
}
Expand Down