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

Side by Side Diff: ios/web/webui/url_fetcher_block_adapter_unittest.mm

Issue 2846073002: Use ScopedTaskEnvironment instead of MessageLoopForUI in ios tests. (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
« no previous file with comments | « ios/chrome/browser/ui/settings/voicesearch_collection_view_controller_unittest.mm ('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 #import "ios/web/webui/url_fetcher_block_adapter.h" 5 #import "ios/web/webui/url_fetcher_block_adapter.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #include "base/test/scoped_task_environment.h"
13 #include "net/url_request/test_url_fetcher_factory.h" 14 #include "net/url_request/test_url_fetcher_factory.h"
14 #include "net/url_request/url_request_status.h" 15 #include "net/url_request/url_request_status.h"
15 #include "net/url_request/url_request_test_util.h" 16 #include "net/url_request/url_request_test_util.h"
16 #import "testing/gtest_mac.h" 17 #import "testing/gtest_mac.h"
17 #include "testing/platform_test.h" 18 #include "testing/platform_test.h"
18 #include "url/gurl.h" 19 #include "url/gurl.h"
19 20
20 namespace web { 21 namespace web {
21 22
22 // Test fixture for URLFetcherBlockAdapter. 23 // Test fixture for URLFetcherBlockAdapter.
23 class URLFetcherBlockAdapterTest : public PlatformTest { 24 class URLFetcherBlockAdapterTest : public PlatformTest {
24 protected: 25 protected:
26 URLFetcherBlockAdapterTest()
27 : scoped_task_environment_(
28 base::test::ScopedTaskEnvironment::MainThreadType::UI) {}
29
25 // Required for base::MessageLoop::current(). 30 // Required for base::MessageLoop::current().
26 base::MessageLoopForUI loop_; 31 base::test::ScopedTaskEnvironment scoped_task_environment_;
27 }; 32 };
28 33
29 // Tests that URLFetcherBlockAdapter calls its completion handler with the 34 // Tests that URLFetcherBlockAdapter calls its completion handler with the
30 // appropriate data for a text resource. 35 // appropriate data for a text resource.
31 TEST_F(URLFetcherBlockAdapterTest, FetchTextResource) { 36 TEST_F(URLFetcherBlockAdapterTest, FetchTextResource) {
32 GURL test_url("http://test"); 37 GURL test_url("http://test");
33 std::string response("<html><body>Hello World!</body></html>"); 38 std::string response("<html><body>Hello World!</body></html>");
34 NSData* expected_data = 39 NSData* expected_data =
35 [NSData dataWithBytes:response.c_str() length:response.size()]; 40 [NSData dataWithBytes:response.c_str() length:response.size()];
36 web::URLFetcherBlockAdapterCompletion completion_handler = 41 web::URLFetcherBlockAdapterCompletion completion_handler =
(...skipping 25 matching lines...) Expand all
62 std::string response; 67 std::string response;
63 EXPECT_TRUE(ReadFileToString(favicon_path, &response)); 68 EXPECT_TRUE(ReadFileToString(favicon_path, &response));
64 net::FakeURLFetcher fake_fetcher(test_url, &web_ui_fetcher, response, 69 net::FakeURLFetcher fake_fetcher(test_url, &web_ui_fetcher, response,
65 net::HTTP_OK, 70 net::HTTP_OK,
66 net::URLRequestStatus::SUCCESS); 71 net::URLRequestStatus::SUCCESS);
67 fake_fetcher.Start(); 72 fake_fetcher.Start();
68 base::RunLoop().RunUntilIdle(); 73 base::RunLoop().RunUntilIdle();
69 } 74 }
70 75
71 } // namespace web 76 } // namespace web
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/settings/voicesearch_collection_view_controller_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698