| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import StringIO |
| 5 import unittest | 6 import unittest |
| 6 import StringIO | |
| 7 | 7 |
| 8 from telemetry.web_components import web_component | 8 from telemetry.web_components import web_component |
| 9 | 9 |
| 10 |
| 10 class SimpleWebComponent(web_component.WebComponent): | 11 class SimpleWebComponent(web_component.WebComponent): |
| 11 def __init__(self): | 12 def __init__(self): |
| 12 super(SimpleWebComponent, self).__init__( | 13 super(SimpleWebComponent, self).__init__( |
| 13 tvcm_module_name='telemetry.web_components.viewer_unittest_data', | 14 tvcm_module_name='telemetry.web_components.viewer_unittest_data', |
| 14 js_class_name='telemetry.web_components.SimpleWebComponent', | 15 js_class_name='telemetry.web_components.SimpleWebComponent', |
| 15 data_binding_property='dataToView') | 16 data_binding_property='dataToView') |
| 16 | 17 |
| 17 def WriteDataToFileAsJson(self, f): | 18 def WriteDataToFileAsJson(self, f): |
| 18 f.write("1\n") | 19 f.write("1\n") |
| 19 | 20 |
| 20 class WebComponentTests(unittest.TestCase): | 21 class WebComponentTests(unittest.TestCase): |
| 21 def testForSmoke(self): | 22 def testForSmoke(self): |
| 22 v = SimpleWebComponent() | 23 v = SimpleWebComponent() |
| 23 | 24 |
| 24 f = StringIO.StringIO() | 25 f = StringIO.StringIO() |
| 25 v.WriteWebComponentToFile(f) | 26 v.WriteWebComponentToFile(f) |
| 26 | 27 |
| 27 def testRead(self): | 28 def testRead(self): |
| 28 v = SimpleWebComponent() | 29 v = SimpleWebComponent() |
| 29 | 30 |
| 30 f = StringIO.StringIO() | 31 f = StringIO.StringIO() |
| 31 v.WriteWebComponentToFile(f) | 32 v.WriteWebComponentToFile(f) |
| 32 | 33 |
| 33 f.seek(0) | 34 f.seek(0) |
| 34 | 35 |
| 35 data = SimpleWebComponent.ReadDataObjectFromWebComponentFile(f) | 36 data = SimpleWebComponent.ReadDataObjectFromWebComponentFile(f) |
| 36 self.assertEquals(data, 1) | 37 self.assertEquals(data, 1) |
| OLD | NEW |