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 #include "chrome/common/content_settings.h" | 5 #include "chrome/common/content_settings.h" |
6 #include "chrome/common/render_messages.h" | 6 #include "chrome/common/render_messages.h" |
7 #include "chrome/renderer/content_settings_observer.h" | 7 #include "chrome/renderer/content_settings_observer.h" |
8 #include "chrome/test/base/render_view_test.h" | 8 #include "chrome/test/base/render_view_test.h" |
9 #include "content/common/view_messages.h" | 9 #include "content/common/view_messages.h" |
10 #include "ipc/ipc_message_macros.h" | 10 #include "ipc/ipc_message_macros.h" |
11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
14 | 14 |
15 using testing::_; | 15 using testing::_; |
16 using testing::DeleteArg; | 16 using testing::DeleteArg; |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 class MockContentSettingsObserver : public ContentSettingsObserver { | 20 class MockContentSettingsObserver : public ContentSettingsObserver { |
21 public: | 21 public: |
22 explicit MockContentSettingsObserver(RenderView* render_view); | 22 explicit MockContentSettingsObserver(content::RenderView* render_view); |
23 | 23 |
24 virtual bool Send(IPC::Message* message); | 24 virtual bool Send(IPC::Message* message); |
25 | 25 |
26 MOCK_METHOD2(OnContentBlocked, | 26 MOCK_METHOD2(OnContentBlocked, |
27 void(ContentSettingsType, const std::string&)); | 27 void(ContentSettingsType, const std::string&)); |
28 | 28 |
29 MOCK_METHOD5(OnAllowDOMStorage, | 29 MOCK_METHOD5(OnAllowDOMStorage, |
30 void(int, const GURL&, const GURL&, bool, IPC::Message*)); | 30 void(int, const GURL&, const GURL&, bool, IPC::Message*)); |
31 }; | 31 }; |
32 | 32 |
33 MockContentSettingsObserver::MockContentSettingsObserver( | 33 MockContentSettingsObserver::MockContentSettingsObserver( |
34 RenderView* render_view) | 34 content::RenderView* render_view) |
35 : ContentSettingsObserver(render_view) { | 35 : ContentSettingsObserver(render_view) { |
36 } | 36 } |
37 | 37 |
38 bool MockContentSettingsObserver::Send(IPC::Message* message) { | 38 bool MockContentSettingsObserver::Send(IPC::Message* message) { |
39 IPC_BEGIN_MESSAGE_MAP(MockContentSettingsObserver, *message) | 39 IPC_BEGIN_MESSAGE_MAP(MockContentSettingsObserver, *message) |
40 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ContentBlocked, OnContentBlocked) | 40 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ContentBlocked, OnContentBlocked) |
41 IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_AllowDOMStorage, | 41 IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_AllowDOMStorage, |
42 OnAllowDOMStorage) | 42 OnAllowDOMStorage) |
43 IPC_MESSAGE_UNHANDLED(ADD_FAILURE()) | 43 IPC_MESSAGE_UNHANDLED(ADD_FAILURE()) |
44 IPC_END_MESSAGE_MAP() | 44 IPC_END_MESSAGE_MAP() |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 // Simulate a navigation within the page. | 162 // Simulate a navigation within the page. |
163 view_->didNavigateWithinPage(GetMainFrame(), true); | 163 view_->didNavigateWithinPage(GetMainFrame(), true); |
164 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 164 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
165 observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS)); | 165 observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS)); |
166 | 166 |
167 // Navigate to a different page. | 167 // Navigate to a different page. |
168 LoadHTML("<html>Bar</html>"); | 168 LoadHTML("<html>Bar</html>"); |
169 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 169 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
170 observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS)); | 170 observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS)); |
171 } | 171 } |
OLD | NEW |