blob: c815f66123144aef5e4947919192151567140012 [file] [log] [blame]
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/metrics/machine_id_provider.h"
#include "base/system/sys_info.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace metrics {
TEST(MachineIdProviderNonWinTest, GetId) {
const bool has_machine_name = !base::SysInfo::HardwareModelName().empty();
#if defined(OS_ANDROID) || defined(OS_APPLE)
// Should only return a machine ID if the hardware model name is available.
if (has_machine_name) {
const std::string id1 = MachineIdProvider::GetMachineId();
EXPECT_NE(std::string(), id1);
const std::string id2 = MachineIdProvider::GetMachineId();
EXPECT_EQ(id1, id2);
} else {
} // namespace metrics