| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_RENDERER_MOCK_RENDER_THREAD_H_ | 5 #ifndef CHROME_RENDERER_MOCK_RENDER_THREAD_H_ |
| 6 #define CHROME_RENDERER_MOCK_RENDER_THREAD_H_ | 6 #define CHROME_RENDERER_MOCK_RENDER_THREAD_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 // This class is very simple mock of RenderThread. It simulates an IPC channel | 25 // This class is very simple mock of RenderThread. It simulates an IPC channel |
| 26 // which supports only two messages: | 26 // which supports only two messages: |
| 27 // ViewHostMsg_CreateWidget : sync message sent by the Widget. | 27 // ViewHostMsg_CreateWidget : sync message sent by the Widget. |
| 28 // ViewMsg_Close : async, send to the Widget. | 28 // ViewMsg_Close : async, send to the Widget. |
| 29 class MockRenderThread : public RenderThreadBase { | 29 class MockRenderThread : public RenderThreadBase { |
| 30 public: | 30 public: |
| 31 MockRenderThread(); | 31 MockRenderThread(); |
| 32 virtual ~MockRenderThread(); | 32 virtual ~MockRenderThread(); |
| 33 | 33 |
| 34 virtual const ExtensionSet* GetExtensions() const; | |
| 35 | |
| 36 // Provides access to the messages that have been received by this thread. | 34 // Provides access to the messages that have been received by this thread. |
| 37 IPC::TestSink& sink() { return sink_; } | 35 IPC::TestSink& sink() { return sink_; } |
| 38 | 36 |
| 39 // Called by the Widget. The routing_id must match the routing id assigned | 37 // Called by the Widget. The routing_id must match the routing id assigned |
| 40 // to the Widget in reply to ViewHostMsg_CreateWidget message. | 38 // to the Widget in reply to ViewHostMsg_CreateWidget message. |
| 41 virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); | 39 virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); |
| 42 | 40 |
| 43 // Called by the Widget. The routing id must match the routing id of AddRoute. | 41 // Called by the Widget. The routing id must match the routing id of AddRoute. |
| 44 virtual void RemoveRoute(int32 routing_id); | 42 virtual void RemoveRoute(int32 routing_id); |
| 45 | 43 |
| 46 // Called by the Widget. Used to send messages to the browser. | 44 // Called by the Widget. Used to send messages to the browser. |
| 47 // We short-circuit the mechanim and handle the messages right here on this | 45 // We short-circuit the mechanim and handle the messages right here on this |
| 48 // class. | 46 // class. |
| 49 virtual bool Send(IPC::Message* msg); | 47 virtual bool Send(IPC::Message* msg); |
| 50 | 48 |
| 51 // Filtering support. | 49 // Filtering support. |
| 52 virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter); | 50 virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter); |
| 53 virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter); | 51 virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter); |
| 54 | 52 |
| 55 // Our mock thread doesn't deal with hidden and restored tabs. | 53 // Our mock thread doesn't deal with hidden and restored tabs. |
| 56 virtual void WidgetHidden() { } | 54 virtual void WidgetHidden() { } |
| 57 virtual void WidgetRestored() { } | 55 virtual void WidgetRestored() { } |
| 58 | 56 |
| 59 virtual bool IsExtensionProcess() const; | |
| 60 virtual bool IsIncognitoProcess() const; | 57 virtual bool IsIncognitoProcess() const; |
| 61 void SetExtensionProcess(bool value) { is_extension_process_ = value; } | |
| 62 | 58 |
| 63 ////////////////////////////////////////////////////////////////////////// | 59 ////////////////////////////////////////////////////////////////////////// |
| 64 // The following functions are called by the test itself. | 60 // The following functions are called by the test itself. |
| 65 | 61 |
| 66 void set_routing_id(int32 id) { | 62 void set_routing_id(int32 id) { |
| 67 routing_id_ = id; | 63 routing_id_ = id; |
| 68 } | 64 } |
| 69 | 65 |
| 70 int32 opener_id() const { | 66 int32 opener_id() const { |
| 71 return opener_id_; | 67 return opener_id_; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 // We only keep track of one Widget, we learn its pointer when it | 133 // We only keep track of one Widget, we learn its pointer when it |
| 138 // adds a new route. | 134 // adds a new route. |
| 139 IPC::Channel::Listener* widget_; | 135 IPC::Channel::Listener* widget_; |
| 140 | 136 |
| 141 // The last known good deserializer for sync messages. | 137 // The last known good deserializer for sync messages. |
| 142 scoped_ptr<IPC::MessageReplyDeserializer> reply_deserializer_; | 138 scoped_ptr<IPC::MessageReplyDeserializer> reply_deserializer_; |
| 143 | 139 |
| 144 // A mock printer device used for printing tests. | 140 // A mock printer device used for printing tests. |
| 145 scoped_ptr<MockPrinter> printer_; | 141 scoped_ptr<MockPrinter> printer_; |
| 146 | 142 |
| 147 // Contains extensions currently loaded by browser. This is usually empty | |
| 148 // for MockRenderThread. | |
| 149 ExtensionSet extensions_; | |
| 150 | |
| 151 bool is_extension_process_; | |
| 152 | |
| 153 // True to simulate user clicking print. False to cancel. | 143 // True to simulate user clicking print. False to cancel. |
| 154 bool print_dialog_user_response_; | 144 bool print_dialog_user_response_; |
| 155 }; | 145 }; |
| 156 | 146 |
| 157 #endif // CHROME_RENDERER_MOCK_RENDER_THREAD_H_ | 147 #endif // CHROME_RENDERER_MOCK_RENDER_THREAD_H_ |
| OLD | NEW |