Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h" | 7 #include "chrome/browser/child_process_security_policy.h" |
| 8 #include "chrome/browser/chromeos/login/account_screen.h" | 8 #include "chrome/browser/chromeos/login/account_screen.h" |
| 9 #include "chrome/browser/chromeos/login/wizard_controller.h" | 9 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 10 #include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h" | |
| 11 #include "chrome/common/url_constants.h" | |
| 10 #include "chrome/test/in_process_browser_test.h" | 12 #include "chrome/test/in_process_browser_test.h" |
| 13 #include "chrome/test/ui_test_utils.h" | |
| 14 #include "net/url_request/url_request_about_job.h" | |
| 15 #include "net/url_request/url_request_filter.h" | |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 18 |
| 14 namespace chromeos { | 19 namespace chromeos { |
| 15 | 20 |
| 16 class AccountScreenTest : public WizardInProcessBrowserTest { | 21 class AccountScreenTest : public WizardInProcessBrowserTest { |
| 17 public: | 22 public: |
| 18 AccountScreenTest(): WizardInProcessBrowserTest("account") { | 23 AccountScreenTest(): WizardInProcessBrowserTest("account") { |
| 19 } | 24 } |
| 20 | 25 |
| 21 protected: | 26 protected: |
| 22 // Overriden from WizardInProcessBrowserTest: | 27 // Overridden from WizardInProcessBrowserTest: |
| 23 virtual void SetUpWizard() { | 28 virtual void SetUpWizard() { |
| 24 HTTPTestServer* server = StartHTTPServer(); | 29 HTTPTestServer* server = StartHTTPServer(); |
| 25 ASSERT_TRUE(server != NULL); | 30 ASSERT_TRUE(server != NULL); |
| 26 GURL new_account_page_url(server->TestServerPage("new_account.html")); | 31 GURL new_account_page_url(server->TestServerPage("files/new_account.html")); |
| 27 AccountScreen::set_new_account_page_url(new_account_page_url); | 32 AccountScreen::set_new_account_page_url(new_account_page_url); |
| 28 AccountScreen::set_check_for_https(false); | 33 AccountScreen::set_check_for_https(false); |
| 29 } | 34 } |
| 30 | 35 |
| 31 private: | 36 private: |
| 32 DISALLOW_COPY_AND_ASSIGN(AccountScreenTest); | 37 DISALLOW_COPY_AND_ASSIGN(AccountScreenTest); |
| 33 }; | 38 }; |
| 34 | 39 |
| 40 // A basic test. It does not care how things evolve after the URL is | |
| 41 // loaded. Thus no message loop is started. Just check that initial | |
| 42 // status is expected. | |
| 35 IN_PROC_BROWSER_TEST_F(AccountScreenTest, TestBasic) { | 43 IN_PROC_BROWSER_TEST_F(AccountScreenTest, TestBasic) { |
| 36 ASSERT_TRUE(controller()); | 44 ASSERT_TRUE(controller()); |
| 37 EXPECT_EQ(controller()->GetAccountScreen(), controller()->current_screen()); | 45 EXPECT_EQ(controller()->GetAccountScreen(), controller()->current_screen()); |
| 38 } | 46 } |
| 39 | 47 |
| 48 static void QuitUIMessageLoop() { | |
| 49 MessageLoopForUI::current()->Quit(); | |
| 50 } | |
| 51 | |
| 52 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
| |
| 53 // InspectorHook() doesn't have context. | |
| 54 | |
| 55 static URLRequestJob* InspectorHook(URLRequest* request, | |
| 56 const std::string& scheme) { | |
| 57 LOG(INFO) << "Intercepted: " << request->url() << ", scheme: " << scheme; | |
| 58 | |
| 59 // Expect that the parameters are the same as new_account.html gave us. | |
| 60 EXPECT_STREQ("cros://inspector/?param1=value1+param2", | |
| 61 request->url().spec().c_str()); | |
| 62 inspector_called = true; | |
| 63 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
| |
| 64 NewRunnableFunction(QuitUIMessageLoop)); | |
| 65 | |
| 66 // Do not navigate to the given URL. Navigate to about:blank instead. | |
| 67 return new URLRequestAboutJob(request); | |
| 68 } | |
| 69 | |
| 70 IN_PROC_BROWSER_TEST_F(AccountScreenTest, TestSchemeInspector) { | |
| 71 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( | |
| 72 chrome::kCrosScheme); | |
| 73 URLRequestFilter::GetInstance()->AddHostnameHandler(chrome::kCrosScheme, | |
| 74 "inspector", | |
| 75 &InspectorHook); | |
| 76 EXPECT_FALSE(inspector_called); | |
| 77 ui_test_utils::RunMessageLoop(); | |
| 78 EXPECT_TRUE(inspector_called); | |
| 79 } | |
| 80 | |
| 40 } // namespace chromeos | 81 } // namespace chromeos |
| OLD | NEW |