Chromium Code Reviews| Index: chrome/browser/prefs/tracked/device_id_unittest.cc |
| diff --git a/chrome/browser/prefs/tracked/device_id_unittest.cc b/chrome/browser/prefs/tracked/device_id_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8b163ea04015613418210d90f1d529e4ea88214f |
| --- /dev/null |
| +++ b/chrome/browser/prefs/tracked/device_id_unittest.cc |
| @@ -0,0 +1,33 @@ |
| +// Copyright 2015 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 "chrome/browser/prefs/tracked/device_id.h" |
| +#include "build/build_config.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +TEST(GetDeterministicMachineSpecificIdTest, IsDeterministic) { |
| + std::string first_machine_id; |
| + std::string second_machine_id; |
| + |
| + const MachineIdStatus kExpectedStatus = |
| +#if defined(OS_WIN) |
| + MachineIdStatus::SUCCESS; |
| +#else |
| + MachineIdStatus::NOT_IMPLEMENTED; |
| +#endif |
| + |
| + ASSERT_EQ(kExpectedStatus, |
| + GetDeterministicMachineSpecificId(&first_machine_id)); |
| + ASSERT_EQ(kExpectedStatus, |
| + GetDeterministicMachineSpecificId(&second_machine_id)); |
| + |
| + // The reason for using |EXPECT_TRUE| with one argument instead of |EXPECT_EQ| |
| + // with two arguments is a compiler bug in gcc that results in a "converting |
| + // 'false' to pointer type" error when the first argument to |EXPECT_EQ| is a |
| + // compile-time const false value. See also this bug report: |
| + // https://code.google.com/p/googletest/issues/detail?id=322 |
| + EXPECT_TRUE((kExpectedStatus == MachineIdStatus::SUCCESS) == |
|
grt (UTC plus 2)
2015/01/30 14:39:08
how about getting rid of the hack?
if (kExpected
gab
2015/01/30 17:37:16
I considered that syntax, but found it just as wei
grt (UTC plus 2)
2015/01/30 17:48:17
It seems pretty clear to me, and I don't think it
|
| + !first_machine_id.empty()); |
| + EXPECT_EQ(first_machine_id, second_machine_id); |
| +} |