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

Unified Diff: content/shell/renderer/test_runner/mock_presentation_client.cc

Issue 907893002: Retry to add MockPresentationClient to use in layout tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replaced a failing DCHECK with a Reset(). Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
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..02012bca821851a92d8e266e1e6c1aedfc266c70
--- /dev/null
+++ b/content/shell/renderer/test_runner/mock_presentation_client.cc
@@ -0,0 +1,61 @@
+// 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 "content/shell/renderer/test_runner/mock_presentation_service.h"
+#include "third_party/WebKit/public/platform/modules/presentation/WebPresentationController.h"
+
+namespace content {
+
+MockPresentationClient::MockPresentationClient(MockPresentationService* service)
+ : controller_(nullptr),
+ screen_availability_(false),
+ service_(service) {
+ DCHECK(service_);
+ service_->RegisterPresentationClientMock(this);
+}
+
+MockPresentationClient::~MockPresentationClient() {
+ DCHECK(!controller_);
+ if (service_)
+ service_->UnregisterPresentationClientMock(this);
+}
+
+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::Reset() {
+ screen_availability_ = false;
+ service_ = nullptr;
+}
+
+void MockPresentationClient::setController(
+ blink::WebPresentationController* controller) {
+ DCHECK(controller_ != controller && (!controller || !controller_))
+ << "Either one of the new or the old controller must be null, "
+ "controller_ is " << controller_ << ", controller is " << controller;
+
+ controller_ = controller;
+}
+
+void MockPresentationClient::updateAvailableChangeWatched(bool watched) {
+ if (!watched)
+ return;
+ DCHECK(controller_);
+ if (screen_availability_)
+ controller_->didChangeAvailability(screen_availability_);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698