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

Side by Side Diff: cc/trees/layer_tree_host_unittest_scroll.cc

Issue 13844021: Move compositor thread input handling logic into content (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "base/memory/weak_ptr.h"
7 #include "cc/base/thread_impl.h" 8 #include "cc/base/thread_impl.h"
8 #include "cc/layers/content_layer.h" 9 #include "cc/layers/content_layer.h"
9 #include "cc/layers/layer.h" 10 #include "cc/layers/layer.h"
10 #include "cc/layers/layer_impl.h" 11 #include "cc/layers/layer_impl.h"
11 #include "cc/test/fake_content_layer_client.h" 12 #include "cc/test/fake_content_layer_client.h"
12 #include "cc/test/fake_layer_tree_host_client.h" 13 #include "cc/test/fake_layer_tree_host_client.h"
13 #include "cc/test/geometry_test_utils.h" 14 #include "cc/test/geometry_test_utils.h"
14 #include "cc/test/layer_tree_test.h" 15 #include "cc/test/layer_tree_test.h"
15 #include "cc/trees/layer_tree_impl.h" 16 #include "cc/trees/layer_tree_impl.h"
16 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerScrollClien t.h" 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerScrollClien t.h"
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 SINGLE_AND_MULTI_THREAD_TEST_F( 664 SINGLE_AND_MULTI_THREAD_TEST_F(
664 LayerTreeHostScrollTestScrollZeroMaxScrollOffset); 665 LayerTreeHostScrollTestScrollZeroMaxScrollOffset);
665 666
666 class ThreadCheckingInputHandlerClient : public InputHandlerClient { 667 class ThreadCheckingInputHandlerClient : public InputHandlerClient {
667 public: 668 public:
668 ThreadCheckingInputHandlerClient(base::SingleThreadTaskRunner* runner, 669 ThreadCheckingInputHandlerClient(base::SingleThreadTaskRunner* runner,
669 bool* received_stop_flinging) 670 bool* received_stop_flinging)
670 : task_runner_(runner) , 671 : task_runner_(runner) ,
671 received_stop_flinging_(received_stop_flinging) {} 672 received_stop_flinging_(received_stop_flinging) {}
672 673
673 virtual void BindToHandler(InputHandler* handler) OVERRIDE {
674 if (!task_runner_->BelongsToCurrentThread())
675 ADD_FAILURE() << "BindToClient called on wrong thread";
676 }
677
678 virtual void Animate(base::TimeTicks time) OVERRIDE { 674 virtual void Animate(base::TimeTicks time) OVERRIDE {
679 if (!task_runner_->BelongsToCurrentThread()) 675 if (!task_runner_->BelongsToCurrentThread())
680 ADD_FAILURE() << "Animate called on wrong thread"; 676 ADD_FAILURE() << "Animate called on wrong thread";
681 } 677 }
682 678
683 virtual void MainThreadHasStoppedFlinging() OVERRIDE { 679 virtual void MainThreadHasStoppedFlinging() OVERRIDE {
684 if (!task_runner_->BelongsToCurrentThread()) 680 if (!task_runner_->BelongsToCurrentThread())
685 ADD_FAILURE() << "MainThreadHasStoppedFlinging called on wrong thread"; 681 ADD_FAILURE() << "MainThreadHasStoppedFlinging called on wrong thread";
686 *received_stop_flinging_ = true; 682 *received_stop_flinging_ = true;
687 } 683 }
688 684
689 private: 685 private:
690 base::SingleThreadTaskRunner* task_runner_; 686 base::SingleThreadTaskRunner* task_runner_;
691 bool* received_stop_flinging_; 687 bool* received_stop_flinging_;
692 }; 688 };
693 689
694 class ThreadCheckingFakeLayerTreeHostClient : public FakeLayerTreeHostClient { 690 void BindInputHandlerOnCompositorThread(
695 public: 691 const base::WeakPtr<cc::InputHandler>& input_handler,
696 ThreadCheckingFakeLayerTreeHostClient( 692 ThreadCheckingInputHandlerClient* client) {
697 base::SingleThreadTaskRunner* task_runner, 693 input_handler->BindToClient(client);
698 bool* received_stop_flinging) 694 }
699 : FakeLayerTreeHostClient(DIRECT_3D) ,
700 task_runner_(task_runner),
701 received_stop_flinging_(received_stop_flinging) {}
702
703 virtual scoped_ptr<InputHandlerClient> CreateInputHandlerClient() OVERRIDE {
704 return scoped_ptr<InputHandlerClient>(new ThreadCheckingInputHandlerClient(
705 task_runner_, received_stop_flinging_)).Pass();
706 }
707
708 private:
709 base::SingleThreadTaskRunner* task_runner_;
710 bool* received_stop_flinging_;
711 };
712 695
713 TEST(LayerTreeHostFlingTest, DidStopFlingingThread) { 696 TEST(LayerTreeHostFlingTest, DidStopFlingingThread) {
714 base::Thread impl_thread("cc"); 697 base::Thread impl_thread("cc");
715 impl_thread.Start(); 698 impl_thread.Start();
716 scoped_ptr<cc::Thread> impl_ccthread = 699 scoped_ptr<cc::Thread> impl_ccthread =
717 cc::ThreadImpl::CreateForDifferentThread( 700 cc::ThreadImpl::CreateForDifferentThread(
718 impl_thread.message_loop_proxy()); 701 impl_thread.message_loop_proxy());
719 702
720 bool received_stop_flinging = false; 703 bool received_stop_flinging = false;
721 ThreadCheckingFakeLayerTreeHostClient client(
722 impl_thread.message_loop_proxy().get(),
723 &received_stop_flinging);
724 LayerTreeSettings settings; 704 LayerTreeSettings settings;
725 705
706 ThreadCheckingInputHandlerClient input_handler_client(
707 impl_thread.message_loop_proxy().get(), &received_stop_flinging);
708 cc::FakeLayerTreeHostClient client(cc::FakeLayerTreeHostClient::DIRECT_3D);
danakj 2013/05/01 19:20:43 no cc:: needed
709
726 scoped_ptr<LayerTreeHost> layer_tree_host = 710 scoped_ptr<LayerTreeHost> layer_tree_host =
727 LayerTreeHost::Create(&client, settings, impl_ccthread.Pass()); 711 LayerTreeHost::Create(&client, settings, impl_ccthread.Pass());
728 712
713 impl_thread.message_loop_proxy()->PostTask(FROM_HERE,
714 base::Bind(&BindInputHandlerOnCompositorThread,
715 layer_tree_host->GetInputHandler(),
716 &input_handler_client));
717
729 layer_tree_host->DidStopFlinging(); 718 layer_tree_host->DidStopFlinging();
730 layer_tree_host.reset(); 719 layer_tree_host.reset();
731 impl_thread.Stop(); 720 impl_thread.Stop();
732 EXPECT_TRUE(received_stop_flinging); 721 EXPECT_TRUE(received_stop_flinging);
733 } 722 }
734 723
735 } // namespace 724 } // namespace
736 } // namespace cc 725 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698