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
|
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/nearby_sharing/common/nearby_share_resource_getter.h"
#include <string>
#include "base/test/scoped_feature_list.h"
#include "build/branding_buildflags.h"
#include "chrome/browser/nearby_sharing/common/nearby_share_features.h"
#include "chrome/grit/generated_resources.h"
#include "testing/gtest/include/gtest/gtest.h"
class NearbyShareResourceGetterTest : public ::testing::Test {
public:
NearbyShareResourceGetterTest() = default;
~NearbyShareResourceGetterTest() override = default;
};
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
TEST_F(NearbyShareResourceGetterTest,
GetStringWithFeatureNameWorksWithPlaceholderOfficialBuild) {
base::test::ScopedFeatureList feature_list{features::kIsNameEnabled};
// Just enforce non empty string for official branded builds..
EXPECT_NE(NearbyShareResourceGetter::GetInstance()->GetStringWithFeatureName(
IDS_NEARBY_SHARE_FEATURE_NAME_PH),
u"");
}
#else // !BUILDFLAG(GOOGLE_CHROME_BRANDING)
TEST_F(NearbyShareResourceGetterTest,
GetStringWithFeatureNameWorksWithPlaceholderUnofficialBuild) {
base::test::ScopedFeatureList feature_list{features::kIsNameEnabled};
// Expect the feature name to be inserted into the string.
EXPECT_EQ(NearbyShareResourceGetter::GetInstance()->GetStringWithFeatureName(
IDS_NEARBY_SHARE_FEATURE_NAME_PH),
u"Nearby Share");
}
#endif // !BUILDFLAG(GOOGLE_CHROME_BRANDING)
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
TEST_F(NearbyShareResourceGetterTest, GetFeatureNameOfficialBuild) {
base::test::ScopedFeatureList feature_list{features::kIsNameEnabled};
// Just enforce non empty string for official branded builds..
EXPECT_NE(NearbyShareResourceGetter::GetInstance()->GetFeatureName(), u"");
}
#else // !BUILDFLAG(GOOGLE_CHROME_BRANDING)
TEST_F(NearbyShareResourceGetterTest, GetFeatureNameWorksUnofficialBuild) {
base::test::ScopedFeatureList feature_list{features::kIsNameEnabled};
// Expect the feature name to be inserted into the string.
EXPECT_EQ(NearbyShareResourceGetter::GetInstance()->GetFeatureName(),
u"Nearby Share");
}
#endif // !BUILDFLAG(GOOGLE_CHROME_BRANDING)
|