Skip to content

Commit 7952fc4

Browse files
committed
test: adding TermsAndConditionsUIParams tests
1 parent b5df063 commit 7952fc4

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

test/google_navigation_flutter_test.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ void main() {
10161016
const String companyName = 'Temp co.';
10171017
const bool showDriverAwareness = true;
10181018
when(
1019-
sessionMockApi.showTermsAndConditionsDialog(any, any, any),
1019+
sessionMockApi.showTermsAndConditionsDialog(any, any, any, any),
10201020
).thenAnswer((Invocation _) async => true);
10211021
final bool accepted =
10221022
await GoogleMapsNavigator.showTermsAndConditionsDialog(
@@ -1031,11 +1031,13 @@ void main() {
10311031
captureAny,
10321032
captureAny,
10331033
captureAny,
1034+
captureAny,
10341035
),
10351036
);
10361037
expect(result.captured[0] as String, title);
10371038
expect(result.captured[1] as String, companyName);
10381039
expect(result.captured[2] as bool, showDriverAwareness);
1040+
expect(result.captured[3], null); // uiParams is null by default
10391041

10401042
// Reset terms and conditions.
10411043
await GoogleMapsNavigator.resetTermsAccepted();

test/google_navigation_flutter_test.mocks.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,14 @@ class MockTestNavigationSessionApi extends _i1.Mock
115115
String? title,
116116
String? companyName,
117117
bool? shouldOnlyShowDriverAwarenessDisclaimer,
118+
_i2.TermsAndConditionsUIParamsDto? uiParams,
118119
) =>
119120
(super.noSuchMethod(
120121
Invocation.method(#showTermsAndConditionsDialog, [
121122
title,
122123
companyName,
123124
shouldOnlyShowDriverAwarenessDisclaimer,
125+
uiParams,
124126
]),
125127
returnValue: _i4.Future<bool>.value(false),
126128
)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2025 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+
// https://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+
15+
import 'package:flutter/material.dart';
16+
import 'package:flutter_test/flutter_test.dart';
17+
import 'package:google_navigation_flutter/google_navigation_flutter.dart';
18+
19+
void main() {
20+
group('TermsAndConditionsUIParams tests', () {
21+
test('converts to DTO correctly with all parameters', () {
22+
const params = TermsAndConditionsUIParams(
23+
backgroundColor: Color(0xFFFFFFFF),
24+
titleColor: Color(0xFF1976D2),
25+
mainTextColor: Color(0xFF212121),
26+
acceptButtonTextColor: Color(0xFF4CAF50),
27+
cancelButtonTextColor: Color(0xFFF44336),
28+
);
29+
30+
final dto = params.toDto();
31+
32+
expect(dto.backgroundColor, 0xFFFFFFFF);
33+
expect(dto.titleColor, 0xFF1976D2);
34+
expect(dto.mainTextColor, 0xFF212121);
35+
expect(dto.acceptButtonTextColor, 0xFF4CAF50);
36+
expect(dto.cancelButtonTextColor, 0xFFF44336);
37+
});
38+
39+
test('converts to DTO correctly with null parameters', () {
40+
const params = TermsAndConditionsUIParams();
41+
42+
final dto = params.toDto();
43+
44+
expect(dto.backgroundColor, null);
45+
expect(dto.titleColor, null);
46+
expect(dto.mainTextColor, null);
47+
expect(dto.acceptButtonTextColor, null);
48+
expect(dto.cancelButtonTextColor, null);
49+
});
50+
});
51+
}

0 commit comments

Comments
 (0)