1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_MEDIA_WEBRTC_BROWSERTEST_COMMON_H_ 6 #define CHROME_BROWSER_MEDIA_WEBRTC_BROWSERTEST_COMMON_H_ 7 8 #include <string> 9 10 #include "base/process/process_handle.h" 11 12 namespace content { 13 class WebContents; 14 } 15 16 // Executes javascript code which will sleep for |timeout_msec| milliseconds. 17 // Returns true on success. 18 bool SleepInJavascript(content::WebContents* tab_contents, int timeout_msec); 19 20 // This function will execute the provided |javascript| until it causes a call 21 // to window.domAutomationController.send() with |evaluates_to| as the message. 22 // That is, we are NOT checking what the javascript evaluates to. Returns false 23 // if we exceed the TestTimeouts::action_max_timeout(). 24 // TODO(phoglund): Consider a better interaction method with the javascript 25 // than polling javascript methods. 26 bool PollingWaitUntil(const std::string& javascript, 27 const std::string& evaluates_to, 28 content::WebContents* tab_contents); 29 bool PollingWaitUntil(const std::string& javascript, 30 const std::string& evaluates_to, 31 content::WebContents* tab_contents, 32 int poll_interval_msec); 33 34 class PeerConnectionServerRunner { 35 public: 36 PeerConnectionServerRunner(): server_pid_(0) {} 37 ~PeerConnectionServerRunner() {} 38 39 bool Start(); 40 bool Stop(); 41 42 static void KillAllPeerConnectionServersOnCurrentSystem(); 43 44 private: 45 base::ProcessHandle server_pid_; 46 }; 47 48 #endif // CHROME_BROWSER_MEDIA_WEBRTC_BROWSERTEST_COMMON_H_ 49