Line data Source code
1 : // Copyright (c) 2016, 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 : /// A message emitted by a test. 6 : /// 7 : /// A message encompasses any textual information that should be presented to 8 : /// the user. Reporters are encouraged to visually distinguish different message 9 : /// types. 10 : class Message { 11 : final MessageType type; 12 : 13 : final String text; 14 : 15 0 : Message(this.type, this.text); 16 : 17 0 : Message.print(this.text) : type = MessageType.print; 18 0 : Message.skip(this.text) : type = MessageType.skip; 19 : } 20 : 21 : class MessageType { 22 : /// A message explicitly printed by the user's test. 23 : static const print = MessageType._('print'); 24 : 25 : /// A message indicating that a test, or some portion of one, was skipped. 26 : static const skip = MessageType._('skip'); 27 : 28 : /// The name of the message type. 29 : final String name; 30 : 31 0 : factory MessageType.parse(String name) { 32 : switch (name) { 33 0 : case 'print': 34 : return MessageType.print; 35 0 : case 'skip': 36 : return MessageType.skip; 37 : default: 38 0 : throw ArgumentError('Invalid message type "$name".'); 39 : } 40 : } 41 : 42 11 : const MessageType._(this.name); 43 : 44 0 : @override 45 0 : String toString() => name; 46 : }