def test_all_property_transfer(self): """ Test 3: Initial property transfer - make sure the viewer gets stuff set. """ self.init_webdriver() # Replicate the initial test self.test_init_html() # Now let's go further and modify the document self.webdriver.execute_script(""" broadcaster_iframe.contentWindow.change_some_css(); """) # Change text input value property new_input_value = "dfkjgopi" self.webdriver.switch_to_frame('broadcaster_iframe') input = self.webdriver.find_element_by_id('thetextinput') input.send_keys(new_input_value) self.webdriver.switch_to_default_content() diff = self.execute_script(""" var data = broadcaster.start_document(); return JSON.stringify(data["props"]); """) diff = json.loads(diff) # Only properties assert all(d[0] == "props" for d in diff) assert util.diff_contains_changed_property_key(diff, "value") # Should be a border in there somewhere (note: IE returns individual # border rules for each side, FF retains the single border rule) assert util.diff_contains_changed_property_value(diff, "purple") diff = sanitise_diffs(diff) # We can reuse test 2's diff apply thing self.apply_viewer_diff(diff) # Verify the diff made it through self.webdriver.switch_to_frame('viewer_iframe') input = self.webdriver.find_element_by_id('thetextinput') input_value = input.get_attribute("value") print "Got input value: %s. Expected: <original value>%s" % ( input_value, new_input_value) assert input_value.endswith(new_input_value) table = self.webdriver.find_element_by_id('thetable') table_background_colour = input.value_of_css_property( "background-color") table_background_colour = table_background_colour.replace(" ", "") assert table_background_colour in ("purple", "rgba(255,255,255,1)")
def test_all_property_transfer(self): """ Test 3: Initial property transfer - make sure the viewer gets stuff set. """ self.init_webdriver() # Replicate the initial test self.test_init_html() # Now let's go further and modify the document self.webdriver.execute_script(""" broadcaster_iframe.contentWindow.change_some_css(); """) # Change text input value property new_input_value = "dfkjgopi" self.webdriver.switch_to_frame('broadcaster_iframe') input = self.webdriver.find_element_by_id('thetextinput') input.send_keys(new_input_value) self.webdriver.switch_to_default_content() diff = self.execute_script(""" var data = broadcaster.start_document(); return JSON.stringify(data["props"]); """) diff = json.loads(diff) # Only properties assert all(d[0] == "props" for d in diff) assert util.diff_contains_changed_property_key(diff, "value") # Should be a border in there somewhere (note: IE returns individual # border rules for each side, FF retains the single border rule) assert util.diff_contains_changed_property_value(diff, "purple") diff = sanitise_diffs(diff) # We can reuse test 2's diff apply thing self.apply_viewer_diff(diff) # Verify the diff made it through self.webdriver.switch_to_frame('viewer_iframe') input = self.webdriver.find_element_by_id('thetextinput') input_value = input.get_attribute("value") print "Got input value: %s. Expected: <original value>%s" % (input_value, new_input_value) assert input_value.endswith(new_input_value) table = self.webdriver.find_element_by_id('thetable') table_background_colour = input.value_of_css_property("background-color") table_background_colour = table_background_colour.replace(" ", "") assert table_background_colour in ("purple", "rgba(255,255,255,1)")
def test_get_shape_path_diff(self): """ Test 7: Try to update a shape path and get the resulting diff """ self.init_webdriver() new_shape_path = "wr2018,408,4493,2883,2213,978,3255,408 at3255,1645,3255,1645,3255,1645,3255,1645 x e" diffs = self.execute_script(""" broadcaster.make_dom_clone(); var shape = broadcaster_iframe.contentWindow.document.getElementById('theshape'); if (shape == null) { throw new Error("Couldn't find shape!"); } shape.path.v = arguments[0]; return JSON.stringify(broadcaster.get_diff());""", new_shape_path) diffs = json.loads(diffs) assert len(diffs) == 1 print diffs diff_type, node_type, path, vml_xml, props = diffs[0] assert util.diff_contains_changed_property_key(diffs, 'path.v') assert node_type == "vml"
def test_get_shape_path_diff(self): """ Test 7: Try to update a shape path and get the resulting diff """ self.init_webdriver() new_shape_path = "wr2018,408,4493,2883,2213,978,3255,408 at3255,1645,3255,1645,3255,1645,3255,1645 x e" diffs = self.execute_script( """ broadcaster.make_dom_clone(); var shape = broadcaster_iframe.contentWindow.document.getElementById('theshape'); if (shape == null) { throw new Error("Couldn't find shape!"); } shape.path.v = arguments[0]; return JSON.stringify(broadcaster.get_diff());""", new_shape_path) diffs = json.loads(diffs) assert len(diffs) == 1 print diffs diff_type, node_type, path, vml_xml, props = diffs[0] assert util.diff_contains_changed_property_key(diffs, 'path.v') assert node_type == "vml"