summaryrefslogtreecommitdiffstats
path: root/cc/trees/layer_tree_host_unittest_remote_server.cc
blob: 9873dca1e6a9a75919469cf6eb5103127a471bc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Copyright 2016 The Chromium 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 "cc/trees/layer_tree_host.h"

#include "base/memory/scoped_ptr.h"
#include "base/thread_task_runner_handle.h"
#include "cc/test/fake_image_serialization_processor.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/layer_tree_host_client.h"
#include "cc/trees/proxy_common.h"
#include "cc/trees/proxy_main.h"
#include "cc/trees/remote_proto_channel.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace cc {
namespace {

class LayerTreeHostTestRemoteServer : public testing::Test,
                                      public RemoteProtoChannel,
                                      public LayerTreeHostClient {
 public:
  LayerTreeHostTestRemoteServer()
      : calls_received_(0),
        image_serialization_processor_(
            make_scoped_ptr(new FakeImageSerializationProcessor)) {
    LayerTreeHost::InitParams params;
    params.client = this;
    params.task_graph_runner = &task_graph_runner_;
    params.settings = &settings_;
    params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
    params.image_serialization_processor = image_serialization_processor_.get();
    layer_tree_host_ = LayerTreeHost::CreateRemoteServer(this, &params);
  }

  ~LayerTreeHostTestRemoteServer() override {}

  // LayerTreeHostClient implementation
  void WillBeginMainFrame() override {}
  void BeginMainFrame(const BeginFrameArgs& args) override {}
  void BeginMainFrameNotExpectedSoon() override {}
  void DidBeginMainFrame() override {}
  void UpdateLayerTreeHost() override {}
  void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
                           const gfx::Vector2dF& outer_delta,
                           const gfx::Vector2dF& elastic_overscroll_delta,
                           float page_scale,
                           float top_controls_delta) override {}
  void RequestNewOutputSurface() override { NOTREACHED(); }
  void DidInitializeOutputSurface() override { NOTREACHED(); }
  void DidFailToInitializeOutputSurface() override { NOTREACHED(); }
  void WillCommit() override {}
  void DidCommit() override {}
  void DidCommitAndDrawFrame() override {}
  void DidCompleteSwapBuffers() override {}
  void RecordFrameTimingEvents(
      scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
      scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events)
      override{};
  void DidCompletePageScaleAnimation() override {}
  void SendBeginFramesToChildren(const BeginFrameArgs& args) override {}

  // RemoteProtoChannel implementation
  void SetProtoReceiver(RemoteProtoChannel::ProtoReceiver* receiver) override {
    receiver_ = receiver;
  }
  void SendCompositorProto(const proto::CompositorMessage& proto) override {}

  int calls_received_;
  TestTaskGraphRunner task_graph_runner_;
  LayerTreeSettings settings_;
  scoped_ptr<LayerTreeHost> layer_tree_host_;
  RemoteProtoChannel::ProtoReceiver* receiver_;
  scoped_ptr<FakeImageSerializationProcessor> image_serialization_processor_;

 private:
  DISALLOW_COPY_AND_ASSIGN(LayerTreeHostTestRemoteServer);
};

class LayerTreeHostTestRemoteServerBeginMainFrame
    : public LayerTreeHostTestRemoteServer {
 protected:
  void BeginMainFrame(const BeginFrameArgs& args) override {
    calls_received_++;
  }
};

// Makes sure that the BeginMainFrame call is not aborted on the server.
// See crbug.com/577301.
TEST_F(LayerTreeHostTestRemoteServerBeginMainFrame, BeginMainFrameNotAborted) {
  layer_tree_host_->SetVisible(true);

  scoped_ptr<BeginMainFrameAndCommitState> begin_frame_state;
  begin_frame_state.reset(new BeginMainFrameAndCommitState());
  begin_frame_state->scroll_info.reset(new ScrollAndScaleSet());

  static_cast<ProxyMain*>(layer_tree_host_->proxy())
      ->BeginMainFrame(std::move(begin_frame_state));
  EXPECT_EQ(calls_received_, 1);
}

}  // namespace
}  // namespace cc