screenshot_command_test.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 7 8 9 10 11 12 13 14 15 16 17
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter_tools/src/commands/screenshot.dart';

import '../src/common.dart';
import '../src/context.dart';

void main() {
  group('Validate screenshot options', () {
    testUsingContext('rasterizer and skia screenshots do not require a device', () async {
      ScreenshotCommand.validateOptions('rasterizer', null, 'dummy_observatory_uri');
      ScreenshotCommand.validateOptions('skia', null, 'dummy_observatory_uri');
    });

    testUsingContext('rasterizer and skia screenshots require observatory uri', () async {
18 19 20 21 22 23 24 25 26 27 28 29
      expect(
          () => ScreenshotCommand.validateOptions('rasterizer', null, null),
          throwsToolExit(
              message:
                  'Observatory URI must be specified for screenshot type rasterizer'));
      expect(
          () => ScreenshotCommand.validateOptions('skia', null, null),
          throwsToolExit(
              message:
                  'Observatory URI must be specified for screenshot type skia'));
      expect(() => ScreenshotCommand.validateOptions('skia', null, ''),
          throwsToolExit(message: 'Observatory URI "" is invalid'));
30 31 32 33 34 35 36
    });

    testUsingContext('device screenshots require device', () async {
      expect(() => ScreenshotCommand.validateOptions('device', null, null), throwsToolExit());
    });
  });
}