MCPcopy Create free account
hub / github.com/cginternals/glbinding / TEST_F

Function TEST_F

source/tests/glbinding-test/MultiThreading_test.cpp:32–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32TEST_F(MultiThreading_test, Test)
33{
34 int success = glfwInit();
35
36 EXPECT_EQ(1, success);
37
38 glfwSetErrorCallback(error);
39
40 glfwWindowHint(GLFW_VISIBLE, false);
41 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
42 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
43 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, false);
44 glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
45
46 GLFWwindow * window1 = glfwCreateWindow(320, 240, "", nullptr, nullptr);
47
48 EXPECT_NE(nullptr, window1);
49
50 glfwWindowHint(GLFW_VISIBLE, false);
51 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
52 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
53 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, false);
54 glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
55
56 GLFWwindow * window2 = glfwCreateWindow(320, 240, "", nullptr, nullptr);
57
58 EXPECT_NE(nullptr, window2);
59
60 std::thread t1([window1]()
61 {
62 glfwMakeContextCurrent(window1);
63 Binding::initialize(false);
64
65 std::this_thread::sleep_for(std::chrono::milliseconds(5));
66
67 for (int i = 0; i < 40; ++i)
68 {
69 int major = 0;
70 int minor = 0;
71
72 glGetIntegerv(GL_MAJOR_VERSION, &major);
73 glGetIntegerv(GL_MINOR_VERSION, &minor);
74
75 EXPECT_EQ(3, major);
76 EXPECT_EQ(2, minor);
77
78 std::this_thread::sleep_for(std::chrono::milliseconds(4));
79 }
80 });
81
82 std::thread t2([window2]()
83 {
84 glfwMakeContextCurrent(window2);
85 Binding::initialize(false);
86
87 std::this_thread::sleep_for(std::chrono::milliseconds(4));
88
89 for (int i = 0; i < 40; ++i)

Callers

nothing calls this directly

Calls 2

initializeFunction · 0.85
glGetIntegervFunction · 0.50

Tested by

no test coverage detected