Implement and archive Phase 5 form designer
This commit is contained in:
@@ -16,3 +16,6 @@ tb-vm.workspace = true
|
||||
tb-runtime.workspace = true
|
||||
tb-ui = { workspace = true, features = ["terminal"] }
|
||||
anyhow.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
tb-ide = { path = "../tb-ide" }
|
||||
|
||||
@@ -234,3 +234,38 @@ fn explicit_startup_order_and_form_selection_survive_tbc() {
|
||||
}
|
||||
std::fs::remove_dir_all(dir).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn designer_frm_is_accepted_by_the_standalone_cli_compiler() {
|
||||
use tb_frontend::forms::ObjectClass;
|
||||
use tb_ide::{app::App, commands::Command as IdeCommand, documents::Destination};
|
||||
let dir = std::env::temp_dir().join(format!("tb-designer-cli-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let dir = dir.canonicalize().unwrap();
|
||||
let mut app = App::new(&dir, dir.join("options"), (100, 30)).unwrap();
|
||||
app.execute(IdeCommand::NewForm);
|
||||
let root = app.design_objects().unwrap()[0].0;
|
||||
let button = app.design_place(ObjectClass::CommandButton, 0, root, Default::default());
|
||||
assert!(button.is_err()); // ungültige Größe schreibt nichts
|
||||
let mut rect = app.area();
|
||||
rect.x = 2;
|
||||
rect.y = 2;
|
||||
rect.width = 8;
|
||||
rect.height = 2;
|
||||
let control = app
|
||||
.design_place(ObjectClass::CommandButton, 0, root, rect)
|
||||
.unwrap();
|
||||
app.design_property("INDEX", "0").unwrap();
|
||||
app.design_event(control, "CLICK").unwrap();
|
||||
let doc = app.active_document().unwrap();
|
||||
let path = dir.join("designed.frm");
|
||||
app.project
|
||||
.save_file(doc, Some(&Destination::new(&path)))
|
||||
.unwrap();
|
||||
let built = tbc(&dir, "build", "designed.frm");
|
||||
assert!(built.status.success(), "{built:?}");
|
||||
let bytes = std::fs::read(dir.join("designed.tbc")).unwrap();
|
||||
assert_eq!(&bytes[..6], b"TBC\0\x04\0");
|
||||
tb_vm::project_io::load_program(&dir.join("designed.tbc")).unwrap();
|
||||
std::fs::remove_dir_all(dir).unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user