Commit 91bcbee1 authored by John Z Wu's avatar John Z Wu Committed by Commit Bot

Update CWVIdentity and add unit test.

Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Id3ceb16cc07aec0ad376494315db77959806570a
Reviewed-on: https://chromium-review.googlesource.com/1091973Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: John Wu <jzw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565688}
parent 9387b40d
......@@ -322,6 +322,7 @@ test("ios_web_view_unittests") {
"internal/cwv_html_element_unittest.mm",
"internal/cwv_preferences_unittest.mm",
"internal/cwv_preview_element_info_unittest.mm",
"internal/signin/cwv_identity_unittest.mm",
"internal/translate/cwv_translation_controller_unittest.mm",
"internal/translate/cwv_translation_language_unittest.mm",
"internal/translate/cwv_translation_policy_unittest.mm",
......
// Copyright 2018 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/web_view/public/cwv_identity.h"
#import <Foundation/Foundation.h>
#include "testing/gtest/include/gtest/gtest.h"
#import "testing/gtest_mac.h"
#include "testing/platform_test.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace ios_web_view {
using CWVIdentityTest = PlatformTest;
// Tests CWVIdentity initialization.
TEST_F(CWVIdentityTest, Initialization) {
NSString* email = @"john.doe@chromium.org";
NSString* full_name = @"John Doe";
NSString* gaia_id = @"123456789";
CWVIdentity* identity = [[CWVIdentity alloc] initWithEmail:email
fullName:full_name
gaiaID:gaia_id];
EXPECT_NSEQ(email, identity.email);
EXPECT_NSEQ(full_name, identity.fullName);
EXPECT_NSEQ(gaia_id, identity.gaiaID);
}
} // namespace ios_web_view
......@@ -12,6 +12,7 @@
NS_ASSUME_NONNULL_BEGIN
CWV_EXPORT
// Represents a user in ChromeWebView.
@interface CWVIdentity : NSObject
- (instancetype)initWithEmail:(NSString*)email
......@@ -20,17 +21,13 @@ CWV_EXPORT
- (instancetype)init NS_UNAVAILABLE;
// Identity/account email address. This can be shown to the user, but is not a
// unique identifier (@see gaiaID).
// The user's email address. e.g. john.doe@chromium.org.
@property(nonatomic, copy, readonly) NSString* email;
// Returns the full name of the identity.
// Could be nil if no full name has been fetched for this account yet.
// The user's full name. e.g. John Doe.
@property(nonatomic, copy, readonly, nullable) NSString* fullName;
// The unique GAIA user identifier for this identity/account.
// Use this as a unique identifier to remember a particular identity.
// Use SSOIdentity's |userID| property. See go/ios-sso-library for more info.
// The unique GAIA (Google Accounts ID Administration) ID for this user.
@property(nonatomic, copy, readonly) NSString* gaiaID;
@end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment