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

Side by Side Diff: ui/views/controls/webview/webview_unittest.cc

Issue 1159033008: Refactor ViewsDelegate singleton (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed review comments Created 5 years, 6 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/views/controls/webview/webview.h" 5 #include "ui/views/controls/webview/webview.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "content/public/browser/web_contents.h" 8 #include "content/public/browser/web_contents.h"
9 #include "content/public/browser/web_contents_observer.h" 9 #include "content/public/browser/web_contents_observer.h"
10 #include "content/public/test/test_browser_context.h" 10 #include "content/public/test/test_browser_context.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 WebViewUnitTest() 122 WebViewUnitTest()
123 : ui_thread_(content::BrowserThread::UI, base::MessageLoop::current()), 123 : ui_thread_(content::BrowserThread::UI, base::MessageLoop::current()),
124 file_blocking_thread_(content::BrowserThread::FILE_USER_BLOCKING, 124 file_blocking_thread_(content::BrowserThread::FILE_USER_BLOCKING,
125 base::MessageLoop::current()), 125 base::MessageLoop::current()),
126 io_thread_(content::BrowserThread::IO, base::MessageLoop::current()), 126 io_thread_(content::BrowserThread::IO, base::MessageLoop::current()),
127 top_level_widget_(nullptr) {} 127 top_level_widget_(nullptr) {}
128 128
129 ~WebViewUnitTest() override {} 129 ~WebViewUnitTest() override {}
130 130
131 void SetUp() override { 131 void SetUp() override {
132 // The ViewsDelegate is deleted when the ViewsTestBase class is torn down. 132 set_views_delegate(make_scoped_ptr(new WebViewTestViewsDelegate));
133 WidgetTest::set_views_delegate(new WebViewTestViewsDelegate);
134 browser_context_.reset(new content::TestBrowserContext); 133 browser_context_.reset(new content::TestBrowserContext);
135 WidgetTest::SetUp(); 134 WidgetTest::SetUp();
136 // Set the test content browser client to avoid pulling in needless 135 // Set the test content browser client to avoid pulling in needless
137 // dependencies from content. 136 // dependencies from content.
138 SetBrowserClientForTesting(&test_browser_client_); 137 SetBrowserClientForTesting(&test_browser_client_);
139 138
140 // Create a top level widget and add a child, and give it a WebView as a 139 // Create a top level widget and add a child, and give it a WebView as a
141 // child. 140 // child.
142 top_level_widget_ = CreateTopLevelFramelessPlatformWidget(); 141 top_level_widget_ = CreateTopLevelFramelessPlatformWidget();
143 top_level_widget_->SetBounds(gfx::Rect(0, 10, 100, 100)); 142 top_level_widget_->SetBounds(gfx::Rect(0, 10, 100, 100));
(...skipping 25 matching lines...) Expand all
169 scoped_ptr<content::WebContents> CreateWebContents() const { 168 scoped_ptr<content::WebContents> CreateWebContents() const {
170 return make_scoped_ptr(content::WebContents::Create( 169 return make_scoped_ptr(content::WebContents::Create(
171 content::WebContents::CreateParams(browser_context_.get()))); 170 content::WebContents::CreateParams(browser_context_.get())));
172 } 171 }
173 172
174 private: 173 private:
175 content::TestBrowserThread ui_thread_; 174 content::TestBrowserThread ui_thread_;
176 content::TestBrowserThread file_blocking_thread_; 175 content::TestBrowserThread file_blocking_thread_;
177 content::TestBrowserThread io_thread_; 176 content::TestBrowserThread io_thread_;
178 scoped_ptr<content::TestBrowserContext> browser_context_; 177 scoped_ptr<content::TestBrowserContext> browser_context_;
179 scoped_ptr<WebViewTestViewsDelegate> views_delegate_;
180 content::TestContentBrowserClient test_browser_client_; 178 content::TestContentBrowserClient test_browser_client_;
181 179
182 Widget* top_level_widget_; 180 Widget* top_level_widget_;
183 WebView* web_view_; 181 WebView* web_view_;
184 182
185 DISALLOW_COPY_AND_ASSIGN(WebViewUnitTest); 183 DISALLOW_COPY_AND_ASSIGN(WebViewUnitTest);
186 }; 184 };
187 185
188 // Tests that attaching and detaching a WebContents to a WebView makes the 186 // Tests that attaching and detaching a WebContents to a WebView makes the
189 // WebContents visible and hidden respectively. 187 // WebContents visible and hidden respectively.
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 gfx::Point(), // Immaterial. 428 gfx::Point(), // Immaterial.
431 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); 429 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0);
432 EXPECT_FALSE(static_cast<views::View*>(web_view())-> 430 EXPECT_FALSE(static_cast<views::View*>(web_view())->
433 OnMousePressed(click_inside_holder)); 431 OnMousePressed(click_inside_holder));
434 EXPECT_FALSE(web_view()->HasFocus()); 432 EXPECT_FALSE(web_view()->HasFocus());
435 EXPECT_FALSE(holder()->HasFocus()); 433 EXPECT_FALSE(holder()->HasFocus());
436 EXPECT_TRUE(something_to_focus->HasFocus()); 434 EXPECT_TRUE(something_to_focus->HasFocus());
437 } 435 }
438 436
439 } // namespace views 437 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698