Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: chrome/browser/extensions/api/page_capture/page_capture_apitest.cc

Issue 2856053004: [Refactor] Use ScopedTestPublicSessionLoginState in code (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/login_state.h" 11 #include "chromeos/login/scoped_test_public_session_login_state.h"
12 #include "content/public/common/content_switches.h" 12 #include "content/public/common/content_switches.h"
13 #include "content/public/test/test_utils.h" 13 #include "content/public/test/test_utils.h"
14 #include "extensions/browser/extension_dialog_auto_confirm.h" 14 #include "extensions/browser/extension_dialog_auto_confirm.h"
15 #include "net/dns/mock_host_resolver.h" 15 #include "net/dns/mock_host_resolver.h"
16 16
17 using extensions::PageCaptureSaveAsMHTMLFunction; 17 using extensions::PageCaptureSaveAsMHTMLFunction;
18 using extensions::ScopedTestDialogAutoConfirm; 18 using extensions::ScopedTestDialogAutoConfirm;
19 19
20 class ExtensionPageCaptureApiTest : public ExtensionApiTest { 20 class ExtensionPageCaptureApiTest : public ExtensionApiTest {
21 public: 21 public:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // the contents. 60 // the contents.
61 base::ThreadRestrictions::ScopedAllowIO allow_io; 61 base::ThreadRestrictions::ScopedAllowIO allow_io;
62 ASSERT_FALSE(base::PathExists(delegate.temp_file_)); 62 ASSERT_FALSE(base::PathExists(delegate.temp_file_));
63 } 63 }
64 64
65 #if defined(OS_CHROMEOS) 65 #if defined(OS_CHROMEOS)
66 IN_PROC_BROWSER_TEST_F(ExtensionPageCaptureApiTest, 66 IN_PROC_BROWSER_TEST_F(ExtensionPageCaptureApiTest,
67 PublicSessionRequestAllowed) { 67 PublicSessionRequestAllowed) {
68 ASSERT_TRUE(StartEmbeddedTestServer()); 68 ASSERT_TRUE(StartEmbeddedTestServer());
69 PageCaptureSaveAsMHTMLDelegate delegate; 69 PageCaptureSaveAsMHTMLDelegate delegate;
70 // Set Public Session state. 70 chromeos::ScopedTestPublicSessionLoginState login_state;
71 chromeos::LoginState::Get()->SetLoggedInState(
72 chromeos::LoginState::LOGGED_IN_ACTIVE,
73 chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT);
74 // Resolve Permission dialog with Allow. 71 // Resolve Permission dialog with Allow.
75 ScopedTestDialogAutoConfirm auto_confirm(ScopedTestDialogAutoConfirm::ACCEPT); 72 ScopedTestDialogAutoConfirm auto_confirm(ScopedTestDialogAutoConfirm::ACCEPT);
76 ASSERT_TRUE(RunExtensionTest("page_capture")) << message_; 73 ASSERT_TRUE(RunExtensionTest("page_capture")) << message_;
77 ASSERT_FALSE(delegate.temp_file_.empty()); 74 ASSERT_FALSE(delegate.temp_file_.empty());
78 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); 75 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE);
79 content::RunAllPendingInMessageLoop(content::BrowserThread::IO); 76 content::RunAllPendingInMessageLoop(content::BrowserThread::IO);
80 base::ThreadRestrictions::ScopedAllowIO allow_io; 77 base::ThreadRestrictions::ScopedAllowIO allow_io;
81 ASSERT_FALSE(base::PathExists(delegate.temp_file_)); 78 ASSERT_FALSE(base::PathExists(delegate.temp_file_));
82 } 79 }
83 80
84 IN_PROC_BROWSER_TEST_F(ExtensionPageCaptureApiTest, 81 IN_PROC_BROWSER_TEST_F(ExtensionPageCaptureApiTest,
85 PublicSessionRequestDenied) { 82 PublicSessionRequestDenied) {
86 ASSERT_TRUE(StartEmbeddedTestServer()); 83 ASSERT_TRUE(StartEmbeddedTestServer());
87 // Set Public Session state. 84 chromeos::ScopedTestPublicSessionLoginState login_state;
88 chromeos::LoginState::Get()->SetLoggedInState(
89 chromeos::LoginState::LOGGED_IN_ACTIVE,
90 chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT);
91 // Resolve Permission dialog with Deny. 85 // Resolve Permission dialog with Deny.
92 ScopedTestDialogAutoConfirm auto_confirm(ScopedTestDialogAutoConfirm::CANCEL); 86 ScopedTestDialogAutoConfirm auto_confirm(ScopedTestDialogAutoConfirm::CANCEL);
93 ASSERT_TRUE(RunExtensionTestWithArg("page_capture", "REQUEST_DENIED")) 87 ASSERT_TRUE(RunExtensionTestWithArg("page_capture", "REQUEST_DENIED"))
94 << message_; 88 << message_;
95 } 89 }
96 #endif // defined(OS_CHROMEOS) 90 #endif // defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698