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

Side by Side Diff: chrome/browser/media/webrtc/webrtc_log_util_unittest.cc

Issue 2799883003: Switch from TestBrowserThread to TestBrowserThreadBundle in chrome. (Closed)
Patch Set: fix-string Created 3 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/media/webrtc/webrtc_log_util.h"
6
5 #include "base/files/file_enumerator.h" 7 #include "base/files/file_enumerator.h"
6 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
7 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/time/time.h" 11 #include "base/time/time.h"
11 #include "chrome/browser/media/webrtc/webrtc_log_util.h" 12 #include "content/public/test/test_browser_thread_bundle.h"
12 #include "content/public/test/test_browser_thread.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 const int kExpectedDaysToKeepLogFiles = 5; 15 const int kExpectedDaysToKeepLogFiles = 5;
16 16
17 class WebRtcLogUtilTest : public testing::Test { 17 class WebRtcLogUtilTest : public testing::Test {
18 public: 18 public:
19 WebRtcLogUtilTest() 19 WebRtcLogUtilTest() = default;
20 : file_thread_(content::BrowserThread::FILE, &message_loop_) {}
21 20
22 void SetUp() override { 21 void SetUp() override {
23 // Create three files. One with modified date as of now, one with date one 22 // Create three files. One with modified date as of now, one with date one
24 // day younger than the keep limit, one with date one day older than the 23 // day younger than the keep limit, one with date one day older than the
25 // limit. The two former are expected to be kept and the last to be deleted 24 // limit. The two former are expected to be kept and the last to be deleted
26 // when deleting old logs. 25 // when deleting old logs.
27 ASSERT_TRUE(dir_.CreateUniqueTempDir()); 26 ASSERT_TRUE(dir_.CreateUniqueTempDir());
28 base::FilePath file; 27 base::FilePath file;
29 ASSERT_TRUE(CreateTemporaryFileInDir(dir_.GetPath(), &file)); 28 ASSERT_TRUE(CreateTemporaryFileInDir(dir_.GetPath(), &file));
30 ASSERT_TRUE(CreateTemporaryFileInDir(dir_.GetPath(), &file)); 29 ASSERT_TRUE(CreateTemporaryFileInDir(dir_.GetPath(), &file));
(...skipping 14 matching lines...) Expand all
45 int file_counter = 0; 44 int file_counter = 0;
46 for (base::FilePath name = files.Next(); !name.empty(); 45 for (base::FilePath name = files.Next(); !name.empty();
47 name = files.Next()) { 46 name = files.Next()) {
48 EXPECT_LT(base::Time::Now() - files.GetInfo().GetLastModifiedTime(), 47 EXPECT_LT(base::Time::Now() - files.GetInfo().GetLastModifiedTime(),
49 base::TimeDelta::FromDays(kExpectedDaysToKeepLogFiles)); 48 base::TimeDelta::FromDays(kExpectedDaysToKeepLogFiles));
50 ++file_counter; 49 ++file_counter;
51 } 50 }
52 EXPECT_EQ(expected_files, file_counter); 51 EXPECT_EQ(expected_files, file_counter);
53 } 52 }
54 53
55 base::MessageLoopForUI message_loop_; 54 content::TestBrowserThreadBundle test_browser_thread_bundle_;
56 content::TestBrowserThread file_thread_;
57 base::ScopedTempDir dir_; 55 base::ScopedTempDir dir_;
58 }; 56 };
59 57
60 TEST_F(WebRtcLogUtilTest, DeleteOldWebRtcLogFiles) { 58 TEST_F(WebRtcLogUtilTest, DeleteOldWebRtcLogFiles) {
61 WebRtcLogUtil::DeleteOldWebRtcLogFiles(dir_.GetPath()); 59 WebRtcLogUtil::DeleteOldWebRtcLogFiles(dir_.GetPath());
62 VerifyFiles(2); 60 VerifyFiles(2);
63 } 61 }
64 62
65 TEST_F(WebRtcLogUtilTest, DeleteOldAndRecentWebRtcLogFiles) { 63 TEST_F(WebRtcLogUtilTest, DeleteOldAndRecentWebRtcLogFiles) {
66 base::Time time_begin_delete = 64 base::Time time_begin_delete =
67 base::Time::Now() - base::TimeDelta::FromDays(1); 65 base::Time::Now() - base::TimeDelta::FromDays(1);
68 WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles(dir_.GetPath(), 66 WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles(dir_.GetPath(),
69 time_begin_delete); 67 time_begin_delete);
70 VerifyFiles(1); 68 VerifyFiles(1);
71 } 69 }
OLDNEW
« no previous file with comments | « chrome/browser/history/android/sqlite_cursor_unittest.cc ('k') | chrome/browser/metrics/thread_watcher_android_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698