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

Side by Side Diff: components/suggestions/image_manager_unittest.cc

Issue 2798963003: Use ScopedTaskEnvironment instead of MessageLoop in components unit tests. (Closed)
Patch Set: Created 3 years, 8 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 | « components/prefs/pref_member_unittest.cc ('k') | components/sync/base/weak_handle_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/suggestions/image_manager.h" 5 #include "components/suggestions/image_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/test/scoped_task_environment.h"
13 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
14 #include "components/image_fetcher/core/image_fetcher.h" 15 #include "components/image_fetcher/core/image_fetcher.h"
15 #include "components/image_fetcher/core/image_fetcher_delegate.h" 16 #include "components/image_fetcher/core/image_fetcher_delegate.h"
16 #include "components/leveldb_proto/proto_database.h" 17 #include "components/leveldb_proto/proto_database.h"
17 #include "components/leveldb_proto/testing/fake_db.h" 18 #include "components/leveldb_proto/testing/fake_db.h"
18 #include "components/suggestions/image_encoder.h" 19 #include "components/suggestions/image_encoder.h"
19 #include "components/suggestions/proto/suggestions.pb.h" 20 #include "components/suggestions/proto/suggestions.pb.h"
20 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 #include "ui/gfx/geometry/size.h" 23 #include "ui/gfx/geometry/size.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 133
133 EntryMap db_model_; 134 EntryMap db_model_;
134 // Owned by the ImageManager under test. 135 // Owned by the ImageManager under test.
135 FakeDB<ImageData>* fake_db_; 136 FakeDB<ImageData>* fake_db_;
136 137
137 MockImageFetcher* mock_image_fetcher_; 138 MockImageFetcher* mock_image_fetcher_;
138 139
139 int num_callback_null_called_; 140 int num_callback_null_called_;
140 int num_callback_valid_called_; 141 int num_callback_valid_called_;
141 142
142 base::MessageLoop message_loop_; 143 base::test::ScopedTaskEnvironment scoped_task_environment_;
143 144
144 // Under test. 145 // Under test.
145 std::unique_ptr<ImageManager> image_manager_; 146 std::unique_ptr<ImageManager> image_manager_;
146 }; 147 };
147 148
148 TEST_F(ImageManagerTest, InitializeTest) { 149 TEST_F(ImageManagerTest, InitializeTest) {
149 SuggestionsProfile suggestions_profile; 150 SuggestionsProfile suggestions_profile;
150 ChromeSuggestion* suggestion = suggestions_profile.add_suggestions(); 151 ChromeSuggestion* suggestion = suggestions_profile.add_suggestions();
151 suggestion->set_url(kTestUrl1); 152 suggestion->set_url(kTestUrl1);
152 suggestion->set_thumbnail(kTestImagePath); 153 suggestion->set_thumbnail(kTestImagePath);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 image_manager_->GetImageForURL(GURL(kTestUrl1), 219 image_manager_->GetImageForURL(GURL(kTestUrl1),
219 base::Bind(&ImageManagerTest::OnImageAvailable, 220 base::Bind(&ImageManagerTest::OnImageAvailable,
220 base::Unretained(this), &run_loop)); 221 base::Unretained(this), &run_loop));
221 run_loop.Run(); 222 run_loop.Run();
222 223
223 EXPECT_EQ(0, num_callback_null_called_); 224 EXPECT_EQ(0, num_callback_null_called_);
224 EXPECT_EQ(1, num_callback_valid_called_); 225 EXPECT_EQ(1, num_callback_valid_called_);
225 } 226 }
226 227
227 } // namespace suggestions 228 } // namespace suggestions
OLDNEW
« no previous file with comments | « components/prefs/pref_member_unittest.cc ('k') | components/sync/base/weak_handle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698