LCOV - code coverage report
Current view: top level - test-0.12.24+8/lib/src/backend - test_platform.dart (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 1 5 20.0 %
Date: 2017-10-10 20:17:03 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright (c) 2015, 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 'dart:collection';
       6             : 
       7             : // TODO(nweiz): support pluggable platforms.
       8             : /// An enum of all platforms on which tests can run.
       9             : class TestPlatform {
      10             :   // When adding new platforms, be sure to update the baseline and derived
      11             :   // variable tests in test/backend/platform_selector/evaluate_test.
      12             : 
      13             :   /// The command-line Dart VM.
      14             :   static const TestPlatform vm =
      15             :       const TestPlatform._("VM", "vm", isDartVM: true);
      16             : 
      17             :   /// Dartium.
      18             :   static const TestPlatform dartium = const TestPlatform._("Dartium", "dartium",
      19             :       isBrowser: true, isBlink: true, isDartVM: true);
      20             : 
      21             :   /// Dartium content shell.
      22             :   static const TestPlatform contentShell = const TestPlatform._(
      23             :       "Dartium Content Shell", "content-shell",
      24             :       isBrowser: true, isBlink: true, isDartVM: true, isHeadless: true);
      25             : 
      26             :   /// Google Chrome.
      27             :   static const TestPlatform chrome = const TestPlatform._("Chrome", "chrome",
      28             :       isBrowser: true, isJS: true, isBlink: true);
      29             : 
      30             :   /// PhantomJS.
      31             :   static const TestPlatform phantomJS = const TestPlatform._(
      32             :       "PhantomJS", "phantomjs",
      33             :       isBrowser: true, isJS: true, isBlink: true, isHeadless: true);
      34             : 
      35             :   /// Mozilla Firefox.
      36             :   static const TestPlatform firefox =
      37             :       const TestPlatform._("Firefox", "firefox", isBrowser: true, isJS: true);
      38             : 
      39             :   /// Apple Safari.
      40             :   static const TestPlatform safari =
      41             :       const TestPlatform._("Safari", "safari", isBrowser: true, isJS: true);
      42             : 
      43             :   /// Microsoft Internet Explorer.
      44             :   static const TestPlatform internetExplorer = const TestPlatform._(
      45             :       "Internet Explorer", "ie",
      46             :       isBrowser: true, isJS: true);
      47             : 
      48             :   /// The command-line Node.js VM.
      49             :   static const TestPlatform nodeJS =
      50             :       const TestPlatform._("Node.js", "node", isJS: true);
      51             : 
      52             :   /// A list of all instances of [TestPlatform].
      53             :   static final UnmodifiableListView<TestPlatform> all =
      54             :       new UnmodifiableListView<TestPlatform>(_allPlatforms);
      55             : 
      56             :   /// Finds a platform by its identifier string.
      57             :   ///
      58             :   /// If no platform is found, returns `null`.
      59             :   static TestPlatform find(String identifier) =>
      60           0 :       all.firstWhere((platform) => platform.identifier == identifier,
      61             :           orElse: () => null);
      62             : 
      63             :   /// The human-friendly name of the platform.
      64             :   final String name;
      65             : 
      66             :   /// The identifier used to look up the platform.
      67             :   final String identifier;
      68             : 
      69             :   /// Whether this platform runs the Dart VM in any capacity.
      70             :   final bool isDartVM;
      71             : 
      72             :   /// Whether this platform is a browser.
      73             :   final bool isBrowser;
      74             : 
      75             :   /// Whether this platform runs Dart compiled to JavaScript.
      76             :   final bool isJS;
      77             : 
      78             :   /// Whether this platform uses the Blink rendering engine.
      79             :   final bool isBlink;
      80             : 
      81             :   /// Whether this platform has no visible window.
      82             :   final bool isHeadless;
      83             : 
      84             :   const TestPlatform._(this.name, this.identifier,
      85             :       {this.isDartVM: false,
      86             :       this.isBrowser: false,
      87             :       this.isJS: false,
      88             :       this.isBlink: false,
      89           5 :       this.isHeadless: false});
      90             : 
      91           0 :   String toString() => name;
      92             : }
      93             : 
      94             : final List<TestPlatform> _allPlatforms = [
      95             :   TestPlatform.vm,
      96             :   TestPlatform.dartium,
      97             :   TestPlatform.contentShell,
      98             :   TestPlatform.chrome,
      99             :   TestPlatform.phantomJS,
     100             :   TestPlatform.firefox,
     101             :   TestPlatform.safari,
     102             :   TestPlatform.internetExplorer,
     103             :   TestPlatform.nodeJS
     104             : ];
     105             : 
     106             : /// **Do not call this function without express permission from the test package
     107             : /// authors**.
     108             : ///
     109             : /// This constructs and globally registers a new TestPlatform with the provided
     110             : /// details.
     111             : TestPlatform registerTestPlatform(String name, String identifier,
     112             :     {bool isDartVM: false,
     113             :     bool isBrowser: false,
     114             :     bool isJS: false,
     115             :     bool isBlink: false,
     116             :     bool isHeadless: false}) {
     117           0 :   var platform = new TestPlatform._(name, identifier,
     118             :       isDartVM: isDartVM,
     119             :       isBrowser: isBrowser,
     120             :       isJS: isJS,
     121             :       isBlink: isBlink,
     122             :       isHeadless: isHeadless);
     123           0 :   _allPlatforms.add(platform);
     124             :   return platform;
     125             : }

Generated by: LCOV version 1.13