| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // FIXME: http://crbug.com/363843. This needs to find a better way to | 67 // FIXME: http://crbug.com/363843. This needs to find a better way to |
| 68 // not create graphics layers. | 68 // not create graphics layers. |
| 69 m_webView->settings()->setAcceleratedCompositingEnabled(false); | 69 m_webView->settings()->setAcceleratedCompositingEnabled(false); |
| 70 m_mainFrame = WebLocalFrame::create(WebTreeScopeType::Document, &m_webFr
ameClient); | 70 m_mainFrame = WebLocalFrame::create(WebTreeScopeType::Document, &m_webFr
ameClient); |
| 71 m_webView->setMainFrame(m_mainFrame); | 71 m_webView->setMainFrame(m_mainFrame); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void TearDown() override | 74 void TearDown() override |
| 75 { | 75 { |
| 76 m_webView->close(); | 76 m_webView->close(); |
| 77 m_mainFrame->close(); |
| 77 } | 78 } |
| 78 | 79 |
| 79 WebString userAgent() | 80 WebString userAgent() |
| 80 { | 81 { |
| 81 // The test always returns the same user agent . | 82 // The test always returns the same user agent . |
| 82 WTF::CString userAgent = frameLoaderClient().userAgent().utf8(); | 83 WTF::CString userAgent = frameLoaderClient().userAgent().utf8(); |
| 83 return WebString::fromUTF8(userAgent.data(), userAgent.length()); | 84 return WebString::fromUTF8(userAgent.data(), userAgent.length()); |
| 84 } | 85 } |
| 85 | 86 |
| 86 WebLocalFrameImpl* mainFrame() { return toWebLocalFrameImpl(m_webView->mainF
rame()); } | 87 WebLocalFrameImpl* mainFrame() { return toWebLocalFrameImpl(m_webView->mainF
rame()); } |
| 87 Document& document() { return *toWebLocalFrameImpl(m_mainFrame)->frame()->do
cument(); } | 88 Document& document() { return *toWebLocalFrameImpl(m_mainFrame)->frame()->do
cument(); } |
| 88 MockWebFrameClient& webFrameClient() { return m_webFrameClient; } | 89 MockWebFrameClient& webFrameClient() { return m_webFrameClient; } |
| 89 FrameLoaderClient& frameLoaderClient() { return *toFrameLoaderClientImpl(toW
ebLocalFrameImpl(m_webView->mainFrame())->frame()->loader().client()); } | 90 FrameLoaderClient& frameLoaderClient() { return *toFrameLoaderClientImpl(toW
ebLocalFrameImpl(m_webView->mainFrame())->frame()->loader().client()); } |
| 90 | 91 |
| 91 private: | 92 private: |
| 92 MockWebFrameClient m_webFrameClient; | 93 MockWebFrameClient m_webFrameClient; |
| 93 WebView* m_webView; | 94 WebView* m_webView; |
| 94 WebLocalFrame* m_mainFrame; | 95 WebFrame* m_mainFrame; |
| 95 }; | 96 }; |
| 96 | 97 |
| 97 TEST_F(FrameLoaderClientImplTest, UserAgentOverride) | 98 TEST_F(FrameLoaderClientImplTest, UserAgentOverride) |
| 98 { | 99 { |
| 99 const WebString defaultUserAgent = userAgent(); | 100 const WebString defaultUserAgent = userAgent(); |
| 100 const WebString overrideUserAgent = WebString::fromUTF8("dummy override"); | 101 const WebString overrideUserAgent = WebString::fromUTF8("dummy override"); |
| 101 | 102 |
| 102 // Override the user agent and make sure we get it back. | 103 // Override the user agent and make sure we get it back. |
| 103 EXPECT_CALL(webFrameClient(), userAgentOverride()).WillOnce(Return(overrideU
serAgent)); | 104 EXPECT_CALL(webFrameClient(), userAgentOverride()).WillOnce(Return(overrideU
serAgent)); |
| 104 EXPECT_TRUE(overrideUserAgent.equals(userAgent())); | 105 EXPECT_TRUE(overrideUserAgent.equals(userAgent())); |
| 105 Mock::VerifyAndClearExpectations(&webFrameClient()); | 106 Mock::VerifyAndClearExpectations(&webFrameClient()); |
| 106 | 107 |
| 107 // Remove the override and make sure we get the original back. | 108 // Remove the override and make sure we get the original back. |
| 108 EXPECT_CALL(webFrameClient(), userAgentOverride()).WillOnce(Return(WebString
())); | 109 EXPECT_CALL(webFrameClient(), userAgentOverride()).WillOnce(Return(WebString
())); |
| 109 EXPECT_TRUE(defaultUserAgent.equals(userAgent())); | 110 EXPECT_TRUE(defaultUserAgent.equals(userAgent())); |
| 110 } | 111 } |
| 111 | 112 |
| 112 } // namespace | 113 } // namespace |
| 113 } // namespace blink | 114 } // namespace blink |
| OLD | NEW |