public void AddControl_DifferentThread_ThrowsException() { DummyWindow window = null; ExecuteInThread(() => window = new DummyWindow()); window.AddControl(new Button()); }
public void AddControl_DifferentThread_ThrowsException() { DummyWindow window = null; ExecuteInThread(() => window = new DummyWindow()); Assert.Throws <InvalidOperationException>(() => window.AddControl(new Button())); }
public void AddControl_DifferentThread_Using_Context_ThrowsException() { var window = new DummyWindow(); var classInCtx = new ClassUsingWindowInWindowsContext(); ExecuteInThread(() => classInCtx.DoWork(window.Panel)); Assert.IsNotNull(uncaughtException, "Expected an exception"); }
public void DoWorkGeneric_DifferentThreadInContext_WorksFine() { var window = new DummyWindow(); var client = container.Resolve <IClassUsingDepedenecyContext <Panel> >(); ExecuteInThread(() => Assert.AreEqual(window.Panel, client.DoWork(window.Panel))); Assert.IsNull(uncaughtException, "Expected no exception"); }
public void AddControl_DifferentThreadInContextUsingConfiguration_WorksFine() { var window = new DummyWindow(); var client = container.Resolve <ClassUsingWindow>(); ExecuteInThread(() => client.DoWork(window.Panel)); Assert.IsNull(uncaughtException, "Expected no exception"); }
public void AddControl_DifferentThreadInContextUsingConfiguration_UsesAmbientContext() { var window = new DummyWindow(); var client = container.Resolve <ClassUsingWindowInAmbientContext>(); ExecuteInThread(() => { var dispatcherCtx = new DispatcherSynchronizationContext(window.Dispatcher); SynchronizationContext.SetSynchronizationContext(dispatcherCtx); client.DoWork(window.Panel); }); Assert.IsNull(uncaughtException, "Expected no exception"); }
public MenuBasis(MyCharacterController owner, Vector2 pos, Vector2 size,string name, GameWindowBasis gamewindow = null) { this.Position = pos; this.Size = size; this.WindowOwner = owner; MainWindow = gamewindow; MenuName = name; if (gamewindow == null) MainWindow = new DummyWindow(); DelayTimeOfKeyInput = defaultdelay; SubWindows = new List<GameWindowBasis>(); Opend = false; Closed = false; }
public void AddControl_DifferentThreadUsingClass_WorksFine() { DummyWindow window = null; ExecuteInThread(() => { window = container.Resolve <DummyWindow>(); }); Assert.AreEqual(0, window.Panel.Children.Count); var count = window.AddControl(new Button()); Assert.AreEqual(1, count); Assert.IsNull(uncaughtException, "Expected no exception"); }
public void Screen_caching_with_matches() { MockRepository mocks = new MockRepository(); Application mockApplication = mocks.CreateMock<Application>(); DummyWindow window = mocks.CreateMock<DummyWindow>(); SetupResult.For(window.Title).Return("whatever"); SetupResult.For(window.IsClosed).Return(false); Expect.Call(mockApplication.Find(delegate { return true; }, InitializeOption.NoCache)).Return(window).IgnoreArguments(); ApplicationSession applicationSession = mocks.CreateMock<ApplicationSession>(); SetupResult.For(applicationSession.Application).Return(mockApplication); mocks.ReplayAll(); ScreenRepository screenRepository = new ScreenRepository(applicationSession); Assert.AreSame(FindScreen(screenRepository), FindScreen(screenRepository)); mocks.VerifyAll(); }
public RoomTransitionWorkflow(IRoomTransitions transitions, IWindowInfo window, IRendererLoop rendererLoop, Resolver resolver, IGameEvents events, IGameLoop loop, IAGSRenderPipeline pipeline, IGameSettings settings, IAGSGameState state, IDisplayList displayList, IGLUtils glUtils) { _glUtils = glUtils; _dummyWindow = new DummyWindow(); _transitions = transitions; _transitions.Transition = new RoomTransitionInstant(); _window = window; _rendererLoop = rendererLoop; _resolver = resolver; _events = events; _loop = loop; _pipeline = pipeline; _state = state; _displayList = displayList; _settings = settings; _noAspectRatioSettings = new AGSGameSettings(settings.Title, settings.VirtualResolution, preserveAspectRatio: false); state.OnRoomChangeRequired.SubscribeToAsync(onRoomChangeRequired); }
public void ScreenShouldRemovedFromCacheWhenClosed() { var mocks = new MockRepository(); var mockApplication = mocks.CreateMock<Application>(); DummyWindow window = mocks.CreateMock<DummyWindow>(); Expect.Call(window.Title).Return("dummy"); SetupResult.For(window.IsClosed).Return(false); window.Close(); Expect.Call(mockApplication.GetWindow("dummy", InitializeOption.NoCache)).Return(window).IgnoreArguments().Repeat.Twice(); ApplicationSession applicationSession = mocks.CreateMock<ApplicationSession>(); SetupResult.For(applicationSession.Application).Return(mockApplication); mocks.ReplayAll(); ScreenRepository screenRepository = new ScreenRepository(applicationSession); DummyScreen screen = GetScreen(screenRepository); Assert.AreSame(screen, GetScreen(screenRepository)); screen.Close(); GetScreen(screenRepository); mocks.VerifyAll(); }
void EnumerateSupportedSamples(DummyWindow dummyWindow) { NativeAPI.wglGetPixelFormatAttribiARB GetPixelFormatAttribi; NativeAPI.wglGetPixelFormatAttribivARB GetPixelFormatAttribiv; dummyWindow.GetNativeProc("wglGetPixelFormatAttribivARB", out GetPixelFormatAttribi); dummyWindow.GetNativeProc("wglGetPixelFormatAttribivARB", out GetPixelFormatAttribiv); int num_format_attr = NativeAPI.WGL_NUMBER_PIXEL_FORMATS_ARB; int num_formats; if (GetPixelFormatAttribi(dummyWindow.dc, 0, 0, 1, ref num_format_attr, out num_formats)) { int[] attr = { NativeAPI.WGL_DRAW_TO_WINDOW_ARB, // 0 NativeAPI.WGL_ACCELERATION_ARB, // 1 NativeAPI.WGL_SUPPORT_OPENGL_ARB, // 2 NativeAPI.WGL_DOUBLE_BUFFER_ARB, // 3 NativeAPI.WGL_PIXEL_TYPE_ARB, // 4 NativeAPI.WGL_COLOR_BITS_ARB, // 5 NativeAPI.WGL_ALPHA_BITS_ARB, // 6 NativeAPI.WGL_DEPTH_BITS_ARB, // 7 NativeAPI.WGL_STENCIL_BITS_ARB, // 8 NativeAPI.WGL_SAMPLE_BUFFERS_ARB, // 9 NativeAPI.WGL_SAMPLES_ARB, // 10 }; int[] values = new int[attr.Length]; for (int i = 1; i <= num_formats; i++) { if (GetPixelFormatAttribiv(dummyWindow.dc, i, 0, attr.Length, attr, values)) { if (values[0] == 1 && // WGL_DRAW_TO_WINDOW_ARB values[1] == NativeAPI.WGL_FULL_ACCELERATION_ARB && // WGL_ACCELERATION_ARB values[2] == 1 && // WGL_SUPPORT_OPENGL_ARB values[3] == 1 && // WGL_DOUBLE_BUFFER_ARB values[4] == NativeAPI.WGL_TYPE_RGBA_ARB && // WGL_PIXEL_TYPE_ARB values[5] >= 24 && // WGL_COLOR_BITS_ARB values[6] >= 8 && // WGL_ALPHA_BITS_ARB values[7] == 24 && // WGL_DEPTH_BITS_ARB values[8] == 8 && // WGL_STENCIL_BITS_ARB values[9] == 1) // WGL_SAMPLE_BUFFERS_ARB { SupportedSamples |= (long)1 << values[10]; // WGL_SAMPLES_ARB } } } } }
int ChoosePixelFormat(ref NativeAPI.PixelFormatDescriptor pfd) { try { using (DummyWindow dummyWindow = new DummyWindow(ref pfd)) { EnumerateSupportedSamples(dummyWindow); if (dummyWindow.Extensions.Contains("WGL_EXT_swap_control")) { dummyWindow.GetNativeProc("wglSwapIntervalEXT", out SwapInterval); } if (dummyWindow.Extensions.Contains("WGL_ARB_pixel_format")) { NativeAPI.wglChoosePixelFormatARB ChoosePixelFormatARB; dummyWindow.GetNativeProc("wglChoosePixelFormatARB", out ChoosePixelFormatARB); if (dummyWindow.Extensions.Contains("WGL_ARB_multisample") == false) { Samples = 0; } int[] attrib = { NativeAPI.WGL_DRAW_TO_WINDOW_ARB, 1, NativeAPI.WGL_ACCELERATION_ARB, NativeAPI.WGL_FULL_ACCELERATION_ARB, NativeAPI.WGL_SUPPORT_OPENGL_ARB, 1, NativeAPI.WGL_DOUBLE_BUFFER_ARB, 1, NativeAPI.WGL_COLOR_BITS_ARB, 24, NativeAPI.WGL_RED_BITS_ARB, 8, NativeAPI.WGL_GREEN_BITS_ARB, 8, NativeAPI.WGL_BLUE_BITS_ARB, 8, NativeAPI.WGL_ALPHA_BITS_ARB, 0, NativeAPI.WGL_DEPTH_BITS_ARB, 24, NativeAPI.WGL_STENCIL_BITS_ARB, 8, 0, 0, 0, 0, 0 }; if (Samples > 0) { attrib[attrib.Length - 5 + 0] = NativeAPI.WGL_SAMPLE_BUFFERS_ARB; attrib[attrib.Length - 5 + 1] = 1; attrib[attrib.Length - 5 + 2] = NativeAPI.WGL_SAMPLES_ARB; attrib[attrib.Length - 5 + 3] = Samples; } int count; bool validpf = false; int[] piFormats = new int[1]; do { if (!ChoosePixelFormatARB(dummyWindow.dc, attrib, null, 1, piFormats, out count)) { return 0; } if (count == 0) { if (Samples != 0) { Samples--; attrib[attrib.Length - 5 + 3] = Samples; } else { break; } } else { validpf = true; } } while (!validpf && count == 0); if (validpf) { return piFormats[0]; } } } } catch (ApplicationException) { } return NativeAPI.ChoosePixelFormat(this.dc, ref pfd); }