| Index: ios/chrome/browser/ui/first_run/welcome_to_chrome_view_controller_unittest.mm
|
| diff --git a/ios/chrome/browser/ui/first_run/welcome_to_chrome_view_controller_unittest.mm b/ios/chrome/browser/ui/first_run/welcome_to_chrome_view_controller_unittest.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..46d66aa3219acacf5866d713de82b9eb2c9d09a1
|
| --- /dev/null
|
| +++ b/ios/chrome/browser/ui/first_run/welcome_to_chrome_view_controller_unittest.mm
|
| @@ -0,0 +1,79 @@
|
| +// Copyright 2014 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 <UIKit/UIKit.h>
|
| +
|
| +#include <memory>
|
| +
|
| +#include "base/mac/scoped_nsobject.h"
|
| +#include "components/metrics/metrics_pref_names.h"
|
| +#include "components/prefs/pref_registry_simple.h"
|
| +#include "components/prefs/testing_pref_service.h"
|
| +#include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
|
| +#include "ios/chrome/browser/tabs/tab_model.h"
|
| +#include "ios/chrome/browser/ui/fancy_ui/primary_action_button.h"
|
| +#import "ios/chrome/browser/ui/first_run/welcome_to_chrome_view.h"
|
| +#import "ios/chrome/browser/ui/first_run/welcome_to_chrome_view_controller.h"
|
| +#include "ios/chrome/browser/ui/ui_util.h"
|
| +#include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h"
|
| +#include "ios/web/public/test/test_web_thread_bundle.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "testing/gtest_mac.h"
|
| +#include "testing/platform_test.h"
|
| +#include "third_party/ocmock/OCMock/OCMock.h"
|
| +#include "third_party/ocmock/gtest_support.h"
|
| +
|
| +@interface WelcomeToChromeView (ExposedForTesting)
|
| +@property(nonatomic, retain, readonly) UIButton* checkBoxButton;
|
| +- (void)checkBoxButtonWasTapped;
|
| +@end
|
| +
|
| +namespace {
|
| +
|
| +class WelcomeToChromeViewControllerTest : public PlatformTest {
|
| + protected:
|
| + void SetUp() override {
|
| + PlatformTest::SetUp();
|
| + TestChromeBrowserState::Builder test_cbs_builder;
|
| + chrome_browser_state_ = test_cbs_builder.Build();
|
| + id tabModel = [OCMockObject mockForClass:[TabModel class]];
|
| + controller_.reset([[WelcomeToChromeViewController alloc]
|
| + initWithBrowserState:chrome_browser_state_.get()
|
| + tabModel:tabModel]);
|
| + [controller_ loadView];
|
| + }
|
| +
|
| + void TearDown() override {
|
| + controller_.reset();
|
| + PlatformTest::TearDown();
|
| + }
|
| +
|
| + web::TestWebThreadBundle thread_bundle_;
|
| + IOSChromeScopedTestingLocalState local_state_;
|
| + std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
|
| + base::scoped_nsobject<WelcomeToChromeViewController> controller_;
|
| +};
|
| +
|
| +TEST_F(WelcomeToChromeViewControllerTest, TestDefaultStatsCheckBoxValue) {
|
| + BOOL checkbox_value =
|
| + [WelcomeToChromeViewController defaultStatsCheckboxValue];
|
| + ASSERT_TRUE(checkbox_value);
|
| +}
|
| +
|
| +TEST_F(WelcomeToChromeViewControllerTest, TestConstructorDestructor) {
|
| + EXPECT_TRUE(controller_.get());
|
| + EXPECT_TRUE([controller_ view]);
|
| +}
|
| +
|
| +TEST_F(WelcomeToChromeViewControllerTest, TestToggleCheckbox) {
|
| + WelcomeToChromeView* welcome_view =
|
| + static_cast<WelcomeToChromeView*>([controller_ view]);
|
| + EXPECT_TRUE(welcome_view.checkBoxButton.selected);
|
| + [welcome_view checkBoxButtonWasTapped];
|
| + EXPECT_FALSE(welcome_view.checkBoxButton.selected);
|
| + [welcome_view checkBoxButtonWasTapped];
|
| + EXPECT_TRUE(welcome_view.checkBoxButton.selected);
|
| +}
|
| +
|
| +} // namespace
|
|
|