Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Side by Side Diff: third_party/WebKit/Source/web/tests/FrameLoaderClientImplTest.cpp

Issue 2369613003: Require WebLocalFrame to be created with a non-null client (Closed)
Patch Set: oops Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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();
78 } 77 }
79 78
80 WebString userAgent() 79 WebString userAgent()
81 { 80 {
82 // The test always returns the same user agent . 81 // The test always returns the same user agent .
83 WTF::CString userAgent = frameLoaderClient().userAgent().utf8(); 82 WTF::CString userAgent = frameLoaderClient().userAgent().utf8();
84 return WebString::fromUTF8(userAgent.data(), userAgent.length()); 83 return WebString::fromUTF8(userAgent.data(), userAgent.length());
85 } 84 }
86 85
87 WebLocalFrameImpl* mainFrame() { return toWebLocalFrameImpl(m_webView->mainF rame()); } 86 WebLocalFrameImpl* mainFrame() { return toWebLocalFrameImpl(m_webView->mainF rame()); }
88 Document& document() { return *toWebLocalFrameImpl(m_mainFrame)->frame()->do cument(); } 87 Document& document() { return *toWebLocalFrameImpl(m_mainFrame)->frame()->do cument(); }
89 MockWebFrameClient& webFrameClient() { return m_webFrameClient; } 88 MockWebFrameClient& webFrameClient() { return m_webFrameClient; }
90 FrameLoaderClient& frameLoaderClient() { return *toFrameLoaderClientImpl(toW ebLocalFrameImpl(m_webView->mainFrame())->frame()->loader().client()); } 89 FrameLoaderClient& frameLoaderClient() { return *toFrameLoaderClientImpl(toW ebLocalFrameImpl(m_webView->mainFrame())->frame()->loader().client()); }
91 90
92 private: 91 private:
93 MockWebFrameClient m_webFrameClient; 92 MockWebFrameClient m_webFrameClient;
94 WebView* m_webView; 93 WebView* m_webView;
95 WebFrame* m_mainFrame; 94 WebLocalFrame* m_mainFrame;
96 }; 95 };
97 96
98 TEST_F(FrameLoaderClientImplTest, UserAgentOverride) 97 TEST_F(FrameLoaderClientImplTest, UserAgentOverride)
99 { 98 {
100 const WebString defaultUserAgent = userAgent(); 99 const WebString defaultUserAgent = userAgent();
101 const WebString overrideUserAgent = WebString::fromUTF8("dummy override"); 100 const WebString overrideUserAgent = WebString::fromUTF8("dummy override");
102 101
103 // Override the user agent and make sure we get it back. 102 // Override the user agent and make sure we get it back.
104 EXPECT_CALL(webFrameClient(), userAgentOverride()).WillOnce(Return(overrideU serAgent)); 103 EXPECT_CALL(webFrameClient(), userAgentOverride()).WillOnce(Return(overrideU serAgent));
105 EXPECT_TRUE(overrideUserAgent.equals(userAgent())); 104 EXPECT_TRUE(overrideUserAgent.equals(userAgent()));
106 Mock::VerifyAndClearExpectations(&webFrameClient()); 105 Mock::VerifyAndClearExpectations(&webFrameClient());
107 106
108 // Remove the override and make sure we get the original back. 107 // Remove the override and make sure we get the original back.
109 EXPECT_CALL(webFrameClient(), userAgentOverride()).WillOnce(Return(WebString ())); 108 EXPECT_CALL(webFrameClient(), userAgentOverride()).WillOnce(Return(WebString ()));
110 EXPECT_TRUE(defaultUserAgent.equals(userAgent())); 109 EXPECT_TRUE(defaultUserAgent.equals(userAgent()));
111 } 110 }
112 111
113 } // namespace 112 } // namespace
114 } // namespace blink 113 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698