LCOV - code coverage report
Current view: top level - test_api-0.4.8/lib/src/backend - suite_platform.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 6 11 54.5 %
Date: 2021-11-28 14:37:50 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright (c) 2018, the Dart project authors.  Please see the AUTHORS file
       2             : // for details. All rights reserved. Use of this source code is governed by a
       3             : // BSD-style license that can be found in the LICENSE file.
       4             : 
       5             : import 'operating_system.dart';
       6             : import 'runtime.dart';
       7             : 
       8             : /// The platform on which a test suite is loaded.
       9             : class SuitePlatform {
      10             :   /// The runtime that hosts the suite.
      11             :   final Runtime runtime;
      12             : 
      13             :   /// The operating system on which the suite is running.
      14             :   ///
      15             :   /// This will always be [OperatingSystem.none] if `runtime.isBrowser` is
      16             :   /// true.
      17             :   final OperatingSystem os;
      18             : 
      19             :   /// Whether we're running on Google-internal infrastructure.
      20             :   final bool inGoogle;
      21             : 
      22             :   /// Creates a new platform with the given [runtime] and [os], which defaults
      23             :   /// to [OperatingSystem.none].
      24             :   ///
      25             :   /// Throws an [ArgumentError] if [runtime] is a browser and [os] is not
      26             :   /// `null` or [OperatingSystem.none].
      27          11 :   SuitePlatform(this.runtime,
      28             :       {this.os = OperatingSystem.none, this.inGoogle = false}) {
      29          22 :     if (runtime.isBrowser && os != OperatingSystem.none) {
      30           0 :       throw ArgumentError('No OS should be passed for runtime "$runtime".');
      31             :     }
      32             :   }
      33             : 
      34             :   /// Converts a JSON-safe representation generated by [serialize] back into a
      35             :   /// [SuitePlatform].
      36          11 :   factory SuitePlatform.deserialize(Object serialized) {
      37             :     var map = serialized as Map;
      38          33 :     return SuitePlatform(Runtime.deserialize(map['runtime'] as Object),
      39          22 :         os: OperatingSystem.find(map['os'] as String),
      40          11 :         inGoogle: map['inGoogle'] as bool);
      41             :   }
      42             : 
      43             :   /// Converts [this] into a JSON-safe object that can be converted back to a
      44             :   /// [SuitePlatform] using [SuitePlatform.deserialize].
      45           0 :   Object serialize() => {
      46           0 :         'runtime': runtime.serialize(),
      47           0 :         'os': os.identifier,
      48           0 :         'inGoogle': inGoogle
      49             :       };
      50             : }

Generated by: LCOV version 1.14