| OLD | NEW | 
 | (Empty) | 
|    1 // Copyright 2012 The Chromium Authors. All rights reserved. |  | 
|    2 // Use of this source code is governed by a BSD-style license that can be |  | 
|    3 // found in the LICENSE file. |  | 
|    4  |  | 
|    5 #include "config.h" |  | 
|    6  |  | 
|    7 #include "TextureLayerChromium.h" |  | 
|    8  |  | 
|    9 #include "CCLayerTreeHost.h" |  | 
|   10 #include "FakeCCLayerTreeHostClient.h" |  | 
|   11 #include <gmock/gmock.h> |  | 
|   12 #include <gtest/gtest.h> |  | 
|   13 #include <public/WebCompositor.h> |  | 
|   14  |  | 
|   15 using namespace WebCore; |  | 
|   16 using ::testing::Mock; |  | 
|   17 using ::testing::_; |  | 
|   18 using ::testing::AtLeast; |  | 
|   19 using ::testing::AnyNumber; |  | 
|   20  |  | 
|   21 namespace { |  | 
|   22  |  | 
|   23 class MockCCLayerTreeHost : public CCLayerTreeHost { |  | 
|   24 public: |  | 
|   25     MockCCLayerTreeHost() |  | 
|   26         : CCLayerTreeHost(&m_fakeClient, CCLayerTreeSettings()) |  | 
|   27     { |  | 
|   28         initialize(); |  | 
|   29     } |  | 
|   30  |  | 
|   31     MOCK_METHOD0(acquireLayerTextures, void()); |  | 
|   32  |  | 
|   33 private: |  | 
|   34     FakeCCLayerTreeHostClient m_fakeClient; |  | 
|   35 }; |  | 
|   36  |  | 
|   37  |  | 
|   38 class TextureLayerChromiumTest : public testing::Test { |  | 
|   39 protected: |  | 
|   40     virtual void SetUp() |  | 
|   41     { |  | 
|   42         // Initialize without threading support. |  | 
|   43         WebKit::WebCompositor::initialize(0); |  | 
|   44         m_layerTreeHost = adoptPtr(new MockCCLayerTreeHost); |  | 
|   45     } |  | 
|   46  |  | 
|   47     virtual void TearDown() |  | 
|   48     { |  | 
|   49         Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |  | 
|   50         EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber())
     ; |  | 
|   51  |  | 
|   52         m_layerTreeHost->setRootLayer(0); |  | 
|   53         m_layerTreeHost.clear(); |  | 
|   54         WebKit::WebCompositor::shutdown(); |  | 
|   55     } |  | 
|   56  |  | 
|   57     OwnPtr<MockCCLayerTreeHost> m_layerTreeHost; |  | 
|   58 }; |  | 
|   59  |  | 
|   60 TEST_F(TextureLayerChromiumTest, syncImplWhenChangingTextureId) |  | 
|   61 { |  | 
|   62     RefPtr<TextureLayerChromium> testLayer = TextureLayerChromium::create(0); |  | 
|   63     ASSERT_TRUE(testLayer); |  | 
|   64  |  | 
|   65     EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber()); |  | 
|   66     m_layerTreeHost->setRootLayer(testLayer); |  | 
|   67     Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |  | 
|   68     EXPECT_EQ(testLayer->layerTreeHost(), m_layerTreeHost.get()); |  | 
|   69  |  | 
|   70     EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); |  | 
|   71     testLayer->setTextureId(1); |  | 
|   72     Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |  | 
|   73  |  | 
|   74     EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1)); |  | 
|   75     testLayer->setTextureId(2); |  | 
|   76     Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |  | 
|   77  |  | 
|   78     EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1)); |  | 
|   79     testLayer->setTextureId(0); |  | 
|   80     Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |  | 
|   81 } |  | 
|   82  |  | 
|   83 TEST_F(TextureLayerChromiumTest, syncImplWhenRemovingFromTree) |  | 
|   84 { |  | 
|   85     RefPtr<LayerChromium> rootLayer = LayerChromium::create(); |  | 
|   86     ASSERT_TRUE(rootLayer); |  | 
|   87     RefPtr<LayerChromium> childLayer = LayerChromium::create(); |  | 
|   88     ASSERT_TRUE(childLayer); |  | 
|   89     rootLayer->addChild(childLayer); |  | 
|   90     RefPtr<TextureLayerChromium> testLayer = TextureLayerChromium::create(0); |  | 
|   91     ASSERT_TRUE(testLayer); |  | 
|   92     testLayer->setTextureId(0); |  | 
|   93     childLayer->addChild(testLayer); |  | 
|   94  |  | 
|   95     EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber()); |  | 
|   96     m_layerTreeHost->setRootLayer(rootLayer); |  | 
|   97     Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |  | 
|   98  |  | 
|   99     EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); |  | 
|  100     testLayer->removeFromParent(); |  | 
|  101     Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |  | 
|  102  |  | 
|  103     EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); |  | 
|  104     childLayer->addChild(testLayer); |  | 
|  105     Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |  | 
|  106  |  | 
|  107     EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); |  | 
|  108     testLayer->setTextureId(1); |  | 
|  109     Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |  | 
|  110  |  | 
|  111     EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1)); |  | 
|  112     testLayer->removeFromParent(); |  | 
|  113     Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |  | 
|  114 } |  | 
|  115  |  | 
|  116 } // anonymous namespace |  | 
| OLD | NEW |