platform.dart 1.44 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io';

7 8 9 10 11 12
/// Whether the test is running in a web browser compiled to JavaScript.
///
/// See also:
///
///  * [kIsWeb], the equivalent constant in the `foundation` library.
const bool isBrowser = identical(0, 0.0);
13 14 15

/// Whether the test is running on the Windows operating system.
///
16
/// This does not include tests compiled to JavaScript running in a browser on
17
/// the Windows operating system.
18 19 20 21
///
/// See also:
///
///  * [isBrowser], which reports true for tests running in browsers.
22
bool get isWindows {
23
  if (isBrowser) {
24 25 26 27 28 29 30
    return false;
  }
  return Platform.isWindows;
}

/// Whether the test is running on the macOS operating system.
///
31
/// This does not include tests compiled to JavaScript running in a browser on
32
/// the macOS operating system.
33 34 35 36
///
/// See also:
///
///  * [isBrowser], which reports true for tests running in browsers.
37
bool get isMacOS {
38
  if (isBrowser) {
39 40 41 42 43 44 45
    return false;
  }
  return Platform.isMacOS;
}

/// Whether the test is running on the Linux operating system.
///
46
/// This does not include tests compiled to JavaScript running in a browser on
47
/// the Linux operating system.
48 49 50 51
///
/// See also:
///
///  * [isBrowser], which reports true for tests running in browsers.
52
bool get isLinux {
53
  if (isBrowser) {
54 55 56 57
    return false;
  }
  return Platform.isLinux;
}