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

Side by Side Diff: chrome/test/media_router/media_router_integration_browsertest.cc

Issue 2910263002: [Media Router tests] Add minimal ScopedAllowIO for the tests to pass. (Closed)
Patch Set: crbug Created 3 years, 6 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
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/test/media_router/media_router_integration_browsertest.h" 5 #include "chrome/test/media_router/media_router_integration_browsertest.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/json/json_file_value_serializer.h" 11 #include "base/json/json_file_value_serializer.h"
12 #include "base/json/json_reader.h" 12 #include "base/json/json_reader.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/threading/thread_restrictions.h"
16 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/browser_finder.h" 19 #include "chrome/browser/ui/browser_finder.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "chrome/browser/ui/views/frame/browser_view.h" 21 #include "chrome/browser/ui/views/frame/browser_view.h"
21 #include "chrome/browser/ui/webui/media_router/media_router_dialog_controller_im pl.h" 22 #include "chrome/browser/ui/webui/media_router/media_router_dialog_controller_im pl.h"
22 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
23 #include "chrome/test/base/ui_test_utils.h" 24 #include "chrome/test/base/ui_test_utils.h"
24 #include "content/public/browser/render_frame_host.h" 25 #include "content/public/browser/render_frame_host.h"
25 #include "content/public/test/browser_test_utils.h" 26 #include "content/public/test/browser_test_utils.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 void MediaRouterIntegrationBrowserTest::CheckDialogRemainsOpen( 273 void MediaRouterIntegrationBrowserTest::CheckDialogRemainsOpen(
273 WebContents* web_contents) { 274 WebContents* web_contents) {
274 ASSERT_FALSE(ConditionalWait( 275 ASSERT_FALSE(ConditionalWait(
275 base::TimeDelta::FromSeconds(5), base::TimeDelta::FromSeconds(1), 276 base::TimeDelta::FromSeconds(5), base::TimeDelta::FromSeconds(1),
276 base::Bind(&MediaRouterIntegrationBrowserTest::IsDialogClosed, 277 base::Bind(&MediaRouterIntegrationBrowserTest::IsDialogClosed,
277 base::Unretained(this), web_contents))); 278 base::Unretained(this), web_contents)));
278 } 279 }
279 280
280 void MediaRouterIntegrationBrowserTest::SetTestData( 281 void MediaRouterIntegrationBrowserTest::SetTestData(
281 base::FilePath::StringPieceType test_data_file) { 282 base::FilePath::StringPieceType test_data_file) {
283 // crbug.com/724573
284 base::ThreadRestrictions::ScopedAllowIO allow_io;
mark a. foltz 2017/05/30 23:50:04 I don't see anything in this stack frame that requ
imcheng 2017/05/31 00:30:22 JSONFileValueDeserializer::Deserialize requires it
282 base::FilePath full_path = GetResourceFile(test_data_file); 285 base::FilePath full_path = GetResourceFile(test_data_file);
283 JSONFileValueDeserializer deserializer(full_path); 286 JSONFileValueDeserializer deserializer(full_path);
284 int error_code = 0; 287 int error_code = 0;
285 std::string error_message; 288 std::string error_message;
286 std::unique_ptr<base::Value> value = 289 std::unique_ptr<base::Value> value =
287 deserializer.Deserialize(&error_code, &error_message); 290 deserializer.Deserialize(&error_code, &error_message);
288 CHECK(value.get()) << "Deserialize failed: " << error_message; 291 CHECK(value.get()) << "Deserialize failed: " << error_message;
289 std::string test_data_str; 292 std::string test_data_str;
290 ASSERT_TRUE(base::JSONWriter::Write(*value, &test_data_str)); 293 ASSERT_TRUE(base::JSONWriter::Write(*value, &test_data_str));
291 ExecuteScriptInBackgroundPageNoWait( 294 ExecuteScriptInBackgroundPageNoWait(
(...skipping 13 matching lines...) Expand all
305 test_navigation_observer_->Wait(); 308 test_navigation_observer_->Wait();
306 test_navigation_observer_->StopWatchingNewWebContents(); 309 test_navigation_observer_->StopWatchingNewWebContents();
307 WebContents* dialog_contents = controller->GetMediaRouterDialog(); 310 WebContents* dialog_contents = controller->GetMediaRouterDialog();
308 CHECK(dialog_contents); 311 CHECK(dialog_contents);
309 WaitUntilDialogFullyLoaded(dialog_contents); 312 WaitUntilDialogFullyLoaded(dialog_contents);
310 return dialog_contents; 313 return dialog_contents;
311 } 314 }
312 315
313 base::FilePath MediaRouterIntegrationBrowserTest::GetResourceFile( 316 base::FilePath MediaRouterIntegrationBrowserTest::GetResourceFile(
314 base::FilePath::StringPieceType relative_path) const { 317 base::FilePath::StringPieceType relative_path) const {
318 // crbug.com/724573
319 base::ThreadRestrictions::ScopedAllowIO allow_io;
mark a. foltz 2017/05/30 23:50:03 Can this be scoped to only include PathExists?
imcheng 2017/05/31 00:30:22 Done.
315 base::FilePath base_dir; 320 base::FilePath base_dir;
316 // ASSERT_TRUE can only be used in void returning functions. 321 // ASSERT_TRUE can only be used in void returning functions.
317 // Use CHECK instead in non-void returning functions. 322 // Use CHECK instead in non-void returning functions.
318 CHECK(PathService::Get(base::DIR_MODULE, &base_dir)); 323 CHECK(PathService::Get(base::DIR_MODULE, &base_dir));
319 base::FilePath full_path = 324 base::FilePath full_path =
320 base_dir.Append(kResourcePath).Append(relative_path); 325 base_dir.Append(kResourcePath).Append(relative_path);
321 CHECK(PathExists(full_path)); 326 CHECK(PathExists(full_path));
322 return full_path; 327 return full_path;
323 } 328 }
324 329
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 MANUAL_Basic) { 664 MANUAL_Basic) {
660 RunBasicTest(); 665 RunBasicTest();
661 } 666 }
662 667
663 IN_PROC_BROWSER_TEST_F(MediaRouterIntegrationIncognitoBrowserTest, 668 IN_PROC_BROWSER_TEST_F(MediaRouterIntegrationIncognitoBrowserTest,
664 MANUAL_ReconnectSession) { 669 MANUAL_ReconnectSession) {
665 RunReconnectSessionTest(); 670 RunReconnectSessionTest();
666 } 671 }
667 672
668 } // namespace media_router 673 } // namespace media_router
OLDNEW
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698