summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-27 21:14:57 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-27 21:14:57 +0000
commit1d7b60c36369815b2d08ab7836d2193f85a9b946 (patch)
tree163181ef552c367bf52608f08d8bd18c57b88dc8
parent62d317f17a184ff6ececa01cd16a0902f723f375 (diff)
downloadchromium_src-1d7b60c36369815b2d08ab7836d2193f85a9b946.zip
chromium_src-1d7b60c36369815b2d08ab7836d2193f85a9b946.tar.gz
chromium_src-1d7b60c36369815b2d08ab7836d2193f85a9b946.tar.bz2
Make the UI controls (back/forward/stop) in TestShell disable when appropriate.
R=dglazkov Review URL: http://codereview.chromium.org/554102 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37309 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/tools/test_shell/test_shell.cc9
-rw-r--r--webkit/tools/test_shell/test_shell.h16
-rw-r--r--webkit/tools/test_shell/test_shell_gtk.cc4
-rw-r--r--webkit/tools/test_shell/test_shell_mac.mm4
-rw-r--r--webkit/tools/test_shell/test_shell_win.cc19
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.cc11
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.h2
7 files changed, 65 insertions, 0 deletions
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
index c93d814..d931384 100644
--- a/webkit/tools/test_shell/test_shell.cc
+++ b/webkit/tools/test_shell/test_shell.cc
@@ -171,6 +171,15 @@ TestShell::~TestShell() {
}
}
+void TestShell::UpdateNavigationControls() {
+ int current_index = navigation_controller()->GetCurrentEntryIndex();
+ int max_index = navigation_controller()->GetEntryCount() - 1;
+
+ EnableUIControl(BACK_BUTTON, current_index > 0);
+ EnableUIControl(FORWARD_BUTTON, current_index < max_index);
+ EnableUIControl(STOP_BUTTON, is_loading_);
+}
+
bool TestShell::CreateNewWindow(const GURL& starting_url,
TestShell** result) {
TestShell* shell = new TestShell();
diff --git a/webkit/tools/test_shell/test_shell.h b/webkit/tools/test_shell/test_shell.h
index 3a8e4d7f..00a01c2 100644
--- a/webkit/tools/test_shell/test_shell.h
+++ b/webkit/tools/test_shell/test_shell.h
@@ -107,6 +107,11 @@ public:
}
WebWidgetHost* popupHost() { return m_popupHost; }
+ bool is_loading() const { return is_loading_; }
+ void set_is_loading(bool is_loading) { is_loading_ = is_loading; }
+
+ void UpdateNavigationControls();
+
// A new TestShell window will be opened with devtools url.
// DevTools window can be opened manually via menu or automatically when
// inspector's layout test url is passed from command line or console.
@@ -312,6 +317,14 @@ protected:
// Set the focus in interactive mode (pass through to relevant system call).
void InteractiveSetFocus(WebWidgetHost* host, bool enable);
+ enum UIControl {
+ BACK_BUTTON,
+ FORWARD_BUTTON,
+ STOP_BUTTON
+ };
+
+ void EnableUIControl(UIControl control, bool is_enabled);
+
#if defined(OS_WIN)
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
static LRESULT CALLBACK EditWndProc(HWND, UINT, WPARAM, LPARAM);
@@ -375,6 +388,9 @@ private:
// True if driven from a nested message loop.
bool is_modal_;
+ // True if the page is loading.
+ bool is_loading_;
+
// The preferences for the test shell.
static WebPreferences* web_prefs_;
diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc
index 5b00be5..f9c3138 100644
--- a/webkit/tools/test_shell/test_shell_gtk.cc
+++ b/webkit/tools/test_shell/test_shell_gtk.cc
@@ -319,6 +319,10 @@ void TestShell::PlatformCleanUp() {
}
}
+void TestShell::EnableUIControl(UIControl control, bool is_enabled) {
+ // TODO(darin): Implement me.
+}
+
bool TestShell::Initialize(const GURL& starting_url) {
m_mainWnd = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
gtk_window_set_title(m_mainWnd, "Test Shell");
diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm
index 9e13f0d..c3760de 100644
--- a/webkit/tools/test_shell/test_shell_mac.mm
+++ b/webkit/tools/test_shell/test_shell_mac.mm
@@ -155,6 +155,10 @@ FilePath GetResourcesFilePath() {
void TestShell::PlatformCleanUp() {
}
+void TestShell::EnableUIControl(UIControl control, bool is_enabled) {
+ // TODO(darin): Implement me.
+}
+
// static
void TestShell::DestroyAssociatedShell(gfx::NativeWindow handle) {
WindowMap::iterator it = window_map_.Get().find(handle);
diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc
index 2de1695..bab45ab 100644
--- a/webkit/tools/test_shell/test_shell_win.cc
+++ b/webkit/tools/test_shell/test_shell_win.cc
@@ -317,6 +317,25 @@ void TestShell::PlatformCleanUp() {
win_util::SetWindowUserData(m_editWnd, NULL);
}
+void TestShell::EnableUIControl(UIControl control, bool is_enabled) {
+ int id;
+ switch (control) {
+ case BACK_BUTTON:
+ id = IDC_NAV_BACK;
+ break;
+ case FORWARD_BUTTON:
+ id = IDC_NAV_FORWARD;
+ break;
+ case STOP_BUTTON:
+ id = IDC_NAV_STOP;
+ break;
+ default:
+ NOTREACHED() << "Unknown UI control";
+ return;
+ }
+ EnableWindow(GetDlgItem(m_mainWnd, id), is_enabled);
+}
+
bool TestShell::Initialize(const GURL& starting_url) {
// Perform application initialization:
m_mainWnd = CreateWindow(g_windowClass, g_windowTitle,
diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc
index 54a1ea3..c789997 100644
--- a/webkit/tools/test_shell/test_webview_delegate.cc
+++ b/webkit/tools/test_shell/test_webview_delegate.cc
@@ -336,6 +336,16 @@ void TestWebViewDelegate::didAddMessageToConsole(
}
}
+void TestWebViewDelegate::didStartLoading() {
+ shell_->set_is_loading(true);
+ shell_->UpdateNavigationControls();
+}
+
+void TestWebViewDelegate::didStopLoading() {
+ shell_->set_is_loading(false);
+ shell_->UpdateNavigationControls();
+}
+
// The output from these methods in layout test mode should match that
// expected by the layout tests. See EditingDelegate.m in DumpRenderTree.
@@ -1146,6 +1156,7 @@ void TestWebViewDelegate::UpdateURL(WebFrame* frame) {
entry->SetContentState(webkit_glue::HistoryItemToString(history_item));
shell_->navigation_controller()->DidNavigateToEntry(entry.release());
+ shell_->UpdateNavigationControls();
last_page_id_updated_ = std::max(last_page_id_updated_, page_id_);
}
diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h
index cb403fa..6036648 100644
--- a/webkit/tools/test_shell/test_webview_delegate.h
+++ b/webkit/tools/test_shell/test_webview_delegate.h
@@ -80,6 +80,8 @@ class TestWebViewDelegate : public WebKit::WebViewClient,
virtual void didAddMessageToConsole(
const WebKit::WebConsoleMessage& message,
const WebKit::WebString& source_name, unsigned source_line);
+ virtual void didStartLoading();
+ virtual void didStopLoading();
virtual bool shouldBeginEditing(const WebKit::WebRange& range);
virtual bool shouldEndEditing(const WebKit::WebRange& range);
virtual bool shouldInsertNode(