Exemplo n.º 1
0
static void session_delete_plugins(void**)
{
    int pluginCount = 0;

    struct Session* session = createSession();

    struct ViewPluginInstance* i0 = g_pluginUI->createViewPlugin(&s_pluginData);
    struct ViewPluginInstance* i1 = g_pluginUI->createViewPlugin(&s_pluginData);
    struct ViewPluginInstance* i2 = g_pluginUI->createViewPlugin(&s_pluginData);

    Session_addViewPlugin(session, i0);
    Session_addViewPlugin(session, i1);
    Session_addViewPlugin(session, i2);

    // Delete one of the plugins

    assert_true(Session_removeViewPlugin(session, i1) == true);
    assert_true(Session_removeViewPlugin(session, i1) == false);

    struct ViewPluginInstance** instances = Session_getViewPlugins(session, &pluginCount);

    assert_true(pluginCount == 2);
    assert_true(instances[0] == i0);
    assert_true(instances[1] == i2);

    Session_destroy(session);
}
Exemplo n.º 2
0
static void ui_session_layout(void** state)
{
    UILayout layout;
    UILayout layout2;
    (void)state;

    PluginHandler_addStaticPlugin(&s_pluginData);
    imguiSetup(1024, 768);

    ImGuiIO& io = ImGui::GetIO();

    Session* session = Session_create();
    Session* session2 = Session_create();

    PluginData* registersPlugin = PluginHandler_findPlugin(0, "registers_plugin", "Registers View", true);
    PluginData* sourcecodePlugin = PluginHandler_findPlugin(0, "sourcecode_plugin", "Source Code View", true);

    ViewPluginInstance* i0 = PluginInstance_createViewPlugin(registersPlugin);
    ViewPluginInstance* i1 = PluginInstance_createViewPlugin(sourcecodePlugin);

    Session_addViewPlugin(session, i0);
    Session_addViewPlugin(session, i1);

    PluginUI_setWindowRect(i0, &s_t0);
    PluginUI_setWindowRect(i1, &s_t1);

    Session_getLayout(session, &layout, io.DisplaySize.x, io.DisplaySize.y);
    UILayout_saveLayout(&layout, "t2-output/temp_layout2.json");

    // Tear down

    Session_removeViewPlugin(session, i0);
    Session_removeViewPlugin(session, i1);
    PluginHandler_unloadAllPlugins();

    // Load the layout

    UILayout_loadLayout(&layout2, "t2-output/temp_layout2.json");
    compareLayouts(&layout, &layout2);

    int count = 0;

    Session_setLayout(session2, &layout2, io.DisplaySize.x, io.DisplaySize.y);

    ViewPluginInstance** plugins = Session_getViewPlugins(session2, &count);

    assert_int_equal(layout.layoutItemCount, count);

    for (int i = 0; i < layout.layoutItemCount; ++i)
    {
        FloatRect rect;

        PluginUI_getWindowRect(plugins[i], &rect);

        const LayoutItem* item = &layout2.layoutItems[i];

        assert_int_equal((int)(item->rect.x * io.DisplaySize.x), (int)rect.x);
        assert_int_equal((int)(item->rect.y * io.DisplaySize.y), (int)rect.y);
        assert_int_equal((int)(item->rect.width * io.DisplaySize.x), (int)rect.width);
        assert_int_equal((int)(item->rect.height * io.DisplaySize.y), (int)rect.height);
    }
}