Set the window to the default size on #reset!

This should prevent state leakage between test cases.
This commit is contained in:
Tom Lea 2012-03-29 18:01:02 +01:00 committed by Joe Ferris
parent 04fde02ad7
commit 1a609a945d
4 changed files with 13 additions and 0 deletions

View File

@ -48,5 +48,12 @@ describe Capybara::Driver::Webkit, "#resize_window(width, height)" do
@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

View File

@ -16,6 +16,7 @@ void Reset::start() {
page()->setUserAgent(NULL);
page()->resetResponseHeaders();
page()->resetConsoleMessages();
page()->resetWindowSize();
resetHistory();
emit finished(new Response(true));
}

View File

@ -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));
}

View File

@ -19,6 +19,7 @@ class WebPage : public QWebPage {
bool ignoreSslErrors();
QString consoleMessages();
void resetConsoleMessages();
void resetWindowSize();
public slots:
bool shouldInterruptJavaScript();