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

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

Issue 7553009: Add some browser tests for net-internals (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix test_view.js Created 9 years, 4 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
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 #include <vector> 7 #include <vector>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 (running_ && waiting_for_ == NotificationService::AllSources())) { 893 (running_ && waiting_for_ == NotificationService::AllSources())) {
894 seen_ = true; 894 seen_ = true;
895 if (running_) 895 if (running_)
896 MessageLoopForUI::current()->Quit(); 896 MessageLoopForUI::current()->Quit();
897 } else { 897 } else {
898 sources_seen_.insert(source.map_key()); 898 sources_seen_.insert(source.map_key());
899 } 899 }
900 } 900 }
901 901
902 TitleWatcher::TitleWatcher(TabContents* tab_contents, 902 TitleWatcher::TitleWatcher(TabContents* tab_contents,
903 const string16& expected_title) 903 const string16& expected_title,
904 const string16& failure_title)
904 : expected_tab_(tab_contents), 905 : expected_tab_(tab_contents),
905 expected_title_(expected_title), 906 expected_title_(expected_title),
906 title_observed_(false), 907 failure_title_(failure_title),
908 expected_title_observed_(false),
909 failure_title_observed_(false),
907 quit_loop_on_observation_(false) { 910 quit_loop_on_observation_(false) {
908 EXPECT_TRUE(tab_contents != NULL); 911 EXPECT_TRUE(tab_contents != NULL);
909 notification_registrar_.Add(this, 912 notification_registrar_.Add(this,
910 content::NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED, 913 content::NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED,
911 Source<TabContents>(tab_contents)); 914 Source<TabContents>(tab_contents));
912 } 915 }
913 916
914 TitleWatcher::~TitleWatcher() { 917 TitleWatcher::~TitleWatcher() {
915 } 918 }
916 919
917 bool TitleWatcher::Wait() { 920 bool TitleWatcher::Wait() {
918 if (title_observed_) 921 if (expected_title_observed_)
919 return true; 922 return true;
923 if (failure_title_observed_)
924 return false;
920 quit_loop_on_observation_ = true; 925 quit_loop_on_observation_ = true;
921 ui_test_utils::RunMessageLoop(); 926 ui_test_utils::RunMessageLoop();
922 return title_observed_; 927 return expected_title_observed_ && !failure_title_observed_;
923 } 928 }
924 929
925 void TitleWatcher::Observe(int type, 930 void TitleWatcher::Observe(int type,
926 const NotificationSource& source, 931 const NotificationSource& source,
927 const NotificationDetails& details) { 932 const NotificationDetails& details) {
928 if (type != content::NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED) 933 if (type != content::NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED)
929 return; 934 return;
930 935
931 TabContents* source_contents = Source<TabContents>(source).ptr(); 936 TabContents* source_contents = Source<TabContents>(source).ptr();
932 ASSERT_EQ(expected_tab_, source_contents); 937 ASSERT_EQ(expected_tab_, source_contents);
933 if (source_contents->GetTitle() != expected_title_) 938 if (source_contents->GetTitle() == expected_title_) {
939 expected_title_observed_ = true;
940 } else if (failure_title_.length() > 0 &&
941 source_contents->GetTitle() == failure_title_) {
942 failure_title_observed_ = true;
943 } else {
934 return; 944 return;
945 }
935 946
936 title_observed_ = true;
937 if (quit_loop_on_observation_) 947 if (quit_loop_on_observation_)
938 MessageLoopForUI::current()->Quit(); 948 MessageLoopForUI::current()->Quit();
939 } 949 }
940 950
941 DOMMessageQueue::DOMMessageQueue() { 951 DOMMessageQueue::DOMMessageQueue() {
942 registrar_.Add(this, chrome::NOTIFICATION_DOM_OPERATION_RESPONSE, 952 registrar_.Add(this, chrome::NOTIFICATION_DOM_OPERATION_RESPONSE,
943 NotificationService::AllSources()); 953 NotificationService::AllSources());
944 } 954 }
945 955
946 DOMMessageQueue::~DOMMessageQueue() {} 956 DOMMessageQueue::~DOMMessageQueue() {}
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); 1053 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap);
1044 } 1054 }
1045 1055
1046 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { 1056 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) {
1047 DCHECK(bitmap); 1057 DCHECK(bitmap);
1048 SnapshotTaker taker; 1058 SnapshotTaker taker;
1049 return taker.TakeEntirePageSnapshot(rvh, bitmap); 1059 return taker.TakeEntirePageSnapshot(rvh, bitmap);
1050 } 1060 }
1051 1061
1052 } // namespace ui_test_utils 1062 } // namespace ui_test_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698