local_device_info_util_unittest.cc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright (c) 2012 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.
  4. #include "components/sync_device_info/local_device_info_util.h"
  5. #include <utility>
  6. #include "base/system/sys_info.h"
  7. #include "build/build_config.h"
  8. #include "build/chromeos_buildflags.h"
  9. #include "testing/gtest/include/gtest/gtest.h"
  10. #if BUILDFLAG(IS_CHROMEOS_ASH)
  11. #include "base/command_line.h"
  12. #include "base/test/scoped_chromeos_version_info.h"
  13. #endif // BUILDFLAG(IS_CHROMEOS_ASH)
  14. namespace syncer {
  15. namespace {
  16. // Call GetPersonalizableDeviceNameBlocking and make sure its return
  17. // value looks sane.
  18. TEST(GetClientNameTest, GetPersonalizableDeviceNameBlocking) {
  19. const std::string& client_name = GetPersonalizableDeviceNameBlocking();
  20. EXPECT_FALSE(client_name.empty());
  21. }
  22. #if BUILDFLAG(IS_CHROMEOS_ASH)
  23. // Call GetPersonalizableDeviceNameBlocking on ChromeOS where the
  24. // board type is CHROMEBOOK and make sure the return value is "Chromebook".
  25. TEST(GetClientNameTest, GetPersonalizableDeviceNameBlockingChromebook) {
  26. const char* kLsbRelease = "DEVICETYPE=CHROMEBOOK\n";
  27. base::test::ScopedChromeOSVersionInfo version(kLsbRelease, base::Time());
  28. const std::string& client_name = GetPersonalizableDeviceNameBlocking();
  29. EXPECT_EQ("Chromebook", client_name);
  30. }
  31. // Call GetPersonalizableDeviceNameBlocking on ChromeOS where the
  32. // board type is a CHROMEBOX and make sure the return value is "Chromebox".
  33. TEST(GetClientNameTest, GetPersonalizableDeviceNameBlockingChromebox) {
  34. const char* kLsbRelease = "DEVICETYPE=CHROMEBOX\n";
  35. base::test::ScopedChromeOSVersionInfo version(kLsbRelease, base::Time());
  36. const std::string& client_name = GetPersonalizableDeviceNameBlocking();
  37. EXPECT_EQ("Chromebox", client_name);
  38. }
  39. #endif // BUILDFLAG(IS_CHROMEOS_ASH)
  40. } // namespace
  41. } // namespace syncer