Skip to content

Instantly share code, notes, and snippets.

View bartekpacia's full-sized avatar
😎
just an enjoyer

Bartek Pacia bartekpacia

😎
just an enjoyer
View GitHub Profile
View main.dart
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
View callbacks_all_test.dart
import 'package:meta/meta.dart';
import 'package:test/test.dart';
// ignore: depend_on_referenced_packages
import 'package:test_api/src/backend/invoker.dart';
// Input:
const String requestedTest = 'testA';
// Global state:
@bartekpacia
bartekpacia / callbacks_test.dart
Created September 21, 2023 11:40
A mini-example of executing a single Dart test with its lifecycle callbacks.
View callbacks_test.dart
import 'package:flutter_test/flutter_test.dart';
import 'package:patrol/src/extensions.dart';
// ignore: depend_on_referenced_packages
import 'package:test_api/src/backend/invoker.dart';
const String requestedTest = 'groupA testA';
String get currentTest => Invoker.current!.fullCurrentTestName();
void main() {
@bartekpacia
bartekpacia / intro_permissions_1.dart
Last active September 19, 2023 14:20
Flutter Silesia #6 snippets
View intro_permissions_1.dart
PatrolTester $;
$.native.grantPermissionWhenInUse()
$.native.grantPermissionOnlyThisTime();
$.native.denyPermission();
@bartekpacia
bartekpacia / main.dart
Last active August 11, 2023 11:42
Nested groups and test cases example.
View main.dart
class DartTestGroup {
String name = '';
List<DartTestCase> tests = [];
List<DartTestGroup> groups = [];
DartTestGroup({
required this.name,
this.tests = const [],
this.groups = const [],
});
View Part 1 - verbose code 1.dart
testWidgets('signs up', (WidgetTester tester) async {
await tester.pumpWidget(ExampleApp());
await tester.pumpAndSettle();
await tester.enterText(
find.byKey(Key('emailTextField')),
'charlie@root.me',
);
await tester.pumpAndSettle();
await tester.enterText(
find.byKey(Key('nameTextField')),
@bartekpacia
bartekpacia / carbon-width-80
Last active September 14, 2023 10:26
My Carbon config for Dart code.
View carbon-width-80
{
"paddingVertical": "0px",
"paddingHorizontal": "0px",
"backgroundImage": null,
"backgroundImageSelection": null,
"backgroundMode": "color",
"backgroundColor": "rgba(171, 184, 195, 1)",
"dropShadow": false,
"dropShadowOffsetY": "20px",
"dropShadowBlurRadius": "68px",
@bartekpacia
bartekpacia / test_bundle.dart
Created May 16, 2023 12:56
File generated by Patrol CLI for the "integration_test" directory with 2 test files.
View test_bundle.dart
// ignore_for_file: invalid_use_of_internal_member,
// depend_on_referenced_packages, directives_ordering
import 'dart:async';
import 'package:flutter_test/flutter_test.dart';
import 'package:patrol/patrol.dart';
import 'package:patrol/src/native/contracts/contracts.pbgrpc.dart';
import 'package:test_api/src/backend/invoker.dart';
@bartekpacia
bartekpacia / RunnerTests.m
Last active November 16, 2023 11:36
This snippet shows how to dynamically create test cases in XCTest.
View RunnerTests.m
@import XCTest;
@import ObjectiveC.runtime;
@interface ParametrizedTests : XCTestCase
@end
@implementation ParametrizedTests
+ (NSArray<NSInvocation *> *)testInvocations {
NSLog(@"testInvocations() called");
@bartekpacia
bartekpacia / file.m
Created April 26, 2023 22:21
$ clang -framework Foundation file.m -o file
View file.m
#import <Foundation/Foundation.h>
@interface PatrolIntegrationTestRunner : NSObject
+ (NSString *)createMethodNameFromPatrolGeneratedGroup:(NSString *)dartTestGroup;
@end
@implementation PatrolIntegrationTestRunner
- (instancetype)init {
self = [super init];