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

Side by Side Diff: ios/chrome/browser/ui/authentication/signed_in_accounts_view_controller_unittest.mm

Issue 2586993002: Upstream Chrome on iOS source code [3/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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "ios/chrome/browser/ui/authentication/signed_in_accounts_view_controller .h"
6
7 #include <memory>
8
9 #include "base/strings/sys_string_conversions.h"
10 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
11 #include "ios/chrome/browser/signin/authentication_service_factory.h"
12 #import "ios/chrome/browser/signin/authentication_service_fake.h"
13 #include "ios/chrome/test/block_cleanup_test.h"
14 #include "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service .h"
15 #include "ios/web/public/test/test_web_thread_bundle.h"
16 #import "testing/gtest_mac.h"
17 #include "testing/platform_test.h"
18
19 class SignedInAccountsViewControllerTest : public BlockCleanupTest {
20 public:
21 void SetUp() override {
22 BlockCleanupTest::SetUp();
23
24 TestChromeBrowserState::Builder builder;
25 builder.AddTestingFactory(
26 AuthenticationServiceFactory::GetInstance(),
27 AuthenticationServiceFake::CreateAuthenticationService);
28 browser_state_ = builder.Build();
29 auth_service_ = static_cast<AuthenticationServiceFake*>(
30 AuthenticationServiceFactory::GetInstance()->GetForBrowserState(
31 browser_state_.get()));
32 ios::FakeChromeIdentityService* identity_service =
33 ios::FakeChromeIdentityService::GetInstanceFromChromeProvider();
34 identity_service->AddIdentities(
35 @[ @"identity1", @"identity2", @"identity3" ]);
36 auth_service_->SignIn(
37 [identity_service->GetAllIdentitiesSortedForDisplay() objectAtIndex:0],
38 std::string());
39 }
40
41 protected:
42 web::TestWebThreadBundle thread_bundle_;
43 AuthenticationServiceFake* auth_service_;
44 std::unique_ptr<TestChromeBrowserState> browser_state_;
45 };
46
47 // Tests that the signed in accounts view shouldn't be presented when the
48 // accounts haven't changed.
49 TEST_F(SignedInAccountsViewControllerTest,
50 ShouldBePresentedForBrowserStateNotNecessary) {
51 EXPECT_FALSE([SignedInAccountsViewController
52 shouldBePresentedForBrowserState:browser_state_.get()]);
53 }
54
55 // Tests that the signed in accounts view should be presented when the accounts
56 // have changed.
57 TEST_F(SignedInAccountsViewControllerTest,
58 ShouldBePresentedForBrowserStateNecessary) {
59 auth_service_->SetHaveAccountsChanged(true);
60 EXPECT_TRUE([SignedInAccountsViewController
61 shouldBePresentedForBrowserState:browser_state_.get()]);
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698