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
@bartekpacia
bartekpacia / Foo.jmm
Last active April 19, 2024 05:02
Example JMM files
class Foo {
public int constInstr() {
return 0;
}
public int add(int a, int b) {
int c;
c = a + this.constInstr();
return 0;
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
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.
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
PatrolTester $;
$.native.grantPermissionWhenInUse()
$.native.grantPermissionOnlyThisTime();
$.native.denyPermission();
@bartekpacia
bartekpacia / main.dart
Last active August 11, 2023 11:42
Nested groups and test cases example.
class DartTestGroup {
String name = '';
List<DartTestCase> tests = [];
List<DartTestGroup> groups = [];
DartTestGroup({
required this.name,
this.tests = const [],
this.groups = const [],
});
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.
{
"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.
// 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.
@import XCTest;
@import ObjectiveC.runtime;
@interface ParametrizedTests : XCTestCase
@end
@implementation ParametrizedTests
+ (NSArray<NSInvocation *> *)testInvocations {
NSLog(@"testInvocations() called");