extends MainWindowTestSuite ## The Log popup (rows, empty state, scrolling to the newest row) and the QR popup. var _log: LogPopup var _qr: QRPopup func before_test() -> void: await super() _log = _window.get_node("LogPopup") _qr = _window.get_node("QRPopup") func test_empty_log_says_so() -> void: _log.open() assert_bool(_log.empty_label.visible).is_true() func test_log_rows_alternate_and_hide_the_empty_text() -> void: _log.add_log_row("Crono got a point") _log.add_log_row("Marle got a point") _log.open() var rows: Array[Node] = _log.log_box.get_children() assert_str((rows[0] as ListRow).text).ends_with("Crono got a point") assert_str(String((rows[0] as ListRow).theme_type_variation)).is_equal("ListRowEven") assert_str(String((rows[1] as ListRow).theme_type_variation)).is_equal("ListRowOdd") assert_bool(_log.empty_label.visible).is_false() func test_log_shows_the_newest_row() -> void: _log.open() for i: int in 40: _log.add_log_row("Event %d" % i) await _runner.simulate_frames(4) var scroll: ScrollContainer = _log.log_scroll var newest: Rect2 = (_log.log_box.get_children().back() as Control).get_global_rect() assert_bool(scroll.get_global_rect().encloses(newest)).is_true() func test_log_scrolls_to_the_newest_row_when_opened() -> void: for i: int in 40: _log.add_log_row("Event %d" % i) _log.open() await _runner.simulate_frames(4) var newest: Rect2 = (_log.log_box.get_children().back() as Control).get_global_rect() assert_bool(_log.log_scroll.get_global_rect().encloses(newest)).is_true() func test_qr_popup_has_a_title_and_the_search_address() -> void: _qr.open() assert_str((_qr.qr_panel.get_node("TitleLabel") as Label).text) \ .is_equal("Scan to search on your phone") assert_str(_qr.url_label.text).is_equal(Settings.default_path + "/search") assert_str(_qr.qr_code_rect.data).is_equal(_qr.url_label.text) func test_qr_code_follows_the_server_picked_in_the_settings() -> void: _qr.open() _qr.close() Settings.default_path = "http://another-server:8080" _qr.open() assert_str(_qr.url_label.text).is_equal("http://another-server:8080/search") assert_str(_qr.qr_code_rect.data).is_equal("http://another-server:8080/search")