ExtensionSyncService: listen for relevant changes instead of being explicitly called...
[chromium-blink-merge.git] / chrome / browser / android / shortcut_info_unittest.cc
blob2cb835957f136a736f4d327fd1e290982ccfd155
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.
5 #include "chrome/browser/android/shortcut_info.h"
7 #include "base/strings/string16.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "content/public/common/manifest.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "url/gurl.h"
13 class ShortcutInfoTest : public testing::Test {
14 public:
15 ShortcutInfoTest() : info_(GURL()) {}
17 protected:
18 ShortcutInfo info_;
19 content::Manifest manifest_;
21 DISALLOW_COPY_AND_ASSIGN(ShortcutInfoTest);
24 TEST_F(ShortcutInfoTest, NameUpdates) {
25 info_.name = base::ASCIIToUTF16("old");
26 manifest_.name = base::NullableString16(base::ASCIIToUTF16("new"), false);
27 info_.UpdateFromManifest(manifest_);
29 ASSERT_EQ(manifest_.name.string(), info_.name);
32 TEST_F(ShortcutInfoTest, ShortNameUpdates) {
33 info_.short_name = base::ASCIIToUTF16("old");
34 manifest_.short_name =
35 base::NullableString16(base::ASCIIToUTF16("new"), false);
36 info_.UpdateFromManifest(manifest_);
38 ASSERT_EQ(manifest_.short_name.string(), info_.short_name);
41 TEST_F(ShortcutInfoTest, NameFallsBackToShortName) {
42 manifest_.short_name =
43 base::NullableString16(base::ASCIIToUTF16("short_name"), false);
44 info_.UpdateFromManifest(manifest_);
46 ASSERT_EQ(manifest_.short_name.string(), info_.name);
49 TEST_F(ShortcutInfoTest, ShortNameFallsBackToName) {
50 manifest_.name = base::NullableString16(base::ASCIIToUTF16("name"), false);
51 info_.UpdateFromManifest(manifest_);
53 ASSERT_EQ(manifest_.name.string(), info_.short_name);
56 TEST_F(ShortcutInfoTest, UserTitleBecomesShortName) {
57 manifest_.short_name =
58 base::NullableString16(base::ASCIIToUTF16("name"), false);
59 info_.user_title = base::ASCIIToUTF16("title");
60 info_.UpdateFromManifest(manifest_);
62 ASSERT_EQ(manifest_.short_name.string(), info_.user_title);