1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// 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.
#include "chrome/browser/android/shortcut_info.h"
#include "base/macros.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "content/public/common/manifest.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
class ShortcutInfoTest : public testing::Test {
public:
ShortcutInfoTest() : info_(GURL()) {}
protected:
ShortcutInfo info_;
content::Manifest manifest_;
DISALLOW_COPY_AND_ASSIGN(ShortcutInfoTest);
};
TEST_F(ShortcutInfoTest, NameUpdates) {
info_.name = base::ASCIIToUTF16("old");
manifest_.name = base::NullableString16(base::ASCIIToUTF16("new"), false);
info_.UpdateFromManifest(manifest_);
ASSERT_EQ(manifest_.name.string(), info_.name);
}
TEST_F(ShortcutInfoTest, ShortNameUpdates) {
info_.short_name = base::ASCIIToUTF16("old");
manifest_.short_name =
base::NullableString16(base::ASCIIToUTF16("new"), false);
info_.UpdateFromManifest(manifest_);
ASSERT_EQ(manifest_.short_name.string(), info_.short_name);
}
TEST_F(ShortcutInfoTest, NameFallsBackToShortName) {
manifest_.short_name =
base::NullableString16(base::ASCIIToUTF16("short_name"), false);
info_.UpdateFromManifest(manifest_);
ASSERT_EQ(manifest_.short_name.string(), info_.name);
}
TEST_F(ShortcutInfoTest, ShortNameFallsBackToName) {
manifest_.name = base::NullableString16(base::ASCIIToUTF16("name"), false);
info_.UpdateFromManifest(manifest_);
ASSERT_EQ(manifest_.name.string(), info_.short_name);
}
TEST_F(ShortcutInfoTest, UserTitleBecomesShortName) {
manifest_.short_name =
base::NullableString16(base::ASCIIToUTF16("name"), false);
info_.user_title = base::ASCIIToUTF16("title");
info_.UpdateFromManifest(manifest_);
ASSERT_EQ(manifest_.short_name.string(), info_.user_title);
}
|