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

Commit bf2ad1e

Browse files
not for landing - try no-op test
1 parent e342558 commit bf2ad1e

File tree

1 file changed

+2
-87
lines changed

1 file changed

+2
-87
lines changed

packages/shared_preferences/shared_preferences/example/integration_test/shared_preferences_test.dart

Lines changed: 2 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -4,98 +4,13 @@
44

55
import 'package:flutter_test/flutter_test.dart';
66
import 'package:integration_test/integration_test.dart';
7-
import 'package:shared_preferences/shared_preferences.dart';
87

98
void main() {
109
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
1110

12-
group('$SharedPreferences', () {
13-
const String testString = 'hello world';
14-
const bool testBool = true;
15-
const int testInt = 42;
16-
const double testDouble = 3.14159;
17-
const List<String> testList = <String>['foo', 'bar'];
18-
19-
const String testString2 = 'goodbye world';
20-
const bool testBool2 = false;
21-
const int testInt2 = 1337;
22-
const double testDouble2 = 2.71828;
23-
const List<String> testList2 = <String>['baz', 'quox'];
24-
25-
late SharedPreferences preferences;
26-
27-
setUp(() async {
28-
preferences = await SharedPreferences.getInstance();
29-
});
30-
31-
tearDown(() {
32-
preferences.clear();
33-
});
34-
11+
group('SharedPreferences', () {
3512
testWidgets('reading', (WidgetTester _) async {
36-
expect(preferences.get('String'), isNull);
37-
expect(preferences.get('bool'), isNull);
38-
expect(preferences.get('int'), isNull);
39-
expect(preferences.get('double'), isNull);
40-
expect(preferences.get('List'), isNull);
41-
expect(preferences.getString('String'), isNull);
42-
expect(preferences.getBool('bool'), isNull);
43-
expect(preferences.getInt('int'), isNull);
44-
expect(preferences.getDouble('double'), isNull);
45-
expect(preferences.getStringList('List'), isNull);
46-
});
47-
48-
testWidgets('writing', (WidgetTester _) async {
49-
await Future.wait(<Future<bool>>[
50-
preferences.setString('String', testString2),
51-
preferences.setBool('bool', testBool2),
52-
preferences.setInt('int', testInt2),
53-
preferences.setDouble('double', testDouble2),
54-
preferences.setStringList('List', testList2)
55-
]);
56-
expect(preferences.getString('String'), testString2);
57-
expect(preferences.getBool('bool'), testBool2);
58-
expect(preferences.getInt('int'), testInt2);
59-
expect(preferences.getDouble('double'), testDouble2);
60-
expect(preferences.getStringList('List'), testList2);
61-
});
62-
63-
testWidgets('removing', (WidgetTester _) async {
64-
const String key = 'testKey';
65-
await preferences.setString(key, testString);
66-
await preferences.setBool(key, testBool);
67-
await preferences.setInt(key, testInt);
68-
await preferences.setDouble(key, testDouble);
69-
await preferences.setStringList(key, testList);
70-
await preferences.remove(key);
71-
expect(preferences.get('testKey'), isNull);
72-
});
73-
74-
testWidgets('clearing', (WidgetTester _) async {
75-
await preferences.setString('String', testString);
76-
await preferences.setBool('bool', testBool);
77-
await preferences.setInt('int', testInt);
78-
await preferences.setDouble('double', testDouble);
79-
await preferences.setStringList('List', testList);
80-
await preferences.clear();
81-
expect(preferences.getString('String'), null);
82-
expect(preferences.getBool('bool'), null);
83-
expect(preferences.getInt('int'), null);
84-
expect(preferences.getDouble('double'), null);
85-
expect(preferences.getStringList('List'), null);
86-
});
87-
88-
testWidgets('simultaneous writes', (WidgetTester _) async {
89-
final List<Future<bool>> writes = <Future<bool>>[];
90-
const int writeCount = 100;
91-
for (int i = 1; i <= writeCount; i++) {
92-
writes.add(preferences.setInt('int', i));
93-
}
94-
final List<bool> result = await Future.wait(writes, eagerError: true);
95-
// All writes should succeed.
96-
expect(result.where((bool element) => !element), isEmpty);
97-
// The last write should win.
98-
expect(preferences.getInt('int'), writeCount);
13+
expect(true, isTrue);
9914
});
10015
});
10116
}

0 commit comments

Comments
 (0)