OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "content/browser/browser_thread_impl.h" | 7 #include "content/browser/browser_thread_impl.h" |
8 #include "content/public/browser/devtools_http_handler.h" | 8 #include "content/public/browser/devtools_http_handler.h" |
9 #include "content/public/browser/devtools_http_handler_delegate.h" | 9 #include "content/public/browser/devtools_http_handler_delegate.h" |
10 #include "net/socket/stream_listen_socket.h" | 10 #include "net/socket/stream_listen_socket.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 BrowserThread::UI, FROM_HERE, quit_closure_1_); | 49 BrowserThread::UI, FROM_HERE, quit_closure_1_); |
50 return new DummyListenSocket(); | 50 return new DummyListenSocket(); |
51 } | 51 } |
52 private: | 52 private: |
53 base::Closure quit_closure_1_; | 53 base::Closure quit_closure_1_; |
54 base::Closure quit_closure_2_; | 54 base::Closure quit_closure_2_; |
55 }; | 55 }; |
56 | 56 |
57 class DummyDelegate : public DevToolsHttpHandlerDelegate { | 57 class DummyDelegate : public DevToolsHttpHandlerDelegate { |
58 public: | 58 public: |
59 virtual std::string GetDiscoveryPageHTML() OVERRIDE { return ""; } | 59 virtual std::string GetDiscoveryPageHTML() OVERRIDE { return std::string(); } |
60 virtual bool BundlesFrontendResources() OVERRIDE { return true; } | 60 virtual bool BundlesFrontendResources() OVERRIDE { return true; } |
61 virtual base::FilePath GetDebugFrontendDir() OVERRIDE { | 61 virtual base::FilePath GetDebugFrontendDir() OVERRIDE { |
62 return base::FilePath(); | 62 return base::FilePath(); |
63 } | 63 } |
64 virtual std::string GetPageThumbnailData(const GURL& url) OVERRIDE { | 64 virtual std::string GetPageThumbnailData(const GURL& url) OVERRIDE { |
65 return ""; | 65 return std::string(); |
66 } | 66 } |
67 virtual RenderViewHost* CreateNewTarget() OVERRIDE { return NULL; } | 67 virtual RenderViewHost* CreateNewTarget() OVERRIDE { return NULL; } |
68 virtual TargetType GetTargetType(RenderViewHost*) OVERRIDE { | 68 virtual TargetType GetTargetType(RenderViewHost*) OVERRIDE { |
69 return kTargetTypeTab; | 69 return kTargetTypeTab; |
70 } | 70 } |
71 virtual std::string GetViewDescription(content::RenderViewHost*) OVERRIDE { | 71 virtual std::string GetViewDescription(content::RenderViewHost*) OVERRIDE { |
72 return ""; | 72 return std::string(); |
73 } | 73 } |
74 }; | 74 }; |
75 | 75 |
76 } | 76 } |
77 | 77 |
78 class DevToolsHttpHandlerTest : public testing::Test { | 78 class DevToolsHttpHandlerTest : public testing::Test { |
79 public: | 79 public: |
80 DevToolsHttpHandlerTest() | 80 DevToolsHttpHandlerTest() |
81 : ui_thread_(BrowserThread::UI, &message_loop_) { | 81 : ui_thread_(BrowserThread::UI, &message_loop_) { |
82 } | 82 } |
83 protected: | 83 protected: |
84 virtual void SetUp() { | 84 virtual void SetUp() { |
85 file_thread_.reset(new BrowserThreadImpl(BrowserThread::FILE)); | 85 file_thread_.reset(new BrowserThreadImpl(BrowserThread::FILE)); |
86 file_thread_->Start(); | 86 file_thread_->Start(); |
87 } | 87 } |
88 virtual void TearDown() { | 88 virtual void TearDown() { |
89 file_thread_->Stop(); | 89 file_thread_->Stop(); |
90 } | 90 } |
91 private: | 91 private: |
92 MessageLoopForIO message_loop_; | 92 MessageLoopForIO message_loop_; |
93 BrowserThreadImpl ui_thread_; | 93 BrowserThreadImpl ui_thread_; |
94 scoped_ptr<BrowserThreadImpl> file_thread_; | 94 scoped_ptr<BrowserThreadImpl> file_thread_; |
95 }; | 95 }; |
96 | 96 |
97 TEST_F(DevToolsHttpHandlerTest, TestStartStop) { | 97 TEST_F(DevToolsHttpHandlerTest, TestStartStop) { |
98 base::RunLoop run_loop, run_loop_2; | 98 base::RunLoop run_loop, run_loop_2; |
99 content::DevToolsHttpHandler* devtools_http_handler_ = | 99 content::DevToolsHttpHandler* devtools_http_handler_ = |
100 content::DevToolsHttpHandler::Start( | 100 content::DevToolsHttpHandler::Start( |
101 new DummyListenSocketFactory( | 101 new DummyListenSocketFactory(run_loop.QuitClosure(), |
102 run_loop.QuitClosure(), run_loop_2.QuitClosure()), | 102 run_loop_2.QuitClosure()), |
103 "", | 103 std::string(), |
104 new DummyDelegate()); | 104 new DummyDelegate()); |
105 // Our dummy socket factory will post a quit message once the server will | 105 // Our dummy socket factory will post a quit message once the server will |
106 // become ready. | 106 // become ready. |
107 run_loop.Run(); | 107 run_loop.Run(); |
108 devtools_http_handler_->Stop(); | 108 devtools_http_handler_->Stop(); |
109 // Make sure the handler actually stops. | 109 // Make sure the handler actually stops. |
110 run_loop_2.Run(); | 110 run_loop_2.Run(); |
111 } | 111 } |
112 | 112 |
113 } // namespace content | 113 } // namespace content |
OLD | NEW |