Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Unified Diff: gpu/command_buffer/service/valuebuffer_manager_unittest.cc

Issue 816543004: Update from https://crrev.com/308996 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/service/valuebuffer_manager.cc ('k') | gpu/command_buffer/tests/gl_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/valuebuffer_manager_unittest.cc
diff --git a/gpu/command_buffer/service/valuebuffer_manager_unittest.cc b/gpu/command_buffer/service/valuebuffer_manager_unittest.cc
index 44cc2f76caa8e56f47f002facd1d608e52eb86d3..3aac3564322a1f2b6864a0b834d15a63907d5ae5 100644
--- a/gpu/command_buffer/service/valuebuffer_manager_unittest.cc
+++ b/gpu/command_buffer/service/valuebuffer_manager_unittest.cc
@@ -15,6 +15,7 @@
#include "gpu/command_buffer/service/gpu_service_test.h"
#include "gpu/command_buffer/service/mocks.h"
#include "gpu/command_buffer/service/test_helper.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_mock.h"
@@ -22,6 +23,12 @@
namespace gpu {
namespace gles2 {
+class MockSubscriptionRefSetObserver : public SubscriptionRefSet::Observer {
+ public:
+ MOCK_METHOD1(OnAddSubscription, void(unsigned int target));
+ MOCK_METHOD1(OnRemoveSubscription, void(unsigned int target));
+};
+
class ValuebufferManagerTest : public GpuServiceTest {
public:
ValuebufferManagerTest() {}
@@ -29,16 +36,23 @@ class ValuebufferManagerTest : public GpuServiceTest {
void SetUp() override {
GpuServiceTest::SetUp();
+ subscription_ref_set_ = new SubscriptionRefSet();
pending_state_map_ = new ValueStateMap();
- manager_.reset(new ValuebufferManager(pending_state_map_.get()));
+ subscription_ref_set_->AddObserver(&mock_observer_);
+ manager_.reset(new ValuebufferManager(subscription_ref_set_.get(),
+ pending_state_map_.get()));
}
void TearDown() override {
manager_->Destroy();
+ subscription_ref_set_->RemoveObserver(&mock_observer_);
GpuServiceTest::TearDown();
}
protected:
+ MockSubscriptionRefSetObserver mock_observer_;
+
+ scoped_refptr<SubscriptionRefSet> subscription_ref_set_;
scoped_refptr<ValueStateMap> pending_state_map_;
scoped_ptr<ValuebufferManager> manager_;
};
@@ -109,5 +123,30 @@ TEST_F(ValuebufferManagerTest, UpdateState) {
ASSERT_TRUE(new_state2->int_value[0] == 222);
}
+TEST_F(ValuebufferManagerTest, NotifySubscriptionRefs) {
+ const GLuint kClientId1 = 1;
+ const GLuint kClientId2 = 2;
+ manager_->CreateValuebuffer(kClientId1);
+ Valuebuffer* valuebuffer1 = manager_->GetValuebuffer(kClientId1);
+ ASSERT_TRUE(valuebuffer1 != NULL);
+ manager_->CreateValuebuffer(kClientId2);
+ Valuebuffer* valuebuffer2 = manager_->GetValuebuffer(kClientId2);
+ ASSERT_TRUE(valuebuffer2 != NULL);
+ EXPECT_CALL(mock_observer_, OnAddSubscription(GL_MOUSE_POSITION_CHROMIUM))
+ .Times(1);
+ valuebuffer1->AddSubscription(GL_MOUSE_POSITION_CHROMIUM);
+ EXPECT_CALL(mock_observer_, OnAddSubscription(GL_MOUSE_POSITION_CHROMIUM))
+ .Times(0);
+ valuebuffer2->AddSubscription(GL_MOUSE_POSITION_CHROMIUM);
+ EXPECT_CALL(mock_observer_, OnRemoveSubscription(GL_MOUSE_POSITION_CHROMIUM))
+ .Times(0);
+ valuebuffer1->RemoveSubscription(GL_MOUSE_POSITION_CHROMIUM);
+ // Ensure the manager still thinks a buffer has a reference to the
+ // subscription target.
+ EXPECT_CALL(mock_observer_, OnRemoveSubscription(GL_MOUSE_POSITION_CHROMIUM))
+ .Times(1);
+ valuebuffer2->RemoveSubscription(GL_MOUSE_POSITION_CHROMIUM);
+}
+
} // namespace gles2
} // namespace gpu
« no previous file with comments | « gpu/command_buffer/service/valuebuffer_manager.cc ('k') | gpu/command_buffer/tests/gl_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698