1# Copyright (c) 2014 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 codecs
6import os
7import unittest
8import tempfile
9
10from tracing.build import vulcanize_trace_viewer
11
12
13class Trace2HTMLTests(unittest.TestCase):
14  def test_writeHTMLForTracesToFile(self):
15    try:
16      # Note: We can't use "with" when working with tempfile.NamedTemporaryFile
17      # as that does not work on Windows. We use the longer, more clunky version
18      # instead. See https://bugs.python.org/issue14243 for detials.
19      raw_tmpfile = tempfile.NamedTemporaryFile(
20          mode='w', suffix='.html', delete=False)
21      raw_tmpfile.close()
22      with codecs.open(raw_tmpfile.name, 'w', encoding='utf-8') as tmpfile:
23        vulcanize_trace_viewer.WriteTraceViewer(tmpfile)
24    finally:
25      os.remove(raw_tmpfile.name)
26