chromium/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics_unittest.cc

// Copyright 2015 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/metrics/chrome_browser_main_extra_parts_metrics.h"

#include <memory>

#include "base/test/metrics/histogram_tester.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/flags_ui/pref_service_flags_storage.h"
#include "components/prefs/testing_pref_service.h"
#include "components/variations/variations_switches.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/display/screen.h"
#include "ui/display/test/test_screen.h"
#include "ui/gfx/geometry/size.h"

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/dbus/u2f/u2f_client.h"  // nogncheck
#endif

namespace {

const char kSupportsHDRHistogramName[] =;
constexpr char kEnableBenchmarkingPrefId[] =;
constexpr char kFlagMultiValue[] =;

// This is a fake that causes HandleEnableBenchmarkingCountdownAsync() to do
// nothing. A full implementation of HandleEnableBenchmarkingCountdownAsync
// would require significant fakes which we do not want to implement in this
// test.
class ChromeBrowserMainExtraPartsMetricsFake
    : public ChromeBrowserMainExtraPartsMetrics {};

}  // namespace

class ChromeBrowserMainExtraPartsMetricsTest : public testing::Test {};

ChromeBrowserMainExtraPartsMetricsTest::
    ChromeBrowserMainExtraPartsMetricsTest() {}

ChromeBrowserMainExtraPartsMetricsTest::
    ~ChromeBrowserMainExtraPartsMetricsTest() {}

// Verify a Hardware.Display.SupportsHDR value is recorded during
// PostBrowserStart.
TEST_F(ChromeBrowserMainExtraPartsMetricsTest,
       VerifySupportsHDRIsRecordedAfterPostBrowserStart) {}

// Tests that if the countdown is called when there are no prefs, that the pref
// is created.
TEST_F(ChromeBrowserMainExtraPartsMetricsTest,
       EnableBenchmarkingCountdownNoFlag) {}

TEST_F(ChromeBrowserMainExtraPartsMetricsTest,
       EnableBenchmarkingCountdownFromNoStorage) {}

// Checks that the countdown takes the pref from 2 to 1.
TEST_F(ChromeBrowserMainExtraPartsMetricsTest,
       EnableBenchmarkingCountdownFromStorage2) {}

// Checks that the countdown takes the pref from 1 to 0 and clears the pref.
TEST_F(ChromeBrowserMainExtraPartsMetricsTest,
       EnableBenchmarkingCountdownFromStorage1) {}

#if BUILDFLAG(IS_ANDROID)
TEST_F(ChromeBrowserMainExtraPartsMetricsTest,
       IsBundleForMixedDeviceAccordingToVersionCode) {
  EXPECT_FALSE(IsBundleForMixedDeviceAccordingToVersionCode("584505130"));
  EXPECT_TRUE(IsBundleForMixedDeviceAccordingToVersionCode("584505131"));
  EXPECT_TRUE(IsBundleForMixedDeviceAccordingToVersionCode("584505132"));
  EXPECT_TRUE(IsBundleForMixedDeviceAccordingToVersionCode("584505133"));
  EXPECT_FALSE(IsBundleForMixedDeviceAccordingToVersionCode("584505134"));
  EXPECT_FALSE(IsBundleForMixedDeviceAccordingToVersionCode("584505135"));
  EXPECT_FALSE(IsBundleForMixedDeviceAccordingToVersionCode("584505136"));
  EXPECT_TRUE(IsBundleForMixedDeviceAccordingToVersionCode("584505137"));
  EXPECT_TRUE(IsBundleForMixedDeviceAccordingToVersionCode("584505138"));
  EXPECT_FALSE(IsBundleForMixedDeviceAccordingToVersionCode("584505139"));

  EXPECT_FALSE(IsBundleForMixedDeviceAccordingToVersionCode("584505121"));
  EXPECT_FALSE(IsBundleForMixedDeviceAccordingToVersionCode("584505122"));
  EXPECT_FALSE(IsBundleForMixedDeviceAccordingToVersionCode("584505123"));
  EXPECT_FALSE(IsBundleForMixedDeviceAccordingToVersionCode("584505101"));
  EXPECT_FALSE(IsBundleForMixedDeviceAccordingToVersionCode("584505141"));

  EXPECT_FALSE(IsBundleForMixedDeviceAccordingToVersionCode(""));
  EXPECT_FALSE(IsBundleForMixedDeviceAccordingToVersionCode("0"));
  EXPECT_FALSE(IsBundleForMixedDeviceAccordingToVersionCode("5845-051-3-1"));
}
#endif  // BUILDFLAG(IS_ANDROID)