This source file includes following definitions.
- GetURLRequestContext
- GetNetworkTaskRunner
- TakePath
- SetSpecialStoragePolicy
- GetPath
- IsOffTheRecord
- GetDownloadManagerDelegate
- GetRequestContext
- GetRequestContextForRenderProcess
- GetMediaRequestContext
- GetMediaRequestContextForRenderProcess
- GetMediaRequestContextForStoragePartition
- RequestMidiSysExPermission
- CancelMidiSysExPermissionRequest
- RequestProtectedMediaIdentifierPermission
- CancelProtectedMediaIdentifierPermissionRequests
- GetResourceContext
- GetGeolocationPermissionContext
- GetSpecialStoragePolicy
#include "content/public/test/test_browser_context.h"
#include "base/files/file_path.h"
#include "base/test/null_task_runner.h"
#include "content/public/test/mock_resource_context.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/browser/quota/special_storage_policy.h"
namespace {
class TestContextURLRequestContextGetter : public net::URLRequestContextGetter {
public:
TestContextURLRequestContextGetter()
: null_task_runner_(new base::NullTaskRunner) {
}
virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE {
return &context_;
}
virtual scoped_refptr<base::SingleThreadTaskRunner>
GetNetworkTaskRunner() const OVERRIDE {
return null_task_runner_;
}
private:
virtual ~TestContextURLRequestContextGetter() {}
net::TestURLRequestContext context_;
scoped_refptr<base::SingleThreadTaskRunner> null_task_runner_;
};
}
namespace content {
TestBrowserContext::TestBrowserContext() {
EXPECT_TRUE(browser_context_dir_.CreateUniqueTempDir());
}
TestBrowserContext::~TestBrowserContext() {
}
base::FilePath TestBrowserContext::TakePath() {
return browser_context_dir_.Take();
}
void TestBrowserContext::SetSpecialStoragePolicy(
quota::SpecialStoragePolicy* policy) {
special_storage_policy_ = policy;
}
base::FilePath TestBrowserContext::GetPath() const {
return browser_context_dir_.path();
}
bool TestBrowserContext::IsOffTheRecord() const {
return false;
}
DownloadManagerDelegate* TestBrowserContext::GetDownloadManagerDelegate() {
return NULL;
}
net::URLRequestContextGetter* TestBrowserContext::GetRequestContext() {
if (!request_context_.get()) {
request_context_ = new TestContextURLRequestContextGetter();
}
return request_context_.get();
}
net::URLRequestContextGetter*
TestBrowserContext::GetRequestContextForRenderProcess(int renderer_child_id) {
return NULL;
}
net::URLRequestContextGetter* TestBrowserContext::GetMediaRequestContext() {
return NULL;
}
net::URLRequestContextGetter*
TestBrowserContext::GetMediaRequestContextForRenderProcess(
int renderer_child_id) {
return NULL;
}
net::URLRequestContextGetter*
TestBrowserContext::GetMediaRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory) {
return NULL;
}
void TestBrowserContext::RequestMidiSysExPermission(
int render_process_id,
int render_view_id,
int bridge_id,
const GURL& requesting_frame,
bool user_gesture,
const MidiSysExPermissionCallback& callback) {
callback.Run(false);
}
void TestBrowserContext::CancelMidiSysExPermissionRequest(
int render_process_id,
int render_view_id,
int bridge_id,
const GURL& requesting_frame) {
}
void TestBrowserContext::RequestProtectedMediaIdentifierPermission(
int render_process_id,
int render_view_id,
int bridge_id,
int group_id,
const GURL& requesting_frame,
const ProtectedMediaIdentifierPermissionCallback& callback) {
callback.Run(false);
}
void TestBrowserContext::CancelProtectedMediaIdentifierPermissionRequests(
int group_id) {
}
ResourceContext* TestBrowserContext::GetResourceContext() {
if (!resource_context_)
resource_context_.reset(new MockResourceContext(
GetRequestContext()->GetURLRequestContext()));
return resource_context_.get();
}
GeolocationPermissionContext*
TestBrowserContext::GetGeolocationPermissionContext() {
return NULL;
}
quota::SpecialStoragePolicy* TestBrowserContext::GetSpecialStoragePolicy() {
return special_storage_policy_.get();
}
}