OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/shell/renderer/test_runner/mock_presentation_client.h" | 5 #include "content/shell/renderer/test_runner/mock_presentation_client.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/shell/renderer/test_runner/mock_presentation_service.h" | 8 #include "content/shell/renderer/test_runner/mock_presentation_service.h" |
9 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nController.h" | 9 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nController.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 MockPresentationClient::MockPresentationClient(MockPresentationService* service) | 13 MockPresentationClient::MockPresentationClient(MockPresentationService* service) |
14 : controller_(nullptr), | 14 : controller_(nullptr), |
15 screen_availability_(false), | 15 screen_availability_(false), |
16 service_(service) { | 16 service_(service) { |
17 DCHECK(service_); | 17 DCHECK(service_); |
18 service_->RegisterPresentationClientMock(this); | 18 service_->RegisterPresentationClientMock(this); |
19 } | 19 } |
20 | 20 |
21 MockPresentationClient::~MockPresentationClient() { | 21 MockPresentationClient::~MockPresentationClient() { |
22 DCHECK(!controller_); | 22 DCHECK(!controller_); |
23 if (service_) | 23 DCHECK(service_); |
24 service_->UnregisterPresentationClientMock(this); | 24 service_->UnregisterPresentationClientMock(this); |
25 } | 25 } |
26 | 26 |
27 void MockPresentationClient::SetScreenAvailability(bool available) { | 27 void MockPresentationClient::SetScreenAvailability(bool available) { |
28 if (screen_availability_ == available) | 28 if (screen_availability_ == available) |
29 return; | 29 return; |
30 screen_availability_ = available; | 30 screen_availability_ = available; |
31 | 31 |
32 if (!controller_) | 32 if (!controller_) |
33 return; | 33 return; |
34 if (!controller_->isAvailableChangeWatched()) | 34 if (!controller_->isAvailableChangeWatched()) |
35 return; | 35 return; |
36 controller_->didChangeAvailability(screen_availability_); | 36 controller_->didChangeAvailability(screen_availability_); |
37 } | 37 } |
38 | 38 |
39 void MockPresentationClient::Reset() { | 39 void MockPresentationClient::Reset() { |
40 screen_availability_ = false; | 40 screen_availability_ = false; |
41 service_ = nullptr; | |
42 } | 41 } |
43 | 42 |
44 void MockPresentationClient::setController( | 43 void MockPresentationClient::setController( |
45 blink::WebPresentationController* controller) { | 44 blink::WebPresentationController* controller) { |
46 DCHECK(controller_ != controller && (!controller || !controller_)) | 45 DCHECK(controller_ != controller && (!controller || !controller_)) |
47 << "Either one of the new or the old controller must be null, " | 46 << "Either one of the new or the old controller must be null, " |
48 "controller_ is " << controller_ << ", controller is " << controller; | 47 "controller_ is " << controller_ << ", controller is " << controller; |
49 | 48 |
50 controller_ = controller; | 49 controller_ = controller; |
51 } | 50 } |
52 | 51 |
53 void MockPresentationClient::updateAvailableChangeWatched(bool watched) { | 52 void MockPresentationClient::updateAvailableChangeWatched(bool watched) { |
54 if (!watched) | 53 if (!watched) |
55 return; | 54 return; |
56 DCHECK(controller_); | 55 DCHECK(controller_); |
57 if (screen_availability_) | 56 if (screen_availability_) |
58 controller_->didChangeAvailability(screen_availability_); | 57 controller_->didChangeAvailability(screen_availability_); |
59 } | 58 } |
60 | 59 |
61 } // namespace content | 60 } // namespace content |
OLD | NEW |