Flutter Engine
The Flutter Engine
multiemitter_test.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
3# for details. All rights reserved. Use of this source code is governed by a
4# BSD-style license that can be found in the LICENSE file.
5"""Tests for emitter module."""
6
7import logging.config
8import unittest
9import emitter
10import multiemitter
11
12
13class MultiEmitterTestCase(unittest.TestCase):
14
15 def setUp(self):
16 pass
17
18 def tearDown(self):
19 pass
20
21 def check(self, m, expected):
22 """Verifies that the multiemitter contains the expected contents.
23
24 Expected is a list of (filename, content) pairs, sorted by filename.
25 """
26 files = []
27
28 def _Collect(file, contents):
29 files.append((file, ''.join(contents)))
30
31 m.Flush(_Collect)
32 self.assertEqual(expected, files)
33
34 def testExample(self):
36 e1 = m.FileEmitter('file1')
37 e2 = m.FileEmitter('file2', 'key2')
38 e1.Emit('Hi 1')
39 e2.Emit('Hi 2')
40 m.Find('key2').Emit('Bye 2')
41 self.check(m, [('file1', 'Hi 1'), ('file2', 'Hi 2Bye 2')])
42
43
44if __name__ == '__main__':
45 logging.config.fileConfig('logging.conf')
46 if __name__ == '__main__':
47 unittest.main()
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741