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

Side by Side Diff: ios/chrome/browser/web_resource/web_resource_util_unittest.cc

Issue 2357913003: Remove calls to MessageLoop::Run/RunUntilIdle from ios/. (Closed)
Patch Set: add missing include Created 4 years, 2 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 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 "ios/chrome/browser/web_resource/web_resource_util.h" 5 #include "ios/chrome/browser/web_resource/web_resource_util.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h"
13 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #include "ios/web/public/web_thread.h" 16 #include "ios/web/public/web_thread.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 namespace web_resource { 19 namespace web_resource {
19 20
20 class WebResourceUtilTest : public testing::Test { 21 class WebResourceUtilTest : public testing::Test {
21 protected: 22 protected:
22 WebResourceUtilTest() : error_called_(false), success_called_(false) {} 23 WebResourceUtilTest() : error_called_(false), success_called_(false) {}
(...skipping 21 matching lines...) Expand all
44 error_ = error; 45 error_ = error;
45 } 46 }
46 47
47 void FlushBackgroundTasks() { 48 void FlushBackgroundTasks() {
48 // The function is not synchronous, callbacks are not called before flushing 49 // The function is not synchronous, callbacks are not called before flushing
49 // the tasks. 50 // the tasks.
50 EXPECT_FALSE(success_called_); 51 EXPECT_FALSE(success_called_);
51 EXPECT_FALSE(error_called_); 52 EXPECT_FALSE(error_called_);
52 53
53 web::WebThread::GetBlockingPool()->FlushForTesting(); 54 web::WebThread::GetBlockingPool()->FlushForTesting();
54 loop_.RunUntilIdle(); 55 base::RunLoop().RunUntilIdle();
55 } 56 }
56 57
57 base::MessageLoop loop_; 58 base::MessageLoop loop_;
58 std::string error_; 59 std::string error_;
59 std::unique_ptr<base::Value> value_; 60 std::unique_ptr<base::Value> value_;
60 bool error_called_; 61 bool error_called_;
61 bool success_called_; 62 bool success_called_;
62 }; 63 };
63 64
64 TEST_F(WebResourceUtilTest, Success) { 65 TEST_F(WebResourceUtilTest, Success) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 119
119 FlushBackgroundTasks(); 120 FlushBackgroundTasks();
120 121
121 // The error callback is called. 122 // The error callback is called.
122 EXPECT_TRUE(error_called_); 123 EXPECT_TRUE(error_called_);
123 EXPECT_FALSE(success_called_); 124 EXPECT_FALSE(success_called_);
124 EXPECT_FALSE(error_.empty()); 125 EXPECT_FALSE(error_.empty());
125 } 126 }
126 127
127 } // namespace web_resource 128 } // namespace web_resource
OLDNEW
« no previous file with comments | « ios/chrome/app/application_delegate/memory_warning_helper_unittest.mm ('k') | ios/web/net/request_tracker_impl_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698