#include <string>
#include "chrome/installer/util/google_update_settings.h"
#include "base/compiler_specific.h"
#include "base/files/file_util.h"
#include "base/path_service.h"
#include "base/test/scoped_path_override.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/google/google_brand.h"
#include "chrome/common/chrome_paths.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
#if BUILDFLAG(IS_WIN)
#include "base/test/test_reg_util_win.h"
#endif
class GoogleUpdateTest : public PlatformTest { … };
TEST_F(GoogleUpdateTest, StatsConsent) { … }
#if BUILDFLAG(IS_WIN)
TEST_F(GoogleUpdateTest, LastRunTime) {
EXPECT_TRUE(GoogleUpdateSettings::RemoveLastRunTime());
EXPECT_EQ(-1, GoogleUpdateSettings::GetLastRunTime());
EXPECT_TRUE(GoogleUpdateSettings::SetLastRunTime());
EXPECT_EQ(0, GoogleUpdateSettings::GetLastRunTime());
}
#endif
TEST_F(GoogleUpdateTest, IsOrganic) { … }
TEST_F(GoogleUpdateTest, IsOrganicFirstRunBrandCodes) { … }
TEST_F(GoogleUpdateTest, IsEnterpriseBrandCodes) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(GoogleUpdateTest, ConsentFileIsWorldReadable) {
EXPECT_TRUE(GoogleUpdateSettings::SetCollectStatsConsent(true));
base::FilePath consent_dir;
ASSERT_TRUE(base::PathService::Get(chrome::DIR_USER_DATA, &consent_dir));
ASSERT_TRUE(base::DirectoryExists(consent_dir));
base::FilePath consent_file = consent_dir.Append("Consent To Send Stats");
ASSERT_TRUE(base::PathExists(consent_file));
int permissions;
ASSERT_TRUE(base::GetPosixFilePermissions(consent_file, &permissions));
EXPECT_TRUE(permissions & base::FILE_PERMISSION_READ_BY_OTHERS);
}
#endif