Skip to content

Commit

Permalink
Merge branch 'develop' into PAINTROID-662, fix merge conflics, make f…
Browse files Browse the repository at this point in the history
…ormat
  • Loading branch information
msesko committed Dec 28, 2023
2 parents 1125f7b + 8063d84 commit 1a6f1b8
Show file tree
Hide file tree
Showing 43 changed files with 1,508 additions and 467 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ jobs:
uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: subosito/flutter-action@v2.5.0
- uses: subosito/flutter-action@v2.10.0
with:
flutter-version: '3.10.5'
channel: 'stable'
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
cache-path: '${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:'
architecture: x64 # optional, x64 or arm64
- name: Setup
run: |
flutter pub get
Expand Down
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.PHONY: pubget build watch clean test analyze test-unit test-widget test-all all

clean:
flutter clean

pubget:
flutter pub get

build:
dart run build_runner build --delete-conflicting-outputs

run:
flutter run

all: clean pubget build run

watch:
dart run build_runner watch --delete-conflicting-outputs

analyze:
flutter analyze

test-unit:
flutter test test/unit

test-widget:
flutter test test/widget

test-all:
flutter test
1 change: 0 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ analyzer:
exclude:
- lib/**.pb*.dart
- lib/data/*.g.dart
- test/**
15 changes: 10 additions & 5 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.PHONY: run pods-clean get clean build languages lint format test watch

FLUTTER := fvm flutter

run:
Expand All @@ -15,7 +17,10 @@ get:
$(FLUTTER) pub get
melos bootstrap

build-runner:
clean:
melos clean

build:
melos run build:all

languages:
Expand All @@ -29,8 +34,8 @@ lint:
format:
dart format --set-exit-if-changed .

clean:
melos clean
test:
melos run test:all

testing:
melos run test:all
watch:
dart run build_runner watch --delete-conflicting-outputs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Mocks generated by Mockito 5.4.1 from annotations
// in paintroid/test/landing_page_test.dart.
// Mocks generated by Mockito 5.4.2 from annotations
// in landing_page_screen/test/landing_page_test.dart.
// Do not manually edit this file.

// @dart=2.19

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i3;
import 'dart:io' as _i11;
Expand Down Expand Up @@ -88,6 +86,7 @@ class MockProjectDatabase extends _i1.Mock implements _i6.ProjectDatabase {
Invocation.getter(#projectDAO),
),
) as _i2.ProjectDAO);

@override
_i3.StreamController<String> get changeListener => (super.noSuchMethod(
Invocation.getter(#changeListener),
Expand All @@ -96,6 +95,7 @@ class MockProjectDatabase extends _i1.Mock implements _i6.ProjectDatabase {
Invocation.getter(#changeListener),
),
) as _i3.StreamController<String>);

@override
set changeListener(_i3.StreamController<String>? _changeListener) =>
super.noSuchMethod(
Expand All @@ -105,6 +105,7 @@ class MockProjectDatabase extends _i1.Mock implements _i6.ProjectDatabase {
),
returnValueForMissingStub: null,
);

@override
_i4.DatabaseExecutor get database => (super.noSuchMethod(
Invocation.getter(#database),
Expand All @@ -113,6 +114,7 @@ class MockProjectDatabase extends _i1.Mock implements _i6.ProjectDatabase {
Invocation.getter(#database),
),
) as _i4.DatabaseExecutor);

@override
set database(_i4.DatabaseExecutor? _database) => super.noSuchMethod(
Invocation.setter(
Expand All @@ -121,6 +123,7 @@ class MockProjectDatabase extends _i1.Mock implements _i6.ProjectDatabase {
),
returnValueForMissingStub: null,
);

@override
_i3.Future<void> close() => (super.noSuchMethod(
Invocation.method(
Expand Down Expand Up @@ -148,6 +151,7 @@ class MockProjectDAO extends _i1.Mock implements _i2.ProjectDAO {
),
returnValue: _i3.Future<int>.value(0),
) as _i3.Future<int>);

@override
_i3.Future<List<int>> insertProjects(List<_i7.Project>? projects) =>
(super.noSuchMethod(
Expand All @@ -157,6 +161,7 @@ class MockProjectDAO extends _i1.Mock implements _i2.ProjectDAO {
),
returnValue: _i3.Future<List<int>>.value(<int>[]),
) as _i3.Future<List<int>>);

@override
_i3.Future<void> deleteProject(int? id) => (super.noSuchMethod(
Invocation.method(
Expand All @@ -166,6 +171,7 @@ class MockProjectDAO extends _i1.Mock implements _i2.ProjectDAO {
returnValue: _i3.Future<void>.value(),
returnValueForMissingStub: _i3.Future<void>.value(),
) as _i3.Future<void>);

@override
_i3.Future<void> deleteProjects(List<_i7.Project>? projects) =>
(super.noSuchMethod(
Expand All @@ -176,6 +182,7 @@ class MockProjectDAO extends _i1.Mock implements _i2.ProjectDAO {
returnValue: _i3.Future<void>.value(),
returnValueForMissingStub: _i3.Future<void>.value(),
) as _i3.Future<void>);

@override
_i3.Future<List<_i7.Project>> getProjects() => (super.noSuchMethod(
Invocation.method(
Expand All @@ -184,6 +191,7 @@ class MockProjectDAO extends _i1.Mock implements _i2.ProjectDAO {
),
returnValue: _i3.Future<List<_i7.Project>>.value(<_i7.Project>[]),
) as _i3.Future<List<_i7.Project>>);

@override
_i3.Future<_i7.Project?> getProjectByName(String? name) =>
(super.noSuchMethod(
Expand Down Expand Up @@ -220,6 +228,7 @@ class MockIImageService extends _i1.Mock implements _i8.IImageService {
),
)),
) as _i3.Future<_i5.Result<_i9.Image, _i8.Failure>>);

@override
_i3.Future<_i5.Result<_i10.Uint8List, _i8.Failure>> exportAsJpg(
_i9.Image? image,
Expand All @@ -245,6 +254,7 @@ class MockIImageService extends _i1.Mock implements _i8.IImageService {
),
)),
) as _i3.Future<_i5.Result<_i10.Uint8List, _i8.Failure>>);

@override
_i3.Future<_i5.Result<_i10.Uint8List, _i8.Failure>> exportAsPng(
_i9.Image? image) =>
Expand All @@ -262,6 +272,7 @@ class MockIImageService extends _i1.Mock implements _i8.IImageService {
),
)),
) as _i3.Future<_i5.Result<_i10.Uint8List, _i8.Failure>>);

@override
_i5.Result<_i10.Uint8List, _i8.Failure> getProjectPreview(String? path) =>
(super.noSuchMethod(
Expand Down Expand Up @@ -312,6 +323,7 @@ class MockIFileService extends _i1.Mock implements _i8.IFileService {
),
)),
) as _i3.Future<_i5.Result<_i11.File, _i8.Failure>>);

@override
_i3.Future<_i5.Result<_i11.File, _i8.Failure>> saveToApplicationDirectory(
String? filename,
Expand All @@ -337,6 +349,7 @@ class MockIFileService extends _i1.Mock implements _i8.IFileService {
),
)),
) as _i3.Future<_i5.Result<_i11.File, _i8.Failure>>);

@override
_i3.Future<_i5.Result<_i11.File, _i8.Failure>> pick() => (super.noSuchMethod(
Invocation.method(
Expand All @@ -352,6 +365,7 @@ class MockIFileService extends _i1.Mock implements _i8.IFileService {
),
)),
) as _i3.Future<_i5.Result<_i11.File, _i8.Failure>>);

@override
_i5.Result<_i11.File, _i8.Failure> getFile(String? path) =>
(super.noSuchMethod(
Expand All @@ -367,6 +381,7 @@ class MockIFileService extends _i1.Mock implements _i8.IFileService {
),
),
) as _i5.Result<_i11.File, _i8.Failure>);

@override
_i3.Future<bool> checkIfFileExistsInApplicationDirectory(String? fileName) =>
(super.noSuchMethod(
Expand All @@ -376,6 +391,7 @@ class MockIFileService extends _i1.Mock implements _i8.IFileService {
),
returnValue: _i3.Future<bool>.value(false),
) as _i3.Future<bool>);

@override
_i3.Future<_i5.Result<_i11.FileSystemEntity, _i8.Failure>>
deleteFileInApplicationDirectory(String? fileName) => (super.noSuchMethod(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,18 @@ class _DrawingCanvasState extends ConsumerState<DrawingCanvas> {
_resetCanvasScale(fitToScreen: isFullscreen);
},
);
final canvasSize = ref.watch(
canvasStateProvider.select((state) => state.size),
);
final panningMargin = (canvasSize - const Offset(5, 5)) as Size;
return Listener(
onPointerDown: _onPointerDown,
onPointerUp: _onPointerUp,
child: InteractiveViewer(
clipBehavior: Clip.none,
transformationController: _transformationController,
boundaryMargin: EdgeInsets.symmetric(
horizontal: panningMargin.width,
vertical: panningMargin.height,
),
minScale: 0.2,
maxScale: 100,
panEnabled: false,
boundaryMargin: const EdgeInsets.all(double.infinity),
interactionEndFrictionCoefficient: double.minPositive,
panEnabled:
ref.watch(toolBoxStateProvider).currentTool.type == ToolType.HAND,
onInteractionStart: _onInteractionStart,
onInteractionUpdate: _onInteractionUpdate,
onInteractionEnd: _onInteractionEnd,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CanvasInteractions {

List<Offset> lastOffsets = [];

Future<CanvasInteractions> drawLineFromCenter(Offset offset) async {
Future<CanvasInteractions> dragFromCenter(Offset offset) async {
final drawingCanvasFinder = find.byType(CanvasPainter);
expect(drawingCanvasFinder, findsOneWidget);
await _tester.drag(drawingCanvasFinder, offset);
Expand Down
4 changes: 2 additions & 2 deletions packages/features/workspace_screen/test/eraser_tool_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ void main() {
const testOffset = Offset(10, 10);

final pixelColorBeforeErase = await canvasInteractions
.drawLineFromCenter(testOffset)
.dragFromCenter(testOffset)
.then((_) => canvasInteractions.getPixelColor(300, 300));
expect(pixelColorBeforeErase, isNot(equals(0)));

await bottomNavBarInteractions.selectTool(ToolData.ERASER);

final pixelColorAfterErase = await canvasInteractions
.drawLineFromCenter(testOffset)
.dragFromCenter(testOffset)
.then((_) => canvasInteractions.getPixelColor(300, 300));
expect(pixelColorAfterErase, equals(0));
},
Expand Down
73 changes: 73 additions & 0 deletions packages/features/workspace_screen/test/hand_tool_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:l10n/l10n.dart';
import 'package:tools/tools.dart';
import 'package:workspace_screen/workspace_screen.dart';

import 'bottom_nav_bar_interactions.dart';
import 'interactive_viewer_interactions.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

late Widget sut;

setUp(() {
sut = ProviderScope(
overrides: [
IDeviceService.sizeProvider
.overrideWith((ref) => Future.value(const Size(600, 600)))
],
child: const MaterialApp(
home: WorkspaceScreen(),
localizationsDelegates: [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
],
),
);
});

testWidgets('Pan bottom left', (WidgetTester tester) async {
await tester.pumpWidget(sut);
await tester.pumpAndSettle();

final bottomNavBarInteractions = BottomNavBarInteractions(tester);
final interactiveViewerInteractions = InterActiveViewerInteractions(tester);
await bottomNavBarInteractions.selectTool(ToolData.HAND);
await interactiveViewerInteractions.panAndVerify(const Offset(-50, 50));
});

testWidgets('Pan bottom right', (WidgetTester tester) async {
await tester.pumpWidget(sut);
await tester.pumpAndSettle();

final bottomNavBarInteractions = BottomNavBarInteractions(tester);
final interactiveViewerInteractions = InterActiveViewerInteractions(tester);
await bottomNavBarInteractions.selectTool(ToolData.HAND);
await interactiveViewerInteractions.panAndVerify(const Offset(50, 50));
});

testWidgets('Pan top left', (WidgetTester tester) async {
await tester.pumpWidget(sut);
await tester.pumpAndSettle();

final bottomNavBarInteractions = BottomNavBarInteractions(tester);
final interactiveViewerInteractions = InterActiveViewerInteractions(tester);
await bottomNavBarInteractions.selectTool(ToolData.HAND);
await interactiveViewerInteractions.panAndVerify(const Offset(-50, -50));
});

testWidgets('Pan top right', (WidgetTester tester) async {
await tester.pumpWidget(sut);
await tester.pumpAndSettle();

final bottomNavBarInteractions = BottomNavBarInteractions(tester);
final interactiveViewerInteractions = InterActiveViewerInteractions(tester);
await bottomNavBarInteractions.selectTool(ToolData.HAND);
await interactiveViewerInteractions.panAndVerify(const Offset(50, -50));
});
}
Loading

0 comments on commit 1a6f1b8

Please sign in to comment.