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

Commit ab4c38d

Browse files
committed
Test can detect that SharedPrefernces is mocked.
Checking wheter a integration test using shared_preferences as the storage backend should be able to check that the current instance is mocked. Not checking could result in overriding could override app runtime data or calling [setMockInitialValues] could lead to overriding data from the test. Updated pubspecVersion and changelog.md closes #1 fixing formating Merge to latest master Bump compileSdkVersion to 31 (#4432)
1 parent 176cfb8 commit ab4c38d

File tree

5 files changed

+23
-5
lines changed

5 files changed

+23
-5
lines changed

packages/camera/camera/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
group 'io.flutter.plugins.camera'
22
version '1.0-SNAPSHOT'
3-
def args = ["-Xlint:deprecation","-Xlint:unchecked","-Werror"]
3+
def args = ["-Xlint:deprecation","-Xlint:unchecked"]
44

55
buildscript {
66
repositories {

packages/shared_preferences/shared_preferences/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.9
2+
3+
* SharedPreferences mock is detectable
4+
15
## 2.0.8
26

37
* Update minimum Flutter SDK to 2.5 and iOS deployment target to 9.0.

packages/shared_preferences/shared_preferences/lib/shared_preferences.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,15 @@ class SharedPreferences {
212212
InMemorySharedPreferencesStore.withData(newValues);
213213
_completer = null;
214214
}
215+
216+
/// reports if this instance is mocked
217+
///
218+
/// An instance turns to being mocked after a call to [setMockInitialValues]
219+
///
220+
/// true if changes on the current delegate will not write to the disk
221+
/// false if shared preferences behaves as normal
222+
@visibleForTesting
223+
bool isMocked() {
224+
return _store is InMemorySharedPreferencesStore;
225+
}
215226
}

packages/shared_preferences/shared_preferences/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for reading and writing simple key-value pairs.
33
Wraps NSUserDefaults on iOS and SharedPreferences on Android.
44
repository: https://github.com/flutter/plugins/tree/master/packages/shared_preferences/shared_preferences
55
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+shared_preferences%22
6-
version: 2.0.8
6+
version: 2.0.9
77

88
environment:
99
sdk: ">=2.14.0 <3.0.0"

script/tool/lib/src/create_all_plugins_app_command.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,13 @@ class CreateAllPluginsAppCommand extends PluginCommand {
9393

9494
final StringBuffer newGradle = StringBuffer();
9595
for (final String line in gradleFile.readAsLinesSync()) {
96-
if (line.contains('minSdkVersion 16')) {
97-
// Android SDK 20 is required by Google maps.
98-
// Android SDK 19 is required by WebView.
96+
if (line.contains('minSdkVersion')) {
97+
// minSdkVersion 20 is required by Google maps.
98+
// minSdkVersion 19 is required by WebView.
9999
newGradle.writeln('minSdkVersion 20');
100+
} else if (line.contains('compileSdkVersion')) {
101+
// compileSdkVersion 31 is required by Camera.
102+
newGradle.writeln('compileSdkVersion 31');
100103
} else {
101104
newGradle.writeln(line);
102105
}

0 commit comments

Comments
 (0)