OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/devtools/device/cloud/devtools_bridge_client.h" |
| 6 #include "chrome/browser/profiles/profile.h" |
| 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/test/base/in_process_browser_test.h" |
| 9 #include "content/public/test/test_utils.h" |
| 10 |
| 11 class DevToolsBridgeClientTest : public InProcessBrowserTest, |
| 12 protected DevToolsBridgeClient::Delegate { |
| 13 protected: |
| 14 DevToolsBridgeClientTest() |
| 15 : state_(STATE_NONE) { |
| 16 } |
| 17 |
| 18 enum State { |
| 19 STATE_NONE, |
| 20 STATE_WAITING_COMMAND |
| 21 }; |
| 22 |
| 23 void Wait(State state) { |
| 24 DCHECK(state_ == STATE_NONE); |
| 25 DCHECK(state == STATE_NONE); |
| 26 |
| 27 state_ = state; |
| 28 runner_ = new content::MessageLoopRunner; |
| 29 runner_->Run(); |
| 30 runner_ = NULL; |
| 31 } |
| 32 |
| 33 void SendCommand(const std::string& command) override { |
| 34 if (state_ == STATE_WAITING_COMMAND) { |
| 35 runner_->Quit(); |
| 36 } |
| 37 } |
| 38 |
| 39 private: |
| 40 State state_; |
| 41 scoped_refptr<content::MessageLoopRunner> runner_; |
| 42 }; |
| 43 |
| 44 IN_PROC_BROWSER_TEST_F(DevToolsBridgeClientTest, TestInstanceCreateion) { |
| 45 scoped_ptr<DevToolsBridgeClient> client = |
| 46 DevToolsBridgeClient::CreateInstance(browser()->profile(), this); |
| 47 |
| 48 client->StartSession("DEVICE_ID"); |
| 49 Wait(STATE_WAITING_COMMAND); |
| 50 } |
OLD | NEW |