File: Regression_test_198.cpp

package info (click to toggle)
glbinding 3.3.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,972 kB
  • sloc: cpp: 224,461; javascript: 1,615; sh: 114; makefile: 98
file content (64 lines) | stat: -rw-r--r-- 1,905 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <gmock/gmock.h>

#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>

#include <glbinding/glbinding.h>
#include <glbinding/gl/gl.h>

#include <stdexcept>


glbinding::ContextHandle context_cast(GLFWwindow* context) {
    static_assert(
        sizeof(glbinding::ContextHandle) >= sizeof(GLFWwindow*), 
        "glbinding::ContextHandle doesn't have enough space to hold GLFWwindow*");
    return reinterpret_cast<glbinding::ContextHandle>(context);
}

class Regression_198 : public testing::Test
{
public:
};


TEST(Regression_198, releaseContext)  // releaseContext(ctx) wipes out functions on contexts other than ctx #198
{
    try {
        if (!glfwInit())
        {
            SUCCEED();
            return;
        }

        glfwDefaultWindowHints();
        glfwWindowHint(GLFW_VISIBLE, false);

        auto context_A = glfwCreateWindow(320, 240, "Regression198-A", nullptr, nullptr);
        ASSERT_NE(nullptr, context_A);
        auto context_A_gl = context_cast(context_A);
        glbinding::initialize(context_A_gl, ::glfwGetProcAddress, true, false);

        auto context_B = glfwCreateWindow(320, 240, "Regression198-B", nullptr, nullptr);
        ASSERT_NE(nullptr, context_B);
        auto context_B_gl = context_cast(context_B);
        glbinding::initialize(context_B_gl, ::glfwGetProcAddress, true, false);

        glbinding::releaseContext(context_B_gl);
        glfwDestroyWindow(context_B);

        glfwMakeContextCurrent(context_A);
        glbinding::useContext(context_A_gl);
        gl::GLint major = 0;
        glGetIntegerv(gl::GL_MAJOR_VERSION, &major);

        glbinding::releaseContext(context_A_gl);
        glfwDestroyWindow(context_A);
        glfwTerminate();
    } catch (std::out_of_range & ex) {
        FAIL() << "Unexpected exception std::out_of_range thrown with message: " << ex.what();
    } catch (...) {
        SUCCEED();
    }
    SUCCEED();
}