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

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

Issue 2835233002: Fix integration tests in src/chrome and src/extensions so that we can turn on IO thread checks wi... (Closed)
Patch Set: ready for review 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 "chrome/browser/extensions/api/page_capture/page_capture_api.h" 8 #include "chrome/browser/extensions/api/page_capture/page_capture_api.h"
8 #include "chrome/browser/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
10 #include "chromeos/login/login_state.h" 11 #include "chromeos/login/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 using extensions::PageCaptureSaveAsMHTMLFunction; 17 using extensions::PageCaptureSaveAsMHTMLFunction;
(...skipping 30 matching lines...) Expand all
47 ASSERT_TRUE(StartEmbeddedTestServer()); 48 ASSERT_TRUE(StartEmbeddedTestServer());
48 PageCaptureSaveAsMHTMLDelegate delegate; 49 PageCaptureSaveAsMHTMLDelegate delegate;
49 ASSERT_TRUE(RunExtensionTest("page_capture")) << message_; 50 ASSERT_TRUE(RunExtensionTest("page_capture")) << message_;
50 // Make sure the MHTML data gets written to the temporary file. 51 // Make sure the MHTML data gets written to the temporary file.
51 ASSERT_FALSE(delegate.temp_file_.empty()); 52 ASSERT_FALSE(delegate.temp_file_.empty());
52 // Flush the message loops to make sure the delete happens. 53 // Flush the message loops to make sure the delete happens.
53 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); 54 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE);
54 content::RunAllPendingInMessageLoop(content::BrowserThread::IO); 55 content::RunAllPendingInMessageLoop(content::BrowserThread::IO);
55 // Make sure the temporary file is destroyed once the javascript side reads 56 // Make sure the temporary file is destroyed once the javascript side reads
56 // the contents. 57 // the contents.
58 base::ThreadRestrictions::ScopedAllowIO allow_io;
57 ASSERT_FALSE(base::PathExists(delegate.temp_file_)); 59 ASSERT_FALSE(base::PathExists(delegate.temp_file_));
58 } 60 }
59 61
60 #if defined(OS_CHROMEOS) 62 #if defined(OS_CHROMEOS)
61 IN_PROC_BROWSER_TEST_F(ExtensionPageCaptureApiTest, 63 IN_PROC_BROWSER_TEST_F(ExtensionPageCaptureApiTest,
62 PublicSessionRequestAllowed) { 64 PublicSessionRequestAllowed) {
63 host_resolver()->AddRule("www.a.com", "127.0.0.1"); 65 host_resolver()->AddRule("www.a.com", "127.0.0.1");
64 ASSERT_TRUE(StartEmbeddedTestServer()); 66 ASSERT_TRUE(StartEmbeddedTestServer());
65 PageCaptureSaveAsMHTMLDelegate delegate; 67 PageCaptureSaveAsMHTMLDelegate delegate;
66 // Set Public Session state. 68 // Set Public Session state.
67 chromeos::LoginState::Get()->SetLoggedInState( 69 chromeos::LoginState::Get()->SetLoggedInState(
68 chromeos::LoginState::LOGGED_IN_ACTIVE, 70 chromeos::LoginState::LOGGED_IN_ACTIVE,
69 chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT); 71 chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT);
70 // Resolve Permission dialog with Allow. 72 // Resolve Permission dialog with Allow.
71 ScopedTestDialogAutoConfirm auto_confirm(ScopedTestDialogAutoConfirm::ACCEPT); 73 ScopedTestDialogAutoConfirm auto_confirm(ScopedTestDialogAutoConfirm::ACCEPT);
72 ASSERT_TRUE(RunExtensionTest("page_capture")) << message_; 74 ASSERT_TRUE(RunExtensionTest("page_capture")) << message_;
73 ASSERT_FALSE(delegate.temp_file_.empty()); 75 ASSERT_FALSE(delegate.temp_file_.empty());
74 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); 76 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE);
75 content::RunAllPendingInMessageLoop(content::BrowserThread::IO); 77 content::RunAllPendingInMessageLoop(content::BrowserThread::IO);
78 base::ThreadRestrictions::ScopedAllowIO allow_io;
76 ASSERT_FALSE(base::PathExists(delegate.temp_file_)); 79 ASSERT_FALSE(base::PathExists(delegate.temp_file_));
77 } 80 }
78 81
79 IN_PROC_BROWSER_TEST_F(ExtensionPageCaptureApiTest, 82 IN_PROC_BROWSER_TEST_F(ExtensionPageCaptureApiTest,
80 PublicSessionRequestDenied) { 83 PublicSessionRequestDenied) {
81 host_resolver()->AddRule("www.a.com", "127.0.0.1"); 84 host_resolver()->AddRule("www.a.com", "127.0.0.1");
82 ASSERT_TRUE(StartEmbeddedTestServer()); 85 ASSERT_TRUE(StartEmbeddedTestServer());
83 // Set Public Session state. 86 // Set Public Session state.
84 chromeos::LoginState::Get()->SetLoggedInState( 87 chromeos::LoginState::Get()->SetLoggedInState(
85 chromeos::LoginState::LOGGED_IN_ACTIVE, 88 chromeos::LoginState::LOGGED_IN_ACTIVE,
86 chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT); 89 chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT);
87 // Resolve Permission dialog with Deny. 90 // Resolve Permission dialog with Deny.
88 ScopedTestDialogAutoConfirm auto_confirm(ScopedTestDialogAutoConfirm::CANCEL); 91 ScopedTestDialogAutoConfirm auto_confirm(ScopedTestDialogAutoConfirm::CANCEL);
89 ASSERT_TRUE(RunExtensionTestWithArg("page_capture", "REQUEST_DENIED")) 92 ASSERT_TRUE(RunExtensionTestWithArg("page_capture", "REQUEST_DENIED"))
90 << message_; 93 << message_;
91 } 94 }
92 #endif // defined(OS_CHROMEOS) 95 #endif // defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698