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

Side by Side Diff: ios/chrome/browser/ui/settings/time_range_selector_collection_view_controller_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 | « no previous file | ios/chrome/browser/ui/settings/translate_collection_view_controller_unittest.mm » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/chrome/browser/ui/settings/time_range_selector_collection_view_cont roller.h" 5 #import "ios/chrome/browser/ui/settings/time_range_selector_collection_view_cont roller.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/test/scoped_task_environment.h"
9 #include "components/browsing_data/core/pref_names.h" 9 #include "components/browsing_data/core/pref_names.h"
10 #include "components/prefs/pref_registry_simple.h" 10 #include "components/prefs/pref_registry_simple.h"
11 #include "components/prefs/pref_service.h" 11 #include "components/prefs/pref_service.h"
12 #include "components/sync_preferences/pref_service_mock_factory.h" 12 #include "components/sync_preferences/pref_service_mock_factory.h"
13 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h " 13 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h "
14 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h " 14 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h "
15 #include "ios/chrome/grit/ios_strings.h" 15 #include "ios/chrome/grit/ios_strings.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/ocmock/OCMock/OCMock.h" 17 #include "third_party/ocmock/OCMock/OCMock.h"
18 #import "third_party/ocmock/gtest_support.h" 18 #import "third_party/ocmock/gtest_support.h"
19 19
20 #if !defined(__has_feature) || !__has_feature(objc_arc) 20 #if !defined(__has_feature) || !__has_feature(objc_arc)
21 #error "This file requires ARC support." 21 #error "This file requires ARC support."
22 #endif 22 #endif
23 23
24 @interface TimeRangeSelectorCollectionViewController (ExposedForTesting) 24 @interface TimeRangeSelectorCollectionViewController (ExposedForTesting)
25 - (void)updatePrefValue:(int)prefValue; 25 - (void)updatePrefValue:(int)prefValue;
26 @end 26 @end
27 27
28 namespace { 28 namespace {
29 29
30 const NSInteger kNumberOfItems = 5; 30 const NSInteger kNumberOfItems = 5;
31 31
32 class TimeRangeSelectorCollectionViewControllerTest 32 class TimeRangeSelectorCollectionViewControllerTest
33 : public CollectionViewControllerTest { 33 : public CollectionViewControllerTest {
34 protected: 34 protected:
35 TimeRangeSelectorCollectionViewControllerTest()
36 : scoped_task_environment_(
37 base::test::ScopedTaskEnvironment::MainThreadType::UI) {}
38
35 void SetUp() override { 39 void SetUp() override {
36 CollectionViewControllerTest::SetUp(); 40 CollectionViewControllerTest::SetUp();
37 pref_service_ = CreateLocalState(); 41 pref_service_ = CreateLocalState();
38 delegate_ = [OCMockObject 42 delegate_ = [OCMockObject
39 mockForProtocol:@protocol( 43 mockForProtocol:@protocol(
40 TimeRangeSelectorCollectionViewControllerDelegate)]; 44 TimeRangeSelectorCollectionViewControllerDelegate)];
41 CreateController(); 45 CreateController();
42 } 46 }
43 47
44 CollectionViewController* InstantiateController() override { 48 CollectionViewController* InstantiateController() override {
(...skipping 12 matching lines...) Expand all
57 return factory.Create(registry.get()); 61 return factory.Create(registry.get());
58 } 62 }
59 63
60 // Verifies that the cell at |item| in |section| has the given |accessory| 64 // Verifies that the cell at |item| in |section| has the given |accessory|
61 // type. 65 // type.
62 void CheckTextItemAccessoryType(int accessory_type, int section, int item) { 66 void CheckTextItemAccessoryType(int accessory_type, int section, int item) {
63 CollectionViewTextItem* cell = GetCollectionViewItem(section, item); 67 CollectionViewTextItem* cell = GetCollectionViewItem(section, item);
64 EXPECT_EQ(accessory_type, cell.accessoryType); 68 EXPECT_EQ(accessory_type, cell.accessoryType);
65 } 69 }
66 70
67 base::MessageLoopForUI message_loop_; 71 base::test::ScopedTaskEnvironment scoped_task_environment_;
68 std::unique_ptr<PrefService> pref_service_; 72 std::unique_ptr<PrefService> pref_service_;
69 id delegate_; 73 id delegate_;
70 TimeRangeSelectorCollectionViewController* time_range_selector_controller_; 74 TimeRangeSelectorCollectionViewController* time_range_selector_controller_;
71 }; 75 };
72 76
73 TEST_F(TimeRangeSelectorCollectionViewControllerTest, TestModel) { 77 TEST_F(TimeRangeSelectorCollectionViewControllerTest, TestModel) {
74 CheckController(); 78 CheckController();
75 EXPECT_EQ(1, NumberOfSections()); 79 EXPECT_EQ(1, NumberOfSections());
76 80
77 // No section header + 5 rows 81 // No section header + 5 rows
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 [time_range_selector_controller_ collectionView:collectionView 131 [time_range_selector_controller_ collectionView:collectionView
128 didSelectItemAtIndexPath:indexPath]; 132 didSelectItemAtIndexPath:indexPath];
129 EXPECT_EQ( 133 EXPECT_EQ(
130 pref_service_->GetInteger(browsing_data::prefs::kDeleteTimePeriod), 134 pref_service_->GetInteger(browsing_data::prefs::kDeleteTimePeriod),
131 checkedItem); 135 checkedItem);
132 EXPECT_OCMOCK_VERIFY(delegate_); 136 EXPECT_OCMOCK_VERIFY(delegate_);
133 } 137 }
134 } 138 }
135 139
136 } // namespace 140 } // namespace
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/ui/settings/translate_collection_view_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698