2022-09-06 19:14:07 -04:00
|
|
|
// Copyright 2015 The Crashpad Authors
|
2015-03-09 18:47:52 -04:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
#include "client/settings.h"
|
|
|
|
|
2016-01-06 12:22:50 -05:00
|
|
|
#include "build/build_config.h"
|
2015-03-09 18:47:52 -04:00
|
|
|
#include "gtest/gtest.h"
|
2015-04-20 14:21:48 -07:00
|
|
|
#include "test/errors.h"
|
test: Move util/test to its own top-level directory, test.
After 9e79ea1da719, it no longer makes sense for crashpad_util_test_lib
to “hide” in util/util_test.gyp. All of util/test is moved to its own
top-level directory, test, which all other test code is allowed to
depend on. test, too, is allowed to depend on all other non-test code.
In a future change, when crashpad_util_test_lib gains a dependency on
crashpad_client, it won’t look so weird for something in util (even
though it’s in util/test) to depend on something in client, because the
thing that needs to depend on client will live in test, not util.
BUG=crashpad:33
R=scottmg@chromium.org
Review URL: https://codereview.chromium.org/1051533002
2015-03-31 17:44:14 -04:00
|
|
|
#include "test/scoped_temp_dir.h"
|
2015-03-09 18:47:52 -04:00
|
|
|
#include "util/file/file_io.h"
|
|
|
|
|
|
|
|
namespace crashpad {
|
|
|
|
namespace test {
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
class SettingsTest : public testing::Test {
|
|
|
|
public:
|
2018-02-13 14:25:14 -08:00
|
|
|
SettingsTest() = default;
|
2015-03-09 18:47:52 -04:00
|
|
|
|
2021-09-20 12:55:12 -07:00
|
|
|
SettingsTest(const SettingsTest&) = delete;
|
|
|
|
SettingsTest& operator=(const SettingsTest&) = delete;
|
|
|
|
|
2015-03-09 18:47:52 -04:00
|
|
|
base::FilePath settings_path() {
|
2015-04-20 14:21:48 -07:00
|
|
|
return temp_dir_.path().Append(FILE_PATH_LITERAL("settings"));
|
2015-03-09 18:47:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Settings* settings() { return &settings_; }
|
|
|
|
|
|
|
|
void InitializeBadFile() {
|
|
|
|
ScopedFileHandle handle(
|
|
|
|
LoggingOpenFileForWrite(settings_path(),
|
|
|
|
FileWriteMode::kTruncateOrCreate,
|
|
|
|
FilePermissions::kWorldReadable));
|
|
|
|
ASSERT_TRUE(handle.is_valid());
|
|
|
|
|
2017-07-25 13:34:04 -04:00
|
|
|
static constexpr char kBuf[] = "test bad file";
|
2015-03-09 18:47:52 -04:00
|
|
|
ASSERT_TRUE(LoggingWriteFile(handle.get(), kBuf, sizeof(kBuf)));
|
|
|
|
handle.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// testing::Test:
|
|
|
|
void SetUp() override {
|
2018-02-13 14:25:14 -08:00
|
|
|
ASSERT_TRUE(settings()->Initialize(settings_path()));
|
2015-03-09 18:47:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
ScopedTempDir temp_dir_;
|
|
|
|
Settings settings_;
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(SettingsTest, ClientID) {
|
|
|
|
UUID client_id;
|
|
|
|
EXPECT_TRUE(settings()->GetClientID(&client_id));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_NE(client_id, UUID());
|
2015-03-09 18:47:52 -04:00
|
|
|
|
2018-02-13 14:25:14 -08:00
|
|
|
Settings local_settings;
|
|
|
|
EXPECT_TRUE(local_settings.Initialize(settings_path()));
|
2015-03-09 18:47:52 -04:00
|
|
|
UUID actual;
|
|
|
|
EXPECT_TRUE(local_settings.GetClientID(&actual));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(actual, client_id);
|
2015-03-09 18:47:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SettingsTest, UploadsEnabled) {
|
|
|
|
bool enabled = true;
|
|
|
|
// Default value is false.
|
|
|
|
EXPECT_TRUE(settings()->GetUploadsEnabled(&enabled));
|
|
|
|
EXPECT_FALSE(enabled);
|
|
|
|
|
|
|
|
EXPECT_TRUE(settings()->SetUploadsEnabled(true));
|
|
|
|
EXPECT_TRUE(settings()->GetUploadsEnabled(&enabled));
|
|
|
|
EXPECT_TRUE(enabled);
|
|
|
|
|
2018-02-13 14:25:14 -08:00
|
|
|
Settings local_settings;
|
|
|
|
EXPECT_TRUE(local_settings.Initialize(settings_path()));
|
2015-03-09 18:47:52 -04:00
|
|
|
enabled = false;
|
|
|
|
EXPECT_TRUE(local_settings.GetUploadsEnabled(&enabled));
|
|
|
|
EXPECT_TRUE(enabled);
|
|
|
|
|
|
|
|
EXPECT_TRUE(settings()->SetUploadsEnabled(false));
|
|
|
|
EXPECT_TRUE(settings()->GetUploadsEnabled(&enabled));
|
|
|
|
EXPECT_FALSE(enabled);
|
|
|
|
|
|
|
|
enabled = true;
|
|
|
|
EXPECT_TRUE(local_settings.GetUploadsEnabled(&enabled));
|
|
|
|
EXPECT_FALSE(enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SettingsTest, LastUploadAttemptTime) {
|
|
|
|
time_t actual = -1;
|
|
|
|
EXPECT_TRUE(settings()->GetLastUploadAttemptTime(&actual));
|
|
|
|
// Default value is 0.
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(actual, 0);
|
2015-03-09 18:47:52 -04:00
|
|
|
|
|
|
|
const time_t expected = time(nullptr);
|
|
|
|
EXPECT_TRUE(settings()->SetLastUploadAttemptTime(expected));
|
|
|
|
EXPECT_TRUE(settings()->GetLastUploadAttemptTime(&actual));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(actual, expected);
|
2015-03-09 18:47:52 -04:00
|
|
|
|
2018-02-13 14:25:14 -08:00
|
|
|
Settings local_settings;
|
|
|
|
EXPECT_TRUE(local_settings.Initialize(settings_path()));
|
2015-03-09 18:47:52 -04:00
|
|
|
actual = -1;
|
|
|
|
EXPECT_TRUE(local_settings.GetLastUploadAttemptTime(&actual));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(actual, expected);
|
2015-03-09 18:47:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// The following tests write a corrupt settings file and test the recovery
|
|
|
|
// operation.
|
|
|
|
|
|
|
|
TEST_F(SettingsTest, BadFileOnInitialize) {
|
|
|
|
InitializeBadFile();
|
|
|
|
|
2018-02-13 14:25:14 -08:00
|
|
|
Settings settings;
|
|
|
|
EXPECT_TRUE(settings.Initialize(settings_path()));
|
2015-03-09 18:47:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SettingsTest, BadFileOnGet) {
|
|
|
|
InitializeBadFile();
|
|
|
|
|
|
|
|
UUID client_id;
|
|
|
|
EXPECT_TRUE(settings()->GetClientID(&client_id));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_NE(client_id, UUID());
|
2015-03-09 18:47:52 -04:00
|
|
|
|
2018-02-13 14:25:14 -08:00
|
|
|
Settings local_settings;
|
|
|
|
EXPECT_TRUE(local_settings.Initialize(settings_path()));
|
2015-03-09 18:47:52 -04:00
|
|
|
UUID actual;
|
|
|
|
EXPECT_TRUE(local_settings.GetClientID(&actual));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(actual, client_id);
|
2015-03-09 18:47:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SettingsTest, BadFileOnSet) {
|
|
|
|
InitializeBadFile();
|
|
|
|
|
|
|
|
EXPECT_TRUE(settings()->SetUploadsEnabled(true));
|
|
|
|
bool enabled = false;
|
|
|
|
EXPECT_TRUE(settings()->GetUploadsEnabled(&enabled));
|
|
|
|
EXPECT_TRUE(enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SettingsTest, UnlinkFile) {
|
|
|
|
UUID client_id;
|
|
|
|
EXPECT_TRUE(settings()->GetClientID(&client_id));
|
|
|
|
EXPECT_TRUE(settings()->SetUploadsEnabled(true));
|
|
|
|
EXPECT_TRUE(settings()->SetLastUploadAttemptTime(time(nullptr)));
|
|
|
|
|
2022-01-19 15:00:24 -05:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(_wunlink(settings_path().value().c_str()), 0)
|
2015-04-20 14:21:48 -07:00
|
|
|
<< ErrnoMessage("_wunlink");
|
|
|
|
#else
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(unlink(settings_path().value().c_str()), 0)
|
2015-04-20 14:21:48 -07:00
|
|
|
<< ErrnoMessage("unlink");
|
|
|
|
#endif
|
2015-03-09 18:47:52 -04:00
|
|
|
|
2018-02-13 14:25:14 -08:00
|
|
|
Settings local_settings;
|
|
|
|
EXPECT_TRUE(local_settings.Initialize(settings_path()));
|
2015-03-09 18:47:52 -04:00
|
|
|
UUID new_client_id;
|
|
|
|
EXPECT_TRUE(local_settings.GetClientID(&new_client_id));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_NE(new_client_id, client_id);
|
2015-03-09 18:47:52 -04:00
|
|
|
|
|
|
|
// Check that all values are reset.
|
|
|
|
bool enabled = true;
|
|
|
|
EXPECT_TRUE(local_settings.GetUploadsEnabled(&enabled));
|
|
|
|
EXPECT_FALSE(enabled);
|
|
|
|
|
|
|
|
time_t time = -1;
|
|
|
|
EXPECT_TRUE(local_settings.GetLastUploadAttemptTime(&time));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(time, 0);
|
2015-03-09 18:47:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
} // namespace test
|
|
|
|
} // namespace crashpad
|