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

Side by Side Diff: chrome/test/base/ui_test_utils.cc

Issue 8834012: Quit MessageLoop in ui_test_utils::DOMOperationObserver when the RenderView goes away. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years 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 | « no previous file | no next file » | 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) 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/test/base/ui_test_utils.h" 5 #include "chrome/test/base/ui_test_utils.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "chrome/common/extensions/extension_action.h" 43 #include "chrome/common/extensions/extension_action.h"
44 #include "chrome/test/automation/javascript_execution_controller.h" 44 #include "chrome/test/automation/javascript_execution_controller.h"
45 #include "chrome/test/base/bookmark_load_observer.h" 45 #include "chrome/test/base/bookmark_load_observer.h"
46 #include "chrome/test/base/test_navigation_observer.h" 46 #include "chrome/test/base/test_navigation_observer.h"
47 #include "content/browser/download/download_item.h" 47 #include "content/browser/download/download_item.h"
48 #include "content/browser/download/download_manager.h" 48 #include "content/browser/download/download_manager.h"
49 #include "content/browser/renderer_host/render_view_host.h" 49 #include "content/browser/renderer_host/render_view_host.h"
50 #include "content/browser/tab_contents/navigation_controller.h" 50 #include "content/browser/tab_contents/navigation_controller.h"
51 #include "content/browser/tab_contents/navigation_entry.h" 51 #include "content/browser/tab_contents/navigation_entry.h"
52 #include "content/browser/tab_contents/tab_contents.h" 52 #include "content/browser/tab_contents/tab_contents.h"
53 #include "content/browser/tab_contents/tab_contents_observer.h"
53 #include "content/public/browser/notification_service.h" 54 #include "content/public/browser/notification_service.h"
54 #include "content/public/browser/render_process_host.h" 55 #include "content/public/browser/render_process_host.h"
55 #include "googleurl/src/gurl.h" 56 #include "googleurl/src/gurl.h"
56 #include "net/base/net_util.h" 57 #include "net/base/net_util.h"
57 #include "testing/gtest/include/gtest/gtest.h" 58 #include "testing/gtest/include/gtest/gtest.h"
58 #include "third_party/skia/include/core/SkBitmap.h" 59 #include "third_party/skia/include/core/SkBitmap.h"
59 #include "third_party/skia/include/core/SkColor.h" 60 #include "third_party/skia/include/core/SkColor.h"
60 #include "ui/gfx/size.h" 61 #include "ui/gfx/size.h"
61 62
62 #if defined(TOOLKIT_VIEWS) 63 #if defined(TOOLKIT_VIEWS)
63 #include "ui/views/focus/accelerator_handler.h" 64 #include "ui/views/focus/accelerator_handler.h"
64 #endif 65 #endif
65 66
66 #if defined(USE_AURA) 67 #if defined(USE_AURA)
67 #include "ui/aura/root_window.h" 68 #include "ui/aura/root_window.h"
68 #endif 69 #endif
69 70
70 static const int kDefaultWsPort = 8880; 71 static const int kDefaultWsPort = 8880;
71 72
72 namespace ui_test_utils { 73 namespace ui_test_utils {
73 74
74 namespace { 75 namespace {
75 76
76 class DOMOperationObserver : public content::NotificationObserver { 77 class DOMOperationObserver : public content::NotificationObserver,
78 public TabContentsObserver {
77 public: 79 public:
78 explicit DOMOperationObserver(RenderViewHost* render_view_host) 80 explicit DOMOperationObserver(RenderViewHost* render_view_host)
79 : did_respond_(false) { 81 : TabContentsObserver(render_view_host->delegate()->GetAsTabContents()),
82 did_respond_(false) {
80 registrar_.Add(this, chrome::NOTIFICATION_DOM_OPERATION_RESPONSE, 83 registrar_.Add(this, chrome::NOTIFICATION_DOM_OPERATION_RESPONSE,
81 content::Source<RenderViewHost>(render_view_host)); 84 content::Source<RenderViewHost>(render_view_host));
82 ui_test_utils::RunMessageLoop(); 85 ui_test_utils::RunMessageLoop();
83 } 86 }
84 87
85 virtual void Observe(int type, 88 virtual void Observe(int type,
86 const content::NotificationSource& source, 89 const content::NotificationSource& source,
87 const content::NotificationDetails& details) { 90 const content::NotificationDetails& details) OVERRIDE {
88 DCHECK(type == chrome::NOTIFICATION_DOM_OPERATION_RESPONSE); 91 DCHECK(type == chrome::NOTIFICATION_DOM_OPERATION_RESPONSE);
89 content::Details<DomOperationNotificationDetails> dom_op_details(details); 92 content::Details<DomOperationNotificationDetails> dom_op_details(details);
90 response_ = dom_op_details->json(); 93 response_ = dom_op_details->json();
91 did_respond_ = true; 94 did_respond_ = true;
92 MessageLoopForUI::current()->Quit(); 95 MessageLoopForUI::current()->Quit();
93 } 96 }
94 97
98 // Overridden from content::TabContentsObserver:
99 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE {
100 MessageLoopForUI::current()->Quit();
101 }
102
95 bool GetResponse(std::string* response) WARN_UNUSED_RESULT { 103 bool GetResponse(std::string* response) WARN_UNUSED_RESULT {
96 *response = response_; 104 *response = response_;
97 return did_respond_; 105 return did_respond_;
98 } 106 }
99 107
100 private: 108 private:
101 content::NotificationRegistrar registrar_; 109 content::NotificationRegistrar registrar_;
102 std::string response_; 110 std::string response_;
103 bool did_respond_; 111 bool did_respond_;
104 112
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); 1061 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap);
1054 } 1062 }
1055 1063
1056 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { 1064 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) {
1057 DCHECK(bitmap); 1065 DCHECK(bitmap);
1058 SnapshotTaker taker; 1066 SnapshotTaker taker;
1059 return taker.TakeEntirePageSnapshot(rvh, bitmap); 1067 return taker.TakeEntirePageSnapshot(rvh, bitmap);
1060 } 1068 }
1061 1069
1062 } // namespace ui_test_utils 1070 } // namespace ui_test_utils
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698