summaryrefslogtreecommitdiffstats
path: root/cc/test/proxy_main_for_test.cc
blob: 6a9fa4188bbbd66ac16d127477de4e61be6c9c7d (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
105
106
107
108
109
110
111
112
113
114
// Copyright 2015 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/test/proxy_main_for_test.h"

#include "cc/animation/animation_events.h"
#include "cc/test/threaded_channel_for_test.h"
#include "cc/trees/remote_channel_main.h"

namespace cc {

scoped_ptr<ProxyMainForTest> ProxyMainForTest::CreateThreaded(
    TestHooks* test_hooks,
    LayerTreeHost* host,
    TaskRunnerProvider* task_runner_provider) {
  scoped_ptr<ProxyMainForTest> proxy_main(
      new ProxyMainForTest(test_hooks, host, task_runner_provider));
  scoped_ptr<ThreadedChannelForTest> channel = ThreadedChannelForTest::Create(
      test_hooks, proxy_main.get(), task_runner_provider);
  proxy_main->threaded_channel_for_test_ = channel.get();
  proxy_main->SetChannel(std::move(channel));
  return proxy_main;
}

scoped_ptr<ProxyMainForTest> ProxyMainForTest::CreateRemote(
    TestHooks* test_hooks,
    RemoteProtoChannel* remote_proto_channel,
    LayerTreeHost* host,
    TaskRunnerProvider* task_runner_provider) {
  scoped_ptr<ProxyMainForTest> proxy_main(
      new ProxyMainForTest(test_hooks, host, task_runner_provider));
  proxy_main->SetChannel(RemoteChannelMain::Create(
      remote_proto_channel, proxy_main.get(), task_runner_provider));
  return proxy_main;
}

ProxyMainForTest::~ProxyMainForTest() {}

ProxyMainForTest::ProxyMainForTest(TestHooks* test_hooks,
                                   LayerTreeHost* host,
                                   TaskRunnerProvider* task_runner_provider)
    : ProxyMain(host, task_runner_provider),
      test_hooks_(test_hooks),
      threaded_channel_for_test_(nullptr) {}

void ProxyMainForTest::SetNeedsUpdateLayers() {
  ProxyMain::SetNeedsUpdateLayers();
  test_hooks_->DidSetNeedsUpdateLayers();
}

void ProxyMainForTest::DidCompleteSwapBuffers() {
  test_hooks_->ReceivedDidCompleteSwapBuffers();
  ProxyMain::DidCompleteSwapBuffers();
}

void ProxyMainForTest::SetRendererCapabilities(
    const RendererCapabilities& capabilities) {
  test_hooks_->ReceivedSetRendererCapabilitiesMainCopy(capabilities);
  ProxyMain::SetRendererCapabilities(capabilities);
}

void ProxyMainForTest::BeginMainFrameNotExpectedSoon() {
  test_hooks_->ReceivedBeginMainFrameNotExpectedSoon();
  ProxyMain::BeginMainFrameNotExpectedSoon();
}

void ProxyMainForTest::DidCommitAndDrawFrame() {
  test_hooks_->ReceivedDidCommitAndDrawFrame();
  ProxyMain::DidCommitAndDrawFrame();
}

void ProxyMainForTest::SetAnimationEvents(scoped_ptr<AnimationEvents> events) {
  test_hooks_->ReceivedSetAnimationEvents();
  ProxyMain::SetAnimationEvents(std::move(events));
}

void ProxyMainForTest::DidLoseOutputSurface() {
  test_hooks_->ReceivedDidLoseOutputSurface();
  ProxyMain::DidLoseOutputSurface();
}

void ProxyMainForTest::RequestNewOutputSurface() {
  test_hooks_->ReceivedRequestNewOutputSurface();
  ProxyMain::RequestNewOutputSurface();
}

void ProxyMainForTest::DidInitializeOutputSurface(
    bool success,
    const RendererCapabilities& capabilities) {
  test_hooks_->ReceivedDidInitializeOutputSurface(success, capabilities);
  ProxyMain::DidInitializeOutputSurface(success, capabilities);
}

void ProxyMainForTest::DidCompletePageScaleAnimation() {
  test_hooks_->ReceivedDidCompletePageScaleAnimation();
  ProxyMain::DidCompletePageScaleAnimation();
}

void ProxyMainForTest::PostFrameTimingEventsOnMain(
    scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
    scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
  test_hooks_->ReceivedPostFrameTimingEventsOnMain();
  ProxyMain::PostFrameTimingEventsOnMain(std::move(composite_events),
                                         std::move(main_frame_events));
}

void ProxyMainForTest::BeginMainFrame(
    scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) {
  test_hooks_->ReceivedBeginMainFrame();
  ProxyMain::BeginMainFrame(std::move(begin_main_frame_state));
}

}  // namespace cc