Skip to content

Commit

Permalink
Set the window to the default size on #reset!
Browse files Browse the repository at this point in the history
This should prevent state leakage between test cases.
  • Loading branch information
tomlea authored and jferris committed Apr 3, 2012
1 parent 04fde02 commit 1a609a9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spec/driver_resize_window_spec.rb
Expand Up @@ -48,5 +48,12 @@
@driver.body.should include("[800x600]")
end

it "resets the window to the default size when the driver is reset" do
@driver.resize_window(800, 600)
@driver.reset!
@driver.visit("/")
@driver.body.should include(DEFAULT_DIMENTIONS)
end

after(:all) { @driver.reset! }
end
1 change: 1 addition & 0 deletions src/Reset.cpp
Expand Up @@ -16,6 +16,7 @@ void Reset::start() {
page()->setUserAgent(NULL);
page()->resetResponseHeaders();
page()->resetConsoleMessages();
page()->resetWindowSize();
resetHistory();
emit finished(new Response(true));
}
Expand Down
4 changes: 4 additions & 0 deletions src/WebPage.cpp
Expand Up @@ -20,6 +20,10 @@ WebPage::WebPage(QObject *parent) : QWebPage(parent) {
this, SLOT(frameCreated(QWebFrame *)));
connect(this, SIGNAL(unsupportedContent(QNetworkReply*)),
this, SLOT(handleUnsupportedContent(QNetworkReply*)));
resetWindowSize();
}

void WebPage::resetWindowSize() {
this->setViewportSize(QSize(1680, 1050));
}

Expand Down
1 change: 1 addition & 0 deletions src/WebPage.h
Expand Up @@ -19,6 +19,7 @@ class WebPage : public QWebPage {
bool ignoreSslErrors();
QString consoleMessages();
void resetConsoleMessages();
void resetWindowSize();

public slots:
bool shouldInterruptJavaScript();
Expand Down

0 comments on commit 1a609a9

Please sign in to comment.