• 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 'dart:io';
6
7// Whether the current dart code is running in an environment that was compiled
8// to JavaScript.
9const bool _kIsCompiledToJavaScript = identical(0, 0.0);
10
11/// Whether the test is running on the Windows operating system.
12///
13/// This does not include test compiled to JavaScript running in a browser on
14/// the Windows operating system.
15bool get isWindows {
16  if (_kIsCompiledToJavaScript) {
17    return false;
18  }
19  return Platform.isWindows;
20}
21
22/// Whether the test is running on the macOS operating system.
23///
24/// This does not include test compiled to JavaScript running in a browser on
25/// the macOS operating system.
26bool get isMacOS {
27  if (_kIsCompiledToJavaScript) {
28    return false;
29  }
30  return Platform.isMacOS;
31}
32
33/// Whether the test is running on the Linux operating system.
34///
35/// This does not include test compiled to JavaScript running in a browser on
36/// the Linux operating system.
37bool get isLinux {
38  if (_kIsCompiledToJavaScript) {
39    return false;
40  }
41  return Platform.isLinux;
42}
43
44/// Whether the test is running in a web browser compiled to JavaScript.
45bool get isBrowser {
46  return _kIsCompiledToJavaScript;
47}
48