Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1347)

Side by Side Diff: client/settings_test.cc

Issue 988063003: Define the Settings interface for a CrashReportDatabase and provide a Mac implementation. (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« client/settings_mac.mm ('K') | « client/settings_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "client/settings.h"
16
17 #include "client/crash_report_database.h"
18 #include "gtest/gtest.h"
19 #include "util/test/scoped_temp_dir.h"
20
21 namespace crashpad {
22 namespace test {
23
Mark Mentovai 2015/03/08 05:21:56 Inner unnamed namespace, too, like all of the othe
Robert Sesek 2015/03/08 22:15:36 Done.
24 class SettingsTest : public testing::Test {
25 public:
26 SettingsTest() {}
27
28 Settings* settings() { return db_->GetSettings(); }
29
30 protected:
31 // testing::Test:
32 void SetUp() override {
33 ReopenDatabase();
34 }
35
36 void ReopenDatabase() {
37 db_.reset();
38 db_ = CrashReportDatabase::Initialize(temp_dir_.path());
39 ASSERT_TRUE(db_);
40 }
41
42 private:
Mark Mentovai 2015/03/08 05:21:56 DISALLOW_COPY_AND_ASSIGN
Robert Sesek 2015/03/08 22:15:36 Done.
43 ScopedTempDir temp_dir_;
44 scoped_ptr<CrashReportDatabase> db_;
45 };
46
47 TEST_F(SettingsTest, ClientID) {
48 std::string client_id;
49 EXPECT_TRUE(settings()->GetClientID(&client_id));
50 EXPECT_FALSE(client_id.empty());
51
52 ReopenDatabase();
53
54 std::string actual;
55 EXPECT_TRUE(settings()->GetClientID(&actual));
56 EXPECT_EQ(client_id, actual);
57 }
58
59 TEST_F(SettingsTest, UploadsEnabled) {
60 bool enabled = false;
61 EXPECT_FALSE(settings()->GetUploadsEnabled(&enabled));
62
63 EXPECT_TRUE(settings()->SetUploadsEnabled(true));
64 EXPECT_TRUE(settings()->GetUploadsEnabled(&enabled));
65 EXPECT_TRUE(enabled);
66
67 EXPECT_TRUE(settings()->SetUploadsEnabled(false));
68 EXPECT_TRUE(settings()->GetUploadsEnabled(&enabled));
69 EXPECT_FALSE(enabled);
70 }
71
72 TEST_F(SettingsTest, LastUploadAttemptTime) {
73 time_t actual = -1;
74 EXPECT_FALSE(settings()->GetLastUploadAttemptTime(&actual));
75
76 time_t expected = time(nullptr);
77 EXPECT_TRUE(settings()->SetLastUploadAttemptTime(expected));
78 EXPECT_TRUE(settings()->GetLastUploadAttemptTime(&actual));
79 EXPECT_EQ(expected, actual);
80 }
81
82 } // namespace test
83 } // namespace crashpad
OLDNEW
« client/settings_mac.mm ('K') | « client/settings_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698