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

Unified Diff: content/shell/renderer/test_runner/mock_presentation_service.h

Issue 907893002: Retry to add MockPresentationClient to use in layout tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split Presentation API mock into per-frame and per-view objects 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_service.h
diff --git a/content/shell/renderer/test_runner/mock_presentation_service.h b/content/shell/renderer/test_runner/mock_presentation_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..0e853ba94be13d0c9402f30f835c0c68d174a8e4
--- /dev/null
+++ b/content/shell/renderer/test_runner/mock_presentation_service.h
@@ -0,0 +1,48 @@
+// 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.
+
+#ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCK_PRESENTATION_SERVICE_H_
+#define CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCK_PRESENTATION_SERVICE_H_
+
+#include "base/macros.h"
+#include "base/observer_list.h"
+#include "content/shell/renderer/test_runner/mock_presentation_client.h"
+
+namespace content {
+
+// A mock implementation of the Mojo PresentationService to be used in tests
+// with content shell. Keeps track of all MockPresentationClient instances and
+// updates each instance with the new state if needed. The service is owned by
+// the WebTextProxy instance (so only one exists per RenderView). Each
+// MockPresentationClient is owned by WebFrameTextProxy (so one exists per each
+// RenderFrame, same as the real PresentationDispatcher) and is registered with
+// the MockPresentationService by the WebFrameTestProxy upon creation.
+class MockPresentationService {
+ public:
+ MockPresentationService();
+ virtual ~MockPresentationService();
+
+ // Imitates getting the actual screen availability for the platform.
+ // If the state changed from the last call, notifies the registered clients.
+ void SetScreenAvailability(bool available);
+
+ // Resets the service state to the defaults for the next test.
+ void Reset();
+
+ // ObserverList implementation.
+ void RegisterPresentationClientMock(MockPresentationClient* client);
+ void UnregisterPresentationClientMock(MockPresentationClient* client);
+
+ private:
+ // The last known state of the screen availability, defaults to false.
+ bool screen_availability_;
+ // The registered presentation client mocks.
+ ObserverList<MockPresentationClient> presentation_clients_;
+
+ DISALLOW_COPY_AND_ASSIGN(MockPresentationService);
+};
+
+} // namespace content
+
+#endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCK_PRESENTATION_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698