Chromium Code Reviews| Index: content/shell/renderer/test_runner/mock_presentation_client.cc |
| diff --git a/content/shell/renderer/test_runner/mock_presentation_client.cc b/content/shell/renderer/test_runner/mock_presentation_client.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..866a3e66a9017e45b3f5ea9c760a6f4c8295424c |
| --- /dev/null |
| +++ b/content/shell/renderer/test_runner/mock_presentation_client.cc |
| @@ -0,0 +1,47 @@ |
| +// 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 "content/shell/renderer/test_runner/mock_presentation_client.h" |
| + |
| +#include "base/logging.h" |
| +#include "third_party/WebKit/public/platform/modules/presentation/WebPresentationController.h" |
| + |
| +namespace content { |
| + |
| +MockPresentationClient::MockPresentationClient() |
| + : controller_(nullptr), |
| + screen_availability_(false) { |
| +} |
| + |
| +MockPresentationClient::~MockPresentationClient() { |
| +} |
| + |
| +void MockPresentationClient::SetScreenAvailability(bool available) { |
| + if (screen_availability_ == available) |
| + return; |
| + screen_availability_ = available; |
| + |
| + if (!controller_) |
| + return; |
| + if (!controller_->isAvailableChangeWatched()) |
| + return; |
| + controller_->didChangeAvailability(screen_availability_); |
| +} |
| + |
| +void MockPresentationClient::setController( |
| + blink::WebPresentationController* controller) { |
| + controller_ = controller; |
|
Peter Beverloo
2015/02/09 17:40:32
I don't like removing the DCHECK() here because yo
whywhat
2015/02/12 16:30:47
Acknowledged.
|
| + if (controller_) |
| + updateAvailableChangeWatched(controller_->isAvailableChangeWatched()); |
| +} |
| + |
| +void MockPresentationClient::updateAvailableChangeWatched(bool watched) { |
| + if (!watched) |
| + return; |
| + DCHECK(controller_); |
| + if (screen_availability_) |
| + controller_->didChangeAvailability(screen_availability_); |
| +} |
| + |
| +} // namespace content |