• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
15  def testWriteHTMLForTracesToFile(self):
16    try:
17      # Note: We can't use "with" when working with tempfile.NamedTemporaryFile
18      # as that does not work on Windows. We use the longer, more clunky version
19      # instead. See https://bugs.python.org/issue14243 for detials.
20      raw_tmpfile = tempfile.NamedTemporaryFile(
21          mode='w', suffix='.html', delete=False)
22      raw_tmpfile.close()
23      with codecs.open(raw_tmpfile.name, 'w', encoding='utf-8') as tmpfile:
24        vulcanize_trace_viewer.WriteTraceViewer(tmpfile)
25    finally:
26      os.remove(raw_tmpfile.name)
27