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

Side by Side Diff: components/test_runner/test_runner.h

Issue 1931833003: Moving TestRunnerForSpecificView into a separate compilation unit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing... Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « components/test_runner/test_common.cc ('k') | components/test_runner/test_runner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_ 5 #ifndef COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_
6 #define COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_ 6 #define COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <deque> 10 #include <deque>
(...skipping 10 matching lines...) Expand all
21 #include "third_party/WebKit/public/platform/WebImage.h" 21 #include "third_party/WebKit/public/platform/WebImage.h"
22 #include "v8/include/v8.h" 22 #include "v8/include/v8.h"
23 23
24 class GURL; 24 class GURL;
25 class SkBitmap; 25 class SkBitmap;
26 26
27 namespace blink { 27 namespace blink {
28 class WebContentSettingsClient; 28 class WebContentSettingsClient;
29 class WebFrame; 29 class WebFrame;
30 class WebLocalFrame; 30 class WebLocalFrame;
31 class WebMediaStream;
32 class WebString; 31 class WebString;
33 class WebView; 32 class WebView;
34 class WebURLResponse;
35 } 33 }
36 34
37 namespace gin { 35 namespace gin {
38 class ArrayBufferView; 36 class ArrayBufferView;
39 class Arguments; 37 class Arguments;
40 } 38 }
41 39
42 namespace test_runner { 40 namespace test_runner {
43 41
44 class InvokeCallbackTask;
45 class MockContentSettingsClient; 42 class MockContentSettingsClient;
46 class MockCredentialManagerClient; 43 class MockCredentialManagerClient;
47 class MockScreenOrientationClient; 44 class MockScreenOrientationClient;
48 class MockWebSpeechRecognizer; 45 class MockWebSpeechRecognizer;
49 class MockWebUserMediaClient; 46 class MockWebUserMediaClient;
50 class SpellCheckClient; 47 class SpellCheckClient;
51 class TestInterfaces; 48 class TestInterfaces;
52 class TestRunnerForSpecificView; 49 class TestRunnerForSpecificView;
53 class WebTestDelegate; 50 class WebTestDelegate;
54 class WebTestProxyBase;
55 51
56 // TestRunner class currently has dual purpose: 52 // TestRunner class currently has dual purpose:
57 // 1. It implements |testRunner| javascript bindings for "global" / "ambient". 53 // 1. It implements |testRunner| javascript bindings for "global" / "ambient".
58 // Examples: 54 // Examples:
59 // - testRunner.dumpAsText (test flag affecting test behavior) 55 // - testRunner.dumpAsText (test flag affecting test behavior)
60 // - testRunner.setAllowDisplayOfInsecureContent (test flag affecting product 56 // - testRunner.setAllowDisplayOfInsecureContent (test flag affecting product
61 // behavior) 57 // behavior)
62 // - testRunner.setTextSubpixelPositioning (directly interacts with product). 58 // - testRunner.setTextSubpixelPositioning (directly interacts with product).
63 // Note that "per-view" (non-"global") bindings are handled by 59 // Note that "per-view" (non-"global") bindings are handled by
64 // instances of TestRunnerForSpecificView class. 60 // instances of TestRunnerForSpecificView class.
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 // is ok, because this is taken care of in WebTestDelegate::SetFocus). 641 // is ok, because this is taken care of in WebTestDelegate::SetFocus).
646 blink::WebView* previously_focused_view_; 642 blink::WebView* previously_focused_view_;
647 643
648 std::set<blink::WebView*> views_with_scheduled_animations_; 644 std::set<blink::WebView*> views_with_scheduled_animations_;
649 645
650 base::WeakPtrFactory<TestRunner> weak_factory_; 646 base::WeakPtrFactory<TestRunner> weak_factory_;
651 647
652 DISALLOW_COPY_AND_ASSIGN(TestRunner); 648 DISALLOW_COPY_AND_ASSIGN(TestRunner);
653 }; 649 };
654 650
655 // TestRunnerForSpecificView implements part of |testRunner| javascript bindings
656 // that work with a view where the javascript call originated from. Examples:
657 // - testRunner.capturePixelsAsyncThen
658 // - testRunner.setPageVisibility
659 // Note that "global" bindings are handled by TestRunner class.
660 // TODO(lukasza): Move this class to a separate compilation unit.
661 class TestRunnerForSpecificView {
662 public:
663 explicit TestRunnerForSpecificView(WebTestProxyBase* web_test_proxy_base);
664 ~TestRunnerForSpecificView();
665
666 // Installs view-specific bindings (handled by |this|) and *also* global
667 // TestRunner bindings (both kinds of bindings are exposed via a single
668 // |testRunner| object in javascript).
669 void Install(blink::WebLocalFrame* frame);
670
671 void Reset();
672
673 // Pointer lock methods used by WebViewTestClient.
674 bool RequestPointerLock();
675 void RequestPointerUnlock();
676 bool isPointerLocked();
677
678 private:
679 friend class TestRunnerBindings;
680
681 // Helpers for working with base and V8 callbacks.
682 void PostTask(const base::Closure& callback);
683 void PostDelayedTask(long long delay, const base::Closure& callback);
684 void PostV8Callback(const v8::Local<v8::Function>& callback);
685 void PostV8CallbackWithArgs(v8::UniquePersistent<v8::Function> callback,
686 int argc,
687 v8::Local<v8::Value> argv[]);
688 void InvokeV8Callback(const v8::UniquePersistent<v8::Function>& callback);
689 void InvokeV8CallbackWithArgs(
690 const v8::UniquePersistent<v8::Function>& callback,
691 const std::vector<v8::UniquePersistent<v8::Value>>& args);
692 base::Closure CreateClosureThatPostsV8Callback(
693 const v8::Local<v8::Function>& callback);
694
695 void LayoutAndPaintAsync();
696 void LayoutAndPaintAsyncThen(v8::Local<v8::Function> callback);
697
698 // Similar to LayoutAndPaintAsyncThen(), but pass parameters of the captured
699 // snapshot (width, height, snapshot) to the callback. The snapshot is in
700 // uint8_t RGBA format.
701 void CapturePixelsAsyncThen(v8::Local<v8::Function> callback);
702 void CapturePixelsCallback(v8::UniquePersistent<v8::Function> callback,
703 const SkBitmap& snapshot);
704
705 // Similar to CapturePixelsAsyncThen(). Copies to the clipboard the image
706 // located at a particular point in the WebView (if there is such an image),
707 // reads back its pixels, and provides the snapshot to the callback. If there
708 // is no image at that point, calls the callback with (0, 0, empty_snapshot).
709 void CopyImageAtAndCapturePixelsAsyncThen(
710 int x,
711 int y,
712 const v8::Local<v8::Function> callback);
713
714 void GetManifestThen(v8::Local<v8::Function> callback);
715 void GetManifestCallback(v8::UniquePersistent<v8::Function> callback,
716 const blink::WebURLResponse& response,
717 const std::string& data);
718
719 // Calls |callback| with a DOMString[] representing the events recorded since
720 // the last call to this function.
721 void GetBluetoothManualChooserEvents(v8::Local<v8::Function> callback);
722 void GetBluetoothManualChooserEventsCallback(
723 v8::UniquePersistent<v8::Function> callback,
724 const std::vector<std::string>& events);
725
726 // Change the bluetooth test data while running a layout test.
727 void SetBluetoothFakeAdapter(const std::string& adapter_name,
728 v8::Local<v8::Function> callback);
729
730 // If |enable| is true, makes the Bluetooth chooser record its input and wait
731 // for instructions from the test program on how to proceed. Otherwise falls
732 // back to the browser's default chooser.
733 void SetBluetoothManualChooser(bool enable);
734
735 // Calls the BluetoothChooser::EventHandler with the arguments here. Valid
736 // event strings are:
737 // * "cancel" - simulates the user canceling the chooser.
738 // * "select" - simulates the user selecting a device whose device ID is in
739 // |argument|.
740 void SendBluetoothManualChooserEvent(const std::string& event,
741 const std::string& argument);
742
743 // Used to set the device scale factor.
744 void SetBackingScaleFactor(double value, v8::Local<v8::Function> callback);
745
746 // Enable zoom-for-dsf option.
747 // TODO(oshima): Remove this once all platforms migrated.
748 void EnableUseZoomForDSF(v8::Local<v8::Function> callback);
749
750 // Change the device color profile while running a layout test.
751 void SetColorProfile(const std::string& name,
752 v8::Local<v8::Function> callback);
753
754 // Causes the beforeinstallprompt event to be sent to the renderer.
755 void DispatchBeforeInstallPromptEvent(
756 int request_id,
757 const std::vector<std::string>& event_platforms,
758 v8::Local<v8::Function> callback);
759 void DispatchBeforeInstallPromptCallback(
760 v8::UniquePersistent<v8::Function> callback,
761 bool canceled);
762
763 // Immediately run all pending idle tasks, including all pending
764 // requestIdleCallback calls. Invoke the callback when all
765 // idle tasks are complete.
766 void RunIdleTasks(v8::Local<v8::Function> callback);
767
768 // Method that controls whether pressing Tab key cycles through page elements
769 // or inserts a '\t' char in text area
770 void SetTabKeyCyclesThroughElements(bool tab_key_cycles_through_elements);
771
772 // Executes an internal command (superset of document.execCommand() commands).
773 void ExecCommand(gin::Arguments* args);
774
775 // Checks if an internal command is currently available.
776 bool IsCommandEnabled(const std::string& command);
777
778 // Returns true if the current page box has custom page size style for
779 // printing.
780 bool HasCustomPageSizeStyle(int page_index);
781
782 // Forces the selection colors for testing under Linux.
783 void ForceRedSelectionColors();
784
785 // Switch the visibility of the page.
786 void SetPageVisibility(const std::string& new_visibility);
787
788 // Changes the direction of the focused element.
789 void SetTextDirection(const std::string& direction_name);
790
791 // Dump current PageImportanceSignals for the page.
792 void DumpPageImportanceSignals();
793
794 // WebPageOverlay related functions. Permits the adding and removing of only
795 // one opaque overlay.
796 void AddWebPageOverlay();
797 void RemoveWebPageOverlay();
798
799 // Sets a flag causing the next call to WebGLRenderingContext::create to fail.
800 void ForceNextWebGLContextCreationToFail();
801
802 // Sets a flag causing the next call to DrawingBuffer::create to fail.
803 void ForceNextDrawingBufferCreationToFail();
804
805 // Gives focus to the view associated with TestRunnerForSpecificView.
806 void SetWindowIsKey(bool value);
807
808 // Pointer lock handling.
809 void DidAcquirePointerLock();
810 void DidNotAcquirePointerLock();
811 void DidLosePointerLock();
812 void SetPointerLockWillFailSynchronously();
813 void SetPointerLockWillRespondAsynchronously();
814 void DidAcquirePointerLockInternal();
815 void DidNotAcquirePointerLockInternal();
816 void DidLosePointerLockInternal();
817 bool pointer_locked_;
818 enum {
819 PointerLockWillSucceed,
820 PointerLockWillRespondAsync,
821 PointerLockWillFailSync,
822 } pointer_lock_planned_result_;
823
824 bool CallShouldCloseOnWebView();
825 void SetDomainRelaxationForbiddenForURLScheme(bool forbidden,
826 const std::string& scheme);
827 v8::Local<v8::Value> EvaluateScriptInIsolatedWorldAndReturnValue(
828 int world_id,
829 const std::string& script);
830 void EvaluateScriptInIsolatedWorld(int world_id, const std::string& script);
831 void SetIsolatedWorldSecurityOrigin(int world_id,
832 v8::Local<v8::Value> origin);
833 void SetIsolatedWorldContentSecurityPolicy(int world_id,
834 const std::string& policy);
835 bool FindString(const std::string& search_text,
836 const std::vector<std::string>& options_array);
837 std::string SelectionAsMarkup();
838 void SetViewSourceForFrame(const std::string& name, bool enabled);
839
840 // Helpers for accessing pointers exposed by |web_test_proxy_base_|.
841 blink::WebView* web_view();
842 WebTestDelegate* delegate();
843 WebTestProxyBase* web_test_proxy_base_;
844
845 base::WeakPtrFactory<TestRunnerForSpecificView> weak_factory_;
846
847 DISALLOW_COPY_AND_ASSIGN(TestRunnerForSpecificView);
848 };
849
850 } // namespace test_runner 651 } // namespace test_runner
851 652
852 #endif // COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_ 653 #endif // COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_
OLDNEW
« no previous file with comments | « components/test_runner/test_common.cc ('k') | components/test_runner/test_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698