Editor: botao Exportar abre menu de contexto (JSON/XML/CSV)
- Substitui os tres botoes de exportacao por um unico "Exportar" que abre um menu de contexto ancorado no botao (reusa o menu de contexto do workspace via os itens CM_EXP_JSON/XML/CSV e o flag ctx_export). - Layout do menu: Abrir / Salvar / Exportar / Carregar library. - Harness: abre um projeto .json escrito a mao (aba distinta, blocos e variavel) e exporta XML pelo menu de contexto do botao.
This commit is contained in:
1 parent
1199d2d7c7
commit
f37884ccdf
2 files changed
+67
-27
No files matched your search
@@ -308,6 +308,43 @@ int main(void) {
|
||||
"estado restaurado apos abrir (chapéu de exemplo de volta)");
|
||||
remove(proj);
|
||||
|
||||
/* 13. Abrir um projeto escrito a mao (aba distinta) */
|
||||
const char* openjson = "/tmp/tb_harness_open.json";
|
||||
FILE* pf = fopen(openjson, "wb");
|
||||
if (pf) {
|
||||
fputs("{\"format\":\"tinyblocks-project\",\"version\":1,\"cur_tab\":0,"
|
||||
"\"tabs\":[{\"name\":\"Aberto!\",\"composite\":false,\"comp_id\":-1,\"color\":0,"
|
||||
"\"blocks\":["
|
||||
"{\"i\":0,\"type\":\"Events.WhenRun\",\"x\":40,\"y\":40,\"next\":1},"
|
||||
"{\"i\":1,\"type\":\"IO.Print\",\"x\":40,\"y\":100,\"in_text\":[\"Oi do arquivo\",\"\"]},"
|
||||
"{\"i\":2,\"type\":\"Stage.Circle\",\"x\":40,\"y\":180,\"in_text\":[\"0\",\"0\",\"80\"]}"
|
||||
"],\"top\":[0,2]}],"
|
||||
"\"user_blocks\":[],\"variables\":[{\"name\":\"x\",\"kind\":0,\"num\":7,\"text\":\"\"}]}", pf);
|
||||
fclose(pf);
|
||||
}
|
||||
if (need("Abrir", R_FLY, 0, &x, &y)) click(x, y);
|
||||
for (int i = 0; i < 40; i++) key(TB_KEY_BACKSPACE, 0, 0);
|
||||
type(openjson);
|
||||
key(TB_KEY_RETURN, 0, 0);
|
||||
frame(0, 0, 0, 0, 0, 0, NULL);
|
||||
CHECK(find("Aberto!", R_ANY, 0, &x, &y), "abrir projeto de arquivo externo (aba Aberto!)");
|
||||
CHECK(find("Oi do arquivo", R_WS, 0, &x, &y), "bloco do arquivo externo aparece no workspace");
|
||||
remove(openjson);
|
||||
|
||||
/* 14. Exportar pelo menu de contexto do botao Exportar */
|
||||
if (need("Exportar", R_FLY, 0, &x, &y)) click(x, y);
|
||||
CHECK(find("Exportar JSON", R_FLY, 0, &x, &y) && find("Exportar XML", R_FLY, 0, &x, &y)
|
||||
&& find("Exportar CSV", R_FLY, 0, &x, &y), "botao Exportar abre menu com JSON/XML/CSV");
|
||||
const char* expf = "/tmp/tb_harness_export.xml";
|
||||
remove(expf);
|
||||
if (need("Exportar XML", R_FLY, 0, &x, &y)) click(x, y);
|
||||
for (int i = 0; i < 40; i++) key(TB_KEY_BACKSPACE, 0, 0);
|
||||
type(expf);
|
||||
key(TB_KEY_RETURN, 0, 0);
|
||||
frame(0, 0, 0, 0, 0, 0, NULL);
|
||||
CHECK(any_has("Exportado xml"), "exportar XML pelo menu escreve o arquivo");
|
||||
remove(expf);
|
||||
|
||||
printf("comandos de desenho no último frame: %u\n", ncmd);
|
||||
tinyblocks_deinit(&rt);
|
||||
printf(fails ? "\n%d FALHA(S)\n" : "\nTUDO OK\n", fails);
|
||||
|
||||
Reference in new issue
Block a user