• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2019 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import 'package:flutter_driver/src/common/find.dart';
6
7import '../common.dart';
8
9void main() {
10  test('Ancestor finder serialize', () {
11    const SerializableFinder of = ByType('Text');
12    final SerializableFinder matching = ByValueKey('hello');
13
14    final Ancestor a = Ancestor(
15      of: of,
16      matching: matching,
17      matchRoot: true,
18    );
19    expect(a.serialize(), <String, String>{
20      'finderType': 'Ancestor',
21      'of_finderType': 'ByType',
22      'of_type': 'Text',
23      'matching_finderType': 'ByValueKey',
24      'matching_keyValueString': 'hello',
25      'matching_keyValueType': 'String',
26      'matchRoot': 'true'
27    });
28  });
29
30  test('Ancestor finder deserialize', () {
31    final Map<String, String> serialized = <String, String>{
32      'finderType': 'Ancestor',
33      'of_finderType': 'ByType',
34      'of_type': 'Text',
35      'matching_finderType': 'ByValueKey',
36      'matching_keyValueString': 'hello',
37      'matching_keyValueType': 'String',
38      'matchRoot': 'true'
39    };
40
41    final Ancestor a = Ancestor.deserialize(serialized);
42    expect(a.of, isA<ByType>());
43    expect(a.matching, isA<ByValueKey>());
44    expect(a.matchRoot, isTrue);
45  });
46
47  test('Descendant finder serialize', () {
48    const SerializableFinder of = ByType('Text');
49    final SerializableFinder matching = ByValueKey('hello');
50
51    final Descendant a = Descendant(
52      of: of,
53      matching: matching,
54      matchRoot: true,
55    );
56    expect(a.serialize(), <String, String>{
57      'finderType': 'Descendant',
58      'of_finderType': 'ByType',
59      'of_type': 'Text',
60      'matching_finderType': 'ByValueKey',
61      'matching_keyValueString': 'hello',
62      'matching_keyValueType': 'String',
63      'matchRoot': 'true'
64    });
65  });
66
67  test('Descendant finder deserialize', () {
68    final Map<String, String> serialized = <String, String>{
69      'finderType': 'Descendant',
70      'of_finderType': 'ByType',
71      'of_type': 'Text',
72      'matching_finderType': 'ByValueKey',
73      'matching_keyValueString': 'hello',
74      'matching_keyValueType': 'String',
75      'matchRoot': 'true'
76    };
77
78    final Descendant a = Descendant.deserialize(serialized);
79    expect(a.of, isA<ByType>());
80    expect(a.matching, isA<ByValueKey>());
81    expect(a.matchRoot, isTrue);
82  });
83}
84