| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/base_switches.h" | 5 #include "base/base_switches.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/threading/thread_restrictions.h" | 7 #include "base/threading/thread_restrictions.h" |
| 8 #include "chrome/browser/extensions/api/page_capture/page_capture_api.h" | 8 #include "chrome/browser/extensions/api/page_capture/page_capture_api.h" |
| 9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
| 10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| 11 #include "chromeos/login/scoped_test_public_session_login_state.h" |
| 11 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 12 #include "content/public/test/test_utils.h" | 13 #include "content/public/test/test_utils.h" |
| 13 #include "extensions/browser/extension_dialog_auto_confirm.h" | 14 #include "extensions/browser/extension_dialog_auto_confirm.h" |
| 14 #include "net/dns/mock_host_resolver.h" | 15 #include "net/dns/mock_host_resolver.h" |
| 15 | 16 |
| 16 #if defined(OS_CHROMEOS) | 17 #if defined(OS_CHROMEOS) |
| 17 #include "chromeos/login/login_state.h" | 18 #include "chromeos/login/login_state.h" |
| 18 #endif // defined(OS_CHROMEOS) | 19 #endif // defined(OS_CHROMEOS) |
| 19 | 20 |
| 20 using extensions::PageCaptureSaveAsMHTMLFunction; | 21 using extensions::PageCaptureSaveAsMHTMLFunction; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // the contents. | 64 // the contents. |
| 64 base::ThreadRestrictions::ScopedAllowIO allow_io; | 65 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 65 ASSERT_FALSE(base::PathExists(delegate.temp_file_)); | 66 ASSERT_FALSE(base::PathExists(delegate.temp_file_)); |
| 66 } | 67 } |
| 67 | 68 |
| 68 #if defined(OS_CHROMEOS) | 69 #if defined(OS_CHROMEOS) |
| 69 IN_PROC_BROWSER_TEST_F(ExtensionPageCaptureApiTest, | 70 IN_PROC_BROWSER_TEST_F(ExtensionPageCaptureApiTest, |
| 70 PublicSessionRequestAllowed) { | 71 PublicSessionRequestAllowed) { |
| 71 ASSERT_TRUE(StartEmbeddedTestServer()); | 72 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 72 PageCaptureSaveAsMHTMLDelegate delegate; | 73 PageCaptureSaveAsMHTMLDelegate delegate; |
| 73 // Set Public Session state. | 74 chromeos::ScopedTestPublicSessionLoginState login_state; |
| 74 chromeos::LoginState::Get()->SetLoggedInState( | |
| 75 chromeos::LoginState::LOGGED_IN_ACTIVE, | |
| 76 chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT); | |
| 77 // Resolve Permission dialog with Allow. | 75 // Resolve Permission dialog with Allow. |
| 78 ScopedTestDialogAutoConfirm auto_confirm(ScopedTestDialogAutoConfirm::ACCEPT); | 76 ScopedTestDialogAutoConfirm auto_confirm(ScopedTestDialogAutoConfirm::ACCEPT); |
| 79 ASSERT_TRUE(RunExtensionTest("page_capture")) << message_; | 77 ASSERT_TRUE(RunExtensionTest("page_capture")) << message_; |
| 80 ASSERT_FALSE(delegate.temp_file_.empty()); | 78 ASSERT_FALSE(delegate.temp_file_.empty()); |
| 81 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); | 79 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); |
| 82 content::RunAllPendingInMessageLoop(content::BrowserThread::IO); | 80 content::RunAllPendingInMessageLoop(content::BrowserThread::IO); |
| 83 base::ThreadRestrictions::ScopedAllowIO allow_io; | 81 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 84 ASSERT_FALSE(base::PathExists(delegate.temp_file_)); | 82 ASSERT_FALSE(base::PathExists(delegate.temp_file_)); |
| 85 } | 83 } |
| 86 | 84 |
| 87 IN_PROC_BROWSER_TEST_F(ExtensionPageCaptureApiTest, | 85 IN_PROC_BROWSER_TEST_F(ExtensionPageCaptureApiTest, |
| 88 PublicSessionRequestDenied) { | 86 PublicSessionRequestDenied) { |
| 89 ASSERT_TRUE(StartEmbeddedTestServer()); | 87 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 90 // Set Public Session state. | 88 chromeos::ScopedTestPublicSessionLoginState login_state; |
| 91 chromeos::LoginState::Get()->SetLoggedInState( | |
| 92 chromeos::LoginState::LOGGED_IN_ACTIVE, | |
| 93 chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT); | |
| 94 // Resolve Permission dialog with Deny. | 89 // Resolve Permission dialog with Deny. |
| 95 ScopedTestDialogAutoConfirm auto_confirm(ScopedTestDialogAutoConfirm::CANCEL); | 90 ScopedTestDialogAutoConfirm auto_confirm(ScopedTestDialogAutoConfirm::CANCEL); |
| 96 ASSERT_TRUE(RunExtensionTestWithArg("page_capture", "REQUEST_DENIED")) | 91 ASSERT_TRUE(RunExtensionTestWithArg("page_capture", "REQUEST_DENIED")) |
| 97 << message_; | 92 << message_; |
| 98 } | 93 } |
| 99 #endif // defined(OS_CHROMEOS) | 94 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |