Chromium Code Reviews| Index: chrome/browser/chromeos/login/account_screen_browsertest.cc |
| =================================================================== |
| --- chrome/browser/chromeos/login/account_screen_browsertest.cc (revision 48143) |
| +++ chrome/browser/chromeos/login/account_screen_browsertest.cc (working copy) |
| @@ -4,10 +4,15 @@ |
| #include <string> |
| -#include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h" |
| +#include "chrome/browser/child_process_security_policy.h" |
| #include "chrome/browser/chromeos/login/account_screen.h" |
| #include "chrome/browser/chromeos/login/wizard_controller.h" |
| +#include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h" |
| +#include "chrome/common/url_constants.h" |
| #include "chrome/test/in_process_browser_test.h" |
| +#include "chrome/test/ui_test_utils.h" |
| +#include "net/url_request/url_request_about_job.h" |
| +#include "net/url_request/url_request_filter.h" |
| #include "testing/gmock/include/gmock/gmock.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -19,11 +24,11 @@ |
| } |
| protected: |
| - // Overriden from WizardInProcessBrowserTest: |
| + // Overridden from WizardInProcessBrowserTest: |
| virtual void SetUpWizard() { |
| HTTPTestServer* server = StartHTTPServer(); |
| ASSERT_TRUE(server != NULL); |
| - GURL new_account_page_url(server->TestServerPage("new_account.html")); |
| + GURL new_account_page_url(server->TestServerPage("files/new_account.html")); |
| AccountScreen::set_new_account_page_url(new_account_page_url); |
| AccountScreen::set_check_for_https(false); |
| } |
| @@ -32,9 +37,45 @@ |
| DISALLOW_COPY_AND_ASSIGN(AccountScreenTest); |
| }; |
| +// A basic test. It does not care how things evolve after the URL is |
| +// loaded. Thus no message loop is started. Just check that initial |
| +// status is expected. |
| IN_PROC_BROWSER_TEST_F(AccountScreenTest, TestBasic) { |
| ASSERT_TRUE(controller()); |
| EXPECT_EQ(controller()->GetAccountScreen(), controller()->current_screen()); |
| } |
| +static void QuitUIMessageLoop() { |
| + MessageLoopForUI::current()->Quit(); |
| +} |
| + |
| +static bool inspector_called = false; // had to use global flag as |
|
Nikita (slow)
2010/05/27 17:40:54
Is it possible to move this flag and InspectorHook
glotov
2010/05/27 17:55:05
It will be static there.
InspectorHook() doesn't h
|
| + // InspectorHook() doesn't have context. |
| + |
| +static URLRequestJob* InspectorHook(URLRequest* request, |
| + const std::string& scheme) { |
| + LOG(INFO) << "Intercepted: " << request->url() << ", scheme: " << scheme; |
| + |
| + // Expect that the parameters are the same as new_account.html gave us. |
| + EXPECT_STREQ("cros://inspector/?param1=value1+param2", |
| + request->url().spec().c_str()); |
| + inspector_called = true; |
| + ChromeThread::PostTask(ChromeThread::UI, FROM_HERE, |
|
Nikita (slow)
2010/05/27 17:40:54
Is this the only solution to quit the test?
I'd p
glotov
2010/05/27 17:55:05
Not sure what you mean.
ui_test_utils::RunMessageL
|
| + NewRunnableFunction(QuitUIMessageLoop)); |
| + |
| + // Do not navigate to the given URL. Navigate to about:blank instead. |
| + return new URLRequestAboutJob(request); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(AccountScreenTest, TestSchemeInspector) { |
| + ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( |
| + chrome::kCrosScheme); |
| + URLRequestFilter::GetInstance()->AddHostnameHandler(chrome::kCrosScheme, |
| + "inspector", |
| + &InspectorHook); |
| + EXPECT_FALSE(inspector_called); |
| + ui_test_utils::RunMessageLoop(); |
| + EXPECT_TRUE(inspector_called); |
| +} |
| + |
| } // namespace chromeos |