Edit

kc3-lang/angle/src/libANGLE/Surface_unittest.cpp

Branch :

  • Show log

    Commit

  • Author : Stanislav Chiknavaryan
    Date : 2016-11-04 18:27:56
    Hash : 20c97cac
    Message : Squashed commit of the following: commit 0146dfeefa47b520e71f0e74230abd7dac163a79 Author: Stanislav Chiknavaryan <stanisc@chromium.org> Date: Fri Nov 4 17:43:03 2016 -0700 Revert "Implementation of eglGetSyncValuesCHROMIUM extension." This reverts commit 5d9f5df01ac5a384d9b7cbb49d9f98a76b62c7ad. commit 0d920fe27bd8e73d831a9002548bde00fea78709 Author: Stanislav Chiknavaryan <stanisc@chromium.org> Date: Fri Nov 4 17:23:11 2016 -0700 Revert "Fix EGLSyncControlTest.SyncValuesTest timeout on Windowse Server 2012 R2" This reverts commit d258ca045f31eb43ec01b5501c84e9afd8e82cd6. commit bde8defe53741855bb71fbf27bcb0a91cfafbd01 Author: Stanislav Chiknavaryan <stanisc@chromium.org> Date: Fri Nov 4 17:22:58 2016 -0700 Revert "Disabling EGLSyncControlTest.SyncValuesTest" This reverts commit a74183613955bd891f56f6a979a5391c16c64138. commit f78e4b7e97b9d1259878f6902bb6ddeb0aeded87 Author: Stanislav Chiknavaryan <stanisc@chromium.org> Date: Fri Nov 4 17:22:36 2016 -0700 Revert "Fix and re-enable EGLSyncControlTest.SyncValuesTest" This reverts commit 138ec92f52da7c0fc8e6df08ac4e4e572bbf6b39. commit f3933e6a04bd23473077d2fd74616023db3c9601 Author: Stanislav Chiknavaryan <stanisc@chromium.org> Date: Fri Nov 4 17:20:26 2016 -0700 Revert "Handle nullptr mSwapChain in SwapChain11::getSyncValues" This reverts commit af7f301f6ba9e5f31d1511142a936a9ba84169d0. BUG=angleproject:1402 Change-Id: I99969e906e316574e9f739141de0e360d1edebd9 Reviewed-on: https://chromium-review.googlesource.com/408752 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Stanislav Chiknavaryan <stanisc@chromium.org>

  • src/libANGLE/Surface_unittest.cpp
  • //
    // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    //
    
    #include "gmock/gmock.h"
    #include "gtest/gtest.h"
    #include "libANGLE/angletypes.h"
    #include "libANGLE/AttributeMap.h"
    #include "libANGLE/Config.h"
    #include "libANGLE/ContextState.h"
    #include "libANGLE/State.h"
    #include "libANGLE/Surface.h"
    #include "libANGLE/renderer/FramebufferImpl_mock.h"
    #include "libANGLE/renderer/SurfaceImpl.h"
    #include "tests/angle_unittests_utils.h"
    
    using namespace rx;
    using namespace testing;
    
    namespace
    {
    
    class MockSurfaceImpl : public rx::SurfaceImpl
    {
      public:
        MockSurfaceImpl() : SurfaceImpl(mockState) {}
        virtual ~MockSurfaceImpl() { destroy(); }
    
        MOCK_METHOD0(initialize, egl::Error());
        MOCK_METHOD1(createDefaultFramebuffer, rx::FramebufferImpl *(const gl::FramebufferState &data));
        MOCK_METHOD0(swap, egl::Error());
        MOCK_METHOD2(swapWithDamage, egl::Error(EGLint *, EGLint));
        MOCK_METHOD4(postSubBuffer, egl::Error(EGLint, EGLint, EGLint, EGLint));
        MOCK_METHOD2(querySurfacePointerANGLE, egl::Error(EGLint, void**));
        MOCK_METHOD2(bindTexImage, egl::Error(gl::Texture*, EGLint));
        MOCK_METHOD1(releaseTexImage, egl::Error(EGLint));
        MOCK_METHOD1(setSwapInterval, void(EGLint));
        MOCK_CONST_METHOD0(getWidth, EGLint());
        MOCK_CONST_METHOD0(getHeight, EGLint());
        MOCK_CONST_METHOD0(isPostSubBufferSupported, EGLint(void));
        MOCK_CONST_METHOD0(getSwapBehavior, EGLint(void));
        MOCK_METHOD2(getAttachmentRenderTarget, gl::Error(const gl::FramebufferAttachment::Target &, rx::FramebufferAttachmentRenderTarget **));
    
        MOCK_METHOD0(destroy, void());
    
        egl::SurfaceState mockState;
    };
    
    TEST(SurfaceTest, DestructionDeletesImpl)
    {
        NiceMock<MockEGLFactory> factory;
    
        MockSurfaceImpl *impl = new MockSurfaceImpl;
        EXPECT_CALL(factory, createWindowSurface(_, _, _, _)).WillOnce(Return(impl));
    
        egl::Config config;
        egl::Surface *surface = new egl::WindowSurface(
            &factory, &config, static_cast<EGLNativeWindowType>(0), egl::AttributeMap());
    
        EXPECT_CALL(*impl, destroy()).Times(1).RetiresOnSaturation();
    
        surface->onDestroy();
    
        // Only needed because the mock is leaked if bugs are present,
        // which logs an error, but does not cause the test to fail.
        // Ordinarily mocks are verified when destroyed.
        Mock::VerifyAndClear(impl);
    }
    
    } // namespace