| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/host/linux/certificate_watcher.h" | 5 #include "remoting/host/linux/certificate_watcher.h" |
| 6 | 6 |
| 7 #include <cstdlib> | 7 #include <cstdlib> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 class CertificateWatcherTest : public testing::Test { | 26 class CertificateWatcherTest : public testing::Test { |
| 27 public: | 27 public: |
| 28 CertificateWatcherTest() : task_runner_(message_loop_.task_runner()) { | 28 CertificateWatcherTest() : task_runner_(message_loop_.task_runner()) { |
| 29 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); | 29 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 30 watcher_.reset(new CertificateWatcher( | 30 watcher_.reset(new CertificateWatcher( |
| 31 base::Bind(&CertificateWatcherTest::OnRestart, | 31 base::Bind(&CertificateWatcherTest::OnRestart, |
| 32 base::Unretained(this)), | 32 base::Unretained(this)), |
| 33 task_runner_)); | 33 task_runner_)); |
| 34 watcher_->SetDelayForTests(base::TimeDelta::FromSeconds(0)); | 34 watcher_->SetDelayForTests(base::TimeDelta::FromSeconds(0)); |
| 35 watcher_->SetWatchPathForTests(temp_dir_.path()); | 35 watcher_->SetWatchPathForTests(temp_dir_.GetPath()); |
| 36 } | 36 } |
| 37 | 37 |
| 38 ~CertificateWatcherTest() override { | 38 ~CertificateWatcherTest() override { |
| 39 watcher_.reset(); | 39 watcher_.reset(); |
| 40 base::RunLoop().RunUntilIdle(); | 40 base::RunLoop().RunUntilIdle(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 protected: | 43 protected: |
| 44 // Call this if you expect a restart after the loop runs. | 44 // Call this if you expect a restart after the loop runs. |
| 45 // The thread will hang if OnRestart is never called. | 45 // The thread will hang if OnRestart is never called. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } | 77 } |
| 78 | 78 |
| 79 void TouchFile(const char* filename) { | 79 void TouchFile(const char* filename) { |
| 80 task_runner_->PostTask(FROM_HERE, | 80 task_runner_->PostTask(FROM_HERE, |
| 81 base::Bind(&CertificateWatcherTest::TouchFileTask, | 81 base::Bind(&CertificateWatcherTest::TouchFileTask, |
| 82 base::Unretained(this), filename)); | 82 base::Unretained(this), filename)); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void TouchFileTask(const char* filename) { | 85 void TouchFileTask(const char* filename) { |
| 86 std::string testWriteString = std::to_string(rand()); | 86 std::string testWriteString = std::to_string(rand()); |
| 87 base::FilePath path = temp_dir_.path().AppendASCII(filename); | 87 base::FilePath path = temp_dir_.GetPath().AppendASCII(filename); |
| 88 | 88 |
| 89 if (base::PathExists(path)) { | 89 if (base::PathExists(path)) { |
| 90 EXPECT_TRUE(base::AppendToFile(path, testWriteString.c_str(), | 90 EXPECT_TRUE(base::AppendToFile(path, testWriteString.c_str(), |
| 91 testWriteString.length())); | 91 testWriteString.length())); |
| 92 } else { | 92 } else { |
| 93 EXPECT_TRUE(base::WriteFile(path, testWriteString.c_str(), | 93 EXPECT_TRUE(base::WriteFile(path, testWriteString.c_str(), |
| 94 testWriteString.length())); | 94 testWriteString.length())); |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 | 97 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // NSS DB contents. | 161 // NSS DB contents. |
| 162 EXPECT_EQ(0, restart_count_); | 162 EXPECT_EQ(0, restart_count_); |
| 163 Start(); | 163 Start(); |
| 164 EXPECT_EQ(0, restart_count_); | 164 EXPECT_EQ(0, restart_count_); |
| 165 TouchFile(kOtherFileName); | 165 TouchFile(kOtherFileName); |
| 166 RunAndWait(); | 166 RunAndWait(); |
| 167 EXPECT_EQ(0, restart_count_); | 167 EXPECT_EQ(0, restart_count_); |
| 168 } | 168 } |
| 169 | 169 |
| 170 } // namespace remoting | 170 } // namespace remoting |
| OLD | NEW |