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

Side by Side Diff: chrome/browser/ui/views/web_dialog_view_browsertest.cc

Issue 10805047: Move WebDialogView to ui/views/controls/webview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/web_dialog_view.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_tabstrip.h" 13 #include "chrome/browser/ui/browser_tabstrip.h"
14 #include "chrome/browser/ui/views/web_dialog_view.h"
15 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h" 14 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h"
16 #include "chrome/browser/ui/webui/test_web_dialog_delegate.h" 15 #include "chrome/browser/ui/webui/test_web_dialog_delegate.h"
17 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
18 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
19 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
20 #include "content/public/browser/browser_context.h" 19 #include "content/public/browser/browser_context.h"
21 #include "content/public/browser/render_widget_host_view.h" 20 #include "content/public/browser/render_widget_host_view.h"
22 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
23 #include "content/public/browser/web_contents_view.h" 22 #include "content/public/browser/web_contents_view.h"
24 #include "testing/gmock/include/gmock/gmock.h" 23 #include "testing/gmock/include/gmock/gmock.h"
25 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
25 #include "ui/views/controls/webview/web_dialog_view.h"
26 #include "ui/views/widget/widget.h" 26 #include "ui/views/widget/widget.h"
27 27
28 using content::BrowserContext; 28 using content::BrowserContext;
29 using content::WebContents; 29 using content::WebContents;
30 using testing::Eq; 30 using testing::Eq;
31 using ui::WebDialogDelegate; 31 using ui::WebDialogDelegate;
32 32
33 namespace { 33 namespace {
34 34
35 // Initial size of WebDialog for SizeWindow test case. 35 // Initial size of WebDialog for SizeWindow test case.
36 const int kInitialWidth = 40; 36 const int kInitialWidth = 40;
37 const int kInitialHeight = 40; 37 const int kInitialHeight = 40;
38 38
39 class TestWebDialogView : public WebDialogView { 39 class TestWebDialogView : public views::WebDialogView {
40 public: 40 public:
41 TestWebDialogView(content::BrowserContext* context, 41 TestWebDialogView(content::BrowserContext* context,
42 WebDialogDelegate* delegate) 42 WebDialogDelegate* delegate)
43 : WebDialogView(context, delegate, new ChromeWebContentsHandler), 43 : views::WebDialogView(context, delegate, new ChromeWebContentsHandler),
44 should_quit_on_size_change_(false) { 44 should_quit_on_size_change_(false) {
45 delegate->GetDialogSize(&last_size_); 45 delegate->GetDialogSize(&last_size_);
46 } 46 }
47 47
48 void set_should_quit_on_size_change(bool should_quit) { 48 void set_should_quit_on_size_change(bool should_quit) {
49 should_quit_on_size_change_ = should_quit; 49 should_quit_on_size_change_ = should_quit;
50 } 50 }
51 51
52 private: 52 private:
53 // TODO(xiyuan): Update this when WidgetDelegate has bounds change hook. 53 // TODO(xiyuan): Update this when WidgetDelegate has bounds change hook.
54 virtual void SaveWindowPlacement(const gfx::Rect& bounds, 54 virtual void SaveWindowPlacement(const gfx::Rect& bounds,
55 ui::WindowShowState show_state) OVERRIDE { 55 ui::WindowShowState show_state) OVERRIDE {
56 if (should_quit_on_size_change_ && last_size_ != bounds.size()) { 56 if (should_quit_on_size_change_ && last_size_ != bounds.size()) {
57 // Schedule message loop quit because we could be called while 57 // Schedule message loop quit because we could be called while
58 // the bounds change call is on the stack and not in the nested message 58 // the bounds change call is on the stack and not in the nested message
59 // loop. 59 // loop.
60 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( 60 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
61 &MessageLoop::Quit, base::Unretained(MessageLoop::current()))); 61 &MessageLoop::Quit, base::Unretained(MessageLoop::current())));
62 } 62 }
63 63
64 last_size_ = bounds.size(); 64 last_size_ = bounds.size();
65 } 65 }
66 66
67 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE { 67 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE {
68 should_quit_on_size_change_ = false; // No quit when we are closing. 68 should_quit_on_size_change_ = false; // No quit when we are closing.
69 WebDialogView::OnDialogClosed(json_retval); 69 views::WebDialogView::OnDialogClosed(json_retval);
70 } 70 }
71 71
72 // Whether we should quit message loop when size change is detected. 72 // Whether we should quit message loop when size change is detected.
73 bool should_quit_on_size_change_; 73 bool should_quit_on_size_change_;
74 gfx::Size last_size_; 74 gfx::Size last_size_;
75 75
76 DISALLOW_COPY_AND_ASSIGN(TestWebDialogView); 76 DISALLOW_COPY_AND_ASSIGN(TestWebDialogView);
77 }; 77 };
78 78
79 } // namespace 79 } // namespace
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // Check to make sure we can't get to 0x0 167 // Check to make sure we can't get to 0x0
168 set_bounds.set_width(0); 168 set_bounds.set_width(0);
169 set_bounds.set_height(0); 169 set_bounds.set_height(0);
170 170
171 view->MoveContents(web_contents, set_bounds); 171 view->MoveContents(web_contents, set_bounds);
172 ui_test_utils::RunMessageLoop(); // TestWebDialogView will quit. 172 ui_test_utils::RunMessageLoop(); // TestWebDialogView will quit.
173 actual_bounds = view->GetWidget()->GetClientAreaBoundsInScreen(); 173 actual_bounds = view->GetWidget()->GetClientAreaBoundsInScreen();
174 EXPECT_LT(0, actual_bounds.width()); 174 EXPECT_LT(0, actual_bounds.width());
175 EXPECT_LT(0, actual_bounds.height()); 175 EXPECT_LT(0, actual_bounds.height());
176 } 176 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/web_dialog_view.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698