flutter/dev/benchmarks/metrics_center/test/legacy_flutter_test.dart
Yuqian Li ac1ebf4889
Migrate the rest of the metrics center library (#73875)
Some notable changes are:
- Add SkiaPerfDestination
- Add LegacyFlutterDestination (for backup options during transitions).
- Add GcsLock

Related issue: https://github.com/flutter/flutter/issues/73872
2021-01-15 13:15:05 -08:00

41 lines
1.5 KiB
Dart

// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:gcloud/src/datastore_impl.dart';
import 'package:googleapis_auth/auth_io.dart';
import 'package:metrics_center/src/common.dart';
import 'package:metrics_center/src/legacy_flutter.dart';
import 'common.dart';
import 'utility.dart';
const String kTestSourceId = 'test';
void main() {
final Map<String, dynamic> credentialsJson = getTestGcpCredentialsJson();
test(
'LegacyFlutterDestination integration test: '
'update does not crash.', () async {
final LegacyFlutterDestination dst =
await LegacyFlutterDestination.makeFromCredentialsJson(credentialsJson);
await dst.update(<MetricPoint>[MetricPoint(1.0, const <String, String>{})]);
}, skip: credentialsJson == null);
test(
'LegacyFlutterDestination integration test: '
'can update with an access token.', () async {
final AutoRefreshingAuthClient client = await clientViaServiceAccount(
ServiceAccountCredentials.fromJson(credentialsJson),
DatastoreImpl.SCOPES,
);
final String token = client.credentials.accessToken.data;
final LegacyFlutterDestination dst =
LegacyFlutterDestination.makeFromAccessToken(
token,
credentialsJson[kProjectId] as String,
);
await dst.update(<MetricPoint>[MetricPoint(1.0, const <String, String>{})]);
}, skip: credentialsJson == null);
}