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

Unified Diff: ios/chrome/browser/ui/settings/bandwidth_management_collection_view_controller_unittest.mm

Issue 2589583003: Upstream Chrome on iOS source code [7/11]. (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/settings/bandwidth_management_collection_view_controller_unittest.mm
diff --git a/ios/chrome/browser/ui/settings/bandwidth_management_collection_view_controller_unittest.mm b/ios/chrome/browser/ui/settings/bandwidth_management_collection_view_controller_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..7fe3ec38fab1400980193f43f0d7b9e75eab2fc1
--- /dev/null
+++ b/ios/chrome/browser/ui/settings/bandwidth_management_collection_view_controller_unittest.mm
@@ -0,0 +1,92 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/browser/ui/settings/bandwidth_management_collection_view_controller.h"
+
+#include <memory>
+
+#include "base/compiler_specific.h"
+#include "base/run_loop.h"
+#include "base/test/test_simple_task_runner.h"
+#include "components/pref_registry/pref_registry_syncable.h"
+#include "components/prefs/testing_pref_service.h"
+#include "components/sync_preferences/pref_service_mock_factory.h"
+#include "components/sync_preferences/pref_service_syncable.h"
+#include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
+#include "ios/chrome/browser/pref_names.h"
+#include "ios/chrome/browser/prefs/browser_prefs.h"
+#import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h"
+#import "ios/chrome/browser/ui/settings/dataplan_usage_collection_view_controller.h"
+#include "ios/chrome/grit/ios_strings.h"
+#include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h"
+#include "ios/chrome/test/testing_application_context.h"
+#include "ios/web/public/test/test_web_thread.h"
+#include "net/log/test_net_log.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace {
+
+class BandwidthManagementCollectionViewControllerTest
+ : public CollectionViewControllerTest {
+ public:
+ BandwidthManagementCollectionViewControllerTest()
+ : loop_(base::MessageLoop::TYPE_IO),
+ ui_thread_(web::WebThread::UI, &loop_),
+ io_thread_(web::WebThread::IO, &loop_) {}
+
+ protected:
+ void SetUp() override {
+ CollectionViewControllerTest::SetUp();
+
+ sync_preferences::PrefServiceMockFactory factory;
+ scoped_refptr<user_prefs::PrefRegistrySyncable> registry(
+ new user_prefs::PrefRegistrySyncable);
+ std::unique_ptr<sync_preferences::PrefServiceSyncable> prefs(
+ factory.CreateSyncable(registry.get()));
+ RegisterBrowserStatePrefs(registry.get());
+ TestChromeBrowserState::Builder test_cbs_builder;
+ test_cbs_builder.SetPrefService(std::move(prefs));
+ chrome_browser_state_ = test_cbs_builder.Build();
+
+ CreateController();
+ }
+
+ void TearDown() override {
+ base::RunLoop().RunUntilIdle();
+ CollectionViewControllerTest::TearDown();
+ }
+
+ CollectionViewController* NewController() override NS_RETURNS_RETAINED {
+ return [[BandwidthManagementCollectionViewController alloc]
+ initWithBrowserState:chrome_browser_state_.get()];
+ }
+
+ base::MessageLoop loop_;
+ web::TestWebThread ui_thread_;
+ web::TestWebThread io_thread_;
+ net::TestNetLog net_log_;
+ IOSChromeScopedTestingLocalState local_state_;
+
+ std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
+};
+
+TEST_F(BandwidthManagementCollectionViewControllerTest, TestModel) {
+ CheckController();
+ EXPECT_EQ(2, NumberOfSections());
+
+ const NSInteger action_section = 0;
+ EXPECT_EQ(1, NumberOfItemsInSection(action_section));
+ // Preload webpages item.
+ NSString* expected_title =
+ l10n_util::GetNSString(IDS_IOS_OPTIONS_PRELOAD_WEBPAGES);
+ NSString* expected_subtitle = [DataplanUsageCollectionViewController
+ currentLabelForPreference:chrome_browser_state_->GetPrefs()
+ basePref:prefs::kNetworkPredictionEnabled
+ wifiPref:prefs::kNetworkPredictionWifiOnly];
+ CheckTextCellTitleAndSubtitle(expected_title, expected_subtitle,
+ action_section, 0);
+}
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698