Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / google / google_update_settings_unittest.cc
index 1bdc68a..3372044 100644 (file)
@@ -4,9 +4,10 @@
 
 #include "base/basictypes.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 "chrome/browser/google/google_util.h"
+#include "chrome/browser/google/google_brand.h"
 #include "chrome/common/chrome_paths.h"
 #include "chrome/installer/util/google_update_settings.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -51,14 +52,32 @@ TEST_F(GoogleUpdateTest, LastRunTime) {
 TEST_F(GoogleUpdateTest, IsOrganicFirstRunBrandCodes) {
   // Test some brand codes to ensure that future changes to this method won't
   // go unnoticed.
-  EXPECT_FALSE(google_util::IsOrganicFirstRun("CHFO"));
-  EXPECT_FALSE(google_util::IsOrganicFirstRun("CHMA"));
-  EXPECT_TRUE(google_util::IsOrganicFirstRun("EUBA"));
-  EXPECT_TRUE(google_util::IsOrganicFirstRun("GGRA"));
+  EXPECT_FALSE(google_brand::IsOrganicFirstRun("CHFO"));
+  EXPECT_FALSE(google_brand::IsOrganicFirstRun("CHMA"));
+  EXPECT_TRUE(google_brand::IsOrganicFirstRun("EUBA"));
+  EXPECT_TRUE(google_brand::IsOrganicFirstRun("GGRA"));
 
 #if defined(OS_MACOSX)
   // An empty brand string on Mac is used for channels other than stable,
   // which are always organic.
-  EXPECT_TRUE(google_util::IsOrganicFirstRun(""));
+  EXPECT_TRUE(google_brand::IsOrganicFirstRun(""));
 #endif
 }
+
+#if defined(OS_CHROMEOS)
+// Test for http://crbug.com/383003
+TEST_F(GoogleUpdateTest, ConsentFileIsWorldReadable) {
+  // Turn on stats reporting.
+  EXPECT_TRUE(GoogleUpdateSettings::SetCollectStatsConsent(true));
+
+  base::FilePath consent_dir;
+  ASSERT_TRUE(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