Clean up proxy interface

This commit is contained in:
Matthew Mongeau 2011-10-14 17:13:06 -04:00
parent 229a20e897
commit 93bfcf6e46
3 changed files with 17 additions and 10 deletions

View File

@ -99,16 +99,13 @@ class Capybara::Driver::Webkit
command("GetCookies").lines.map{ |line| line.strip }.select{ |line| !line.empty? }
end
def set_proxy(opts = {})
# remove proxy?
return command("SetProxy") if opts.empty?
def set_proxy(options = {})
options = default_proxy_options.merge(options)
command("SetProxy", options[:host], options[:port], options[:user], options[:pass])
end
# set a HTTP proxy
command("SetProxy",
opts[:host] || "localhost",
opts[:port] || "0",
opts[:user] || "",
opts[:pass] || "")
def clear_proxy
command("SetProxy")
end
private
@ -206,5 +203,14 @@ class Capybara::Driver::Webkit
response.force_encoding("UTF-8") if response.respond_to?(:force_encoding)
response
end
def default_proxy_options
{
:host => "localhost",
:port => "0",
:user => "",
:pass => ""
}
end
end
end

View File

@ -170,7 +170,7 @@ describe Capybara::Driver::Webkit::Browser do
it 'is possible to disable proxy again' do
@proxy_requests.clear
browser.set_proxy
browser.clear_proxy
browser.visit "http://#{@host}:#{@port}/"
@proxy_requests.size.should == 0
end

View File

@ -17,6 +17,7 @@
#include "SetCookie.h"
#include "ClearCookies.h"
#include "GetCookies.h"
#include "SetProxy.h"
CommandFactory::CommandFactory(WebPage *page, QObject *parent) : QObject(parent) {
m_page = page;