diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-19 06:11:28 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-19 06:11:28 +0000 |
commit | 78089f0bfcb2e2760db01191ceb0165d9517b154 (patch) | |
tree | e371ab6d6bedc40421d351648bfb5e68235d8dff /content/test/content_browser_test_utils.cc | |
parent | 39e12cb553cf861ab0b34b3ccd82baa3dd82be7f (diff) | |
download | chromium_src-78089f0bfcb2e2760db01191ceb0165d9517b154.zip chromium_src-78089f0bfcb2e2760db01191ceb0165d9517b154.tar.gz chromium_src-78089f0bfcb2e2760db01191ceb0165d9517b154.tar.bz2 |
Get content_browsertest working. I've added a simple test for now, and will convert the tests in src/content in future changes.
BUG=90448
Review URL: https://chromiumcodereview.appspot.com/10803026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147404 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/test/content_browser_test_utils.cc')
-rw-r--r-- | content/test/content_browser_test_utils.cc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/content/test/content_browser_test_utils.cc b/content/test/content_browser_test_utils.cc new file mode 100644 index 0000000..0794328 --- /dev/null +++ b/content/test/content_browser_test_utils.cc @@ -0,0 +1,48 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/test/content_browser_test_utils.h" + +#include "base/bind.h" +#include "base/file_path.h" +#include "base/path_service.h" +#include "base/run_loop.h" +#include "content/public/browser/navigation_controller.h" +#include "content/public/browser/notification_source.h" +#include "content/public/browser/web_contents.h" +#include "content/public/common/content_paths.h" +#include "content/public/test/browser_test_utils.h" +#include "content/public/test/test_navigation_observer.h" +#include "content/shell/shell.h" +#include "net/base/net_util.h" + +namespace content { + +FilePath GetTestFilePath(const char* dir, const char* file) { + FilePath path; + PathService::Get(DIR_TEST_DATA, &path); + return path.Append( + FilePath().AppendASCII(dir).Append(FilePath().AppendASCII(file))); +} + +GURL GetTestUrl(const char* dir, const char* file) { + return net::FilePathToFileURL(GetTestFilePath(dir, file)); +} + +void NavigateToURL(Shell* window, const GURL& url) { + NavigationController* controller = &window->web_contents()->GetController(); + TestNavigationObserver same_tab_observer( + Source<NavigationController>(controller), + NULL, + 1); + + window->LoadURL(url); + + base::RunLoop run_loop; + same_tab_observer.WaitForObservation( + base::Bind(&RunThisRunLoop, base::Unretained(&run_loop)), + GetQuitTaskForRunLoop(&run_loop)); +} + +} // namespace content |