Skip to content

Commit 6c66ad2

Browse files
authored
Replace testbed/ with plugin examples (#913)
The testbed/ directory is a relic of a much earlier stage of desktop development, when maintaining apps was cumbersome (because they had to be recreated from scratch on a regular basis, before the template stabilized) and it was useful to have a desktop-enabled example handy for basic functionality like scrolling and typing that were still being implemented. This removes testbed/, and replaces it with standard in-package examples for the two remaining plugins (the other purpose of testbed). Each is created with `flutter create -t plugin .` with the following changes: - Removed all the template comments. - Removed the template-standard used of `flutter_lints` (as the repo uses flutter/plugins-based lints). - Added the copyright notice. - Changed the example Dart code: - `menubar`'s example is the counter app, but with the resize-on-launch logic taken from `testbed`. - `testbed`'s example is testbed's code, but with the keyboard and scrolling parts removed. - Changed the template-standard integration test to be a simple sanity check that calling the plugin works. - Removed the (new!) template-standard macOS native unit tests, since backfilling unit tests is out of scope here. The scaffolding is still in place in case we want to add some later. Having the standard example structure will make the plugins easier to maintain when we do need to touch them, and easier for people to find out how to use. Tangential change: - Updates the CI hosts since the macOS and Linux hosts that were there are deprecated.
1 parent 17d4710 commit 6c66ad2

File tree

153 files changed

+4871
-1465
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+4871
-1465
lines changed

.github/workflows/ci.yml

+17-7
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ jobs:
77
runs-on: ${{ matrix.os }}
88
strategy:
99
matrix:
10-
os: [macOS-10.15, windows-2019, ubuntu-18.04]
10+
os: [macOS-12, windows-2019, ubuntu-22.04]
1111
include:
12-
- os: macOS-10.15
12+
- os: macOS-12
1313
TARGET: macos
14-
- os: ubuntu-18.04
14+
- os: ubuntu-22.04
1515
TARGET: linux
1616
- os: windows-2019
1717
TARGET: windows
@@ -52,13 +52,23 @@ jobs:
5252
- name: Doctor
5353
# Run doctor, for ease of debugging any issues.
5454
run: flutter doctor -v
55-
- name: Build testbed debug
55+
- name: Build menubar debug
5656
run: |
5757
flutter packages get
5858
flutter build -v ${{matrix.TARGET}} --debug
59-
working-directory: ${{ github.workspace }}/fde/testbed
60-
- name: Build testbed release
59+
working-directory: ${{ github.workspace }}/fde/plugins/menubar/example
60+
- name: Build menubar release
6161
run: |
6262
flutter packages get
6363
flutter build -v ${{matrix.TARGET}} --release
64-
working-directory: ${{ github.workspace }}/fde/testbed
64+
working-directory: ${{ github.workspace }}/fde/plugins/menubar/example
65+
- name: Build window_size debug
66+
run: |
67+
flutter packages get
68+
flutter build -v ${{matrix.TARGET}} --debug
69+
working-directory: ${{ github.workspace }}/fde/plugins/window_size/example
70+
- name: Build window_size release
71+
run: |
72+
flutter packages get
73+
flutter build -v ${{matrix.TARGET}} --release
74+
working-directory: ${{ github.workspace }}/fde/plugins/window_size/example

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ please file issues here.
2626
The `plugins` directory contains all the plugins. See
2727
[its README](plugins/README.md) to get started.
2828

29-
`testbed` is a a simple test application for the plugins above.
30-
3129
## Caveats
3230

3331
* This is not an officially supported Google product.

analysis_options.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ linter:
5151
- empty_statements
5252
- hash_and_equals
5353
- implementation_imports
54-
- invariant_booleans
5554
- iterable_contains_unrelated_type
5655
- join_return_with_assignment
5756
- library_names

plugins/menubar/example/.gitignore

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
**/doc/api/
26+
**/ios/Flutter/.last_build_id
27+
.dart_tool/
28+
.flutter-plugins
29+
.flutter-plugins-dependencies
30+
.packages
31+
.pub-cache/
32+
.pub/
33+
/build/
34+
35+
# Symbolication related
36+
app.*.symbols
37+
38+
# Obfuscation related
39+
app.*.map.json
40+
41+
# Android Studio will place build artifacts here
42+
/android/app/debug
43+
/android/app/profile
44+
/android/app/release

plugins/menubar/example/README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# menubar_example
2+
3+
Demonstrates how to use the menubar plugin.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter application.
8+
9+
A few resources to get you started if this is your first Flutter project:
10+
11+
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12+
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
13+
14+
For help getting started with Flutter development, view the
15+
[online documentation](https://docs.flutter.dev/), which offers tutorials,
16+
samples, guidance on mobile development, and a full API reference.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2018 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
import 'package:flutter/material.dart';
15+
import 'package:flutter/services.dart';
16+
import 'package:flutter_test/flutter_test.dart';
17+
import 'package:integration_test/integration_test.dart';
18+
19+
import 'package:menubar/menubar.dart';
20+
21+
void main() {
22+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
23+
24+
testWidgets('sanity check', (tester) async {
25+
expect(
26+
setApplicationMenu([
27+
NativeSubmenu(label: 'Test', children: [
28+
NativeMenuItem(
29+
label: '1',
30+
shortcut: LogicalKeySet(
31+
LogicalKeyboardKey.meta, LogicalKeyboardKey.keyA),
32+
onSelected: () {}),
33+
const NativeMenuDivider(),
34+
NativeSubmenu(label: 'Presets', children: [
35+
NativeMenuItem(
36+
label: '2',
37+
shortcut: LogicalKeySet(LogicalKeyboardKey.meta,
38+
LogicalKeyboardKey.shift, LogicalKeyboardKey.keyB),
39+
onSelected: null),
40+
])
41+
]),
42+
]),
43+
completes);
44+
});
45+
}

testbed/lib/main.dart plugins/menubar/example/lib/main.dart

+7-91
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,13 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
import 'dart:io' show Platform;
15-
import 'dart:math' as math;
16-
1714
import 'package:flutter/material.dart';
1815
import 'package:flutter/services.dart';
1916

2017
import 'package:menubar/menubar.dart';
21-
import 'package:window_size/window_size.dart' as window_size;
22-
23-
import 'keyboard_test_page.dart';
2418

2519
void main() {
26-
// Try to resize and reposition the window to be half the width and height
27-
// of its screen, centered horizontally and shifted up from center.
28-
WidgetsFlutterBinding.ensureInitialized();
29-
window_size.getWindowInfo().then((window) {
30-
final screen = window.screen;
31-
if (screen != null) {
32-
final screenFrame = screen.visibleFrame;
33-
final width = math.max((screenFrame.width / 2).roundToDouble(), 800.0);
34-
final height = math.max((screenFrame.height / 2).roundToDouble(), 600.0);
35-
final left = ((screenFrame.width - width) / 2).roundToDouble();
36-
final top = ((screenFrame.height - height) / 3).roundToDouble();
37-
final frame = Rect.fromLTWH(left, top, width, height);
38-
window_size.setWindowFrame(frame);
39-
window_size.setWindowMinSize(Size(0.8 * width, 0.8 * height));
40-
window_size.setWindowMaxSize(Size(1.5 * width, 1.5 * height));
41-
window_size
42-
.setWindowTitle('Flutter Testbed on ${Platform.operatingSystem}');
43-
}
44-
});
45-
46-
runApp(new MyApp());
20+
runApp(const MyApp());
4721
}
4822

4923
/// Top level widget for the application.
@@ -52,7 +26,7 @@ class MyApp extends StatefulWidget {
5226
const MyApp({Key? key}) : super(key: key);
5327

5428
@override
55-
_AppState createState() => new _AppState();
29+
State<MyApp> createState() => _AppState();
5630
}
5731

5832
class _AppState extends State<MyApp> {
@@ -96,7 +70,7 @@ class _AppState extends State<MyApp> {
9670
: () {
9771
setPrimaryColor(Colors.blue);
9872
}),
99-
NativeMenuDivider(),
73+
const NativeMenuDivider(),
10074
NativeSubmenu(label: 'Presets', children: [
10175
NativeMenuItem(
10276
label: 'Red',
@@ -137,7 +111,7 @@ class _AppState extends State<MyApp> {
137111
: () {
138112
_setCounter(0);
139113
}),
140-
NativeMenuDivider(),
114+
const NativeMenuDivider(),
141115
NativeMenuItem(
142116
label: 'Increment',
143117
shortcut: LogicalKeySet(LogicalKeyboardKey.f2),
@@ -193,36 +167,9 @@ class _MyHomePage extends StatelessWidget {
193167
const Text(
194168
'You have pushed the button this many times:',
195169
),
196-
new Text(
170+
Text(
197171
'$counter',
198-
style: Theme.of(context).textTheme.headline4,
199-
),
200-
TextInputTestWidget(),
201-
new ElevatedButton(
202-
child: new Text('Test raw keyboard events'),
203-
onPressed: () {
204-
Navigator.of(context).push(new MaterialPageRoute(
205-
builder: (context) => KeyboardTestPage()));
206-
},
207-
),
208-
Padding(
209-
padding: const EdgeInsets.all(8.0),
210-
child: Container(
211-
width: 380.0,
212-
height: 100.0,
213-
decoration: BoxDecoration(
214-
border: Border.all(color: Colors.grey, width: 1.0)),
215-
child: Scrollbar(
216-
child: ListView.builder(
217-
padding: EdgeInsets.all(8.0),
218-
itemExtent: 20.0,
219-
itemCount: 50,
220-
itemBuilder: (context, index) {
221-
return Text('entry $index');
222-
},
223-
),
224-
),
225-
),
172+
style: Theme.of(context).textTheme.headlineMedium,
226173
),
227174
],
228175
),
@@ -234,38 +181,7 @@ class _MyHomePage extends StatelessWidget {
234181
floatingActionButton: FloatingActionButton(
235182
onPressed: _AppState.of(context)!.incrementCounter,
236183
tooltip: 'Increment',
237-
child: Icon(Icons.add),
238-
),
239-
);
240-
}
241-
}
242-
243-
/// A widget containing controls to test text input.
244-
class TextInputTestWidget extends StatelessWidget {
245-
@override
246-
Widget build(BuildContext context) {
247-
return Row(
248-
mainAxisAlignment: MainAxisAlignment.center,
249-
children: const <Widget>[
250-
SampleTextField(),
251-
SampleTextField(),
252-
],
253-
);
254-
}
255-
}
256-
257-
/// A text field with styling suitable for including in a TextInputTestWidget.
258-
class SampleTextField extends StatelessWidget {
259-
/// Creates a new sample text field.
260-
const SampleTextField();
261-
262-
@override
263-
Widget build(BuildContext context) {
264-
return Container(
265-
width: 200.0,
266-
padding: const EdgeInsets.all(10.0),
267-
child: TextField(
268-
decoration: InputDecoration(border: OutlineInputBorder()),
184+
child: const Icon(Icons.add),
269185
),
270186
);
271187
}
File renamed without changes.

0 commit comments

Comments
 (0)