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

Side by Side Diff: chrome/browser/net/net_log_temp_file_unittest.cc

Issue 624173002: replace OVERRIDE and FINAL with override and final in chrome/browser/[j-q]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 6 years, 2 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
« no previous file with comments | « chrome/browser/net/net_error_tab_helper_unittest.cc ('k') | chrome/browser/net/predictor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/net/net_log_temp_file.h" 5 #include "chrome/browser/net/net_log_temp_file.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "chrome/browser/net/chrome_net_log.h" 13 #include "chrome/browser/net/chrome_net_log.h"
14 #include "content/public/test/test_browser_thread.h" 14 #include "content/public/test/test_browser_thread.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 using content::BrowserThread; 17 using content::BrowserThread;
18 18
19 class TestNetLogTempFile : public NetLogTempFile { 19 class TestNetLogTempFile : public NetLogTempFile {
20 public: 20 public:
21 explicit TestNetLogTempFile(ChromeNetLog* chrome_net_log) 21 explicit TestNetLogTempFile(ChromeNetLog* chrome_net_log)
22 : NetLogTempFile(chrome_net_log), 22 : NetLogTempFile(chrome_net_log),
23 lie_about_net_export_log_directory_(false), 23 lie_about_net_export_log_directory_(false),
24 lie_about_file_existence_(false) { 24 lie_about_file_existence_(false) {
25 } 25 }
26 26
27 // NetLogTempFile implementation: 27 // NetLogTempFile implementation:
28 virtual bool GetNetExportLogDirectory(base::FilePath* path) OVERRIDE { 28 virtual bool GetNetExportLogDirectory(base::FilePath* path) override {
29 if (lie_about_net_export_log_directory_) 29 if (lie_about_net_export_log_directory_)
30 return false; 30 return false;
31 return NetLogTempFile::GetNetExportLogDirectory(path); 31 return NetLogTempFile::GetNetExportLogDirectory(path);
32 } 32 }
33 33
34 virtual bool NetExportLogExists() OVERRIDE { 34 virtual bool NetExportLogExists() override {
35 if (lie_about_file_existence_) 35 if (lie_about_file_existence_)
36 return false; 36 return false;
37 return NetLogTempFile::NetExportLogExists(); 37 return NetLogTempFile::NetExportLogExists();
38 } 38 }
39 39
40 void set_lie_about_net_export_log_directory( 40 void set_lie_about_net_export_log_directory(
41 bool lie_about_net_export_log_directory) { 41 bool lie_about_net_export_log_directory) {
42 lie_about_net_export_log_directory_ = lie_about_net_export_log_directory; 42 lie_about_net_export_log_directory_ = lie_about_net_export_log_directory;
43 } 43 }
44 44
45 void set_lie_about_file_existence(bool lie_about_file_existence) { 45 void set_lie_about_file_existence(bool lie_about_file_existence) {
46 lie_about_file_existence_ = lie_about_file_existence; 46 lie_about_file_existence_ = lie_about_file_existence;
47 } 47 }
48 48
49 private: 49 private:
50 bool lie_about_net_export_log_directory_; 50 bool lie_about_net_export_log_directory_;
51 bool lie_about_file_existence_; 51 bool lie_about_file_existence_;
52 }; 52 };
53 53
54 class NetLogTempFileTest : public ::testing::Test { 54 class NetLogTempFileTest : public ::testing::Test {
55 public: 55 public:
56 NetLogTempFileTest() 56 NetLogTempFileTest()
57 : net_log_(new ChromeNetLog), 57 : net_log_(new ChromeNetLog),
58 net_log_temp_file_(new TestNetLogTempFile(net_log_.get())), 58 net_log_temp_file_(new TestNetLogTempFile(net_log_.get())),
59 file_user_blocking_thread_(BrowserThread::FILE_USER_BLOCKING, 59 file_user_blocking_thread_(BrowserThread::FILE_USER_BLOCKING,
60 &message_loop_) { 60 &message_loop_) {
61 } 61 }
62 62
63 // ::testing::Test implementation: 63 // ::testing::Test implementation:
64 virtual void SetUp() OVERRIDE { 64 virtual void SetUp() override {
65 // Get a temporary file name for unit tests. 65 // Get a temporary file name for unit tests.
66 base::FilePath net_log_dir; 66 base::FilePath net_log_dir;
67 ASSERT_TRUE(net_log_temp_file_->GetNetExportLogDirectory(&net_log_dir)); 67 ASSERT_TRUE(net_log_temp_file_->GetNetExportLogDirectory(&net_log_dir));
68 ASSERT_TRUE(base::CreateTemporaryFileInDir(net_log_dir, &net_export_log_)); 68 ASSERT_TRUE(base::CreateTemporaryFileInDir(net_log_dir, &net_export_log_));
69 69
70 net_log_temp_file_->log_filename_ = net_export_log_.BaseName().value(); 70 net_log_temp_file_->log_filename_ = net_export_log_.BaseName().value();
71 71
72 // CreateTemporaryFileInDir may return a legacy 8.3 file name on windows. 72 // CreateTemporaryFileInDir may return a legacy 8.3 file name on windows.
73 // Need to use the original directory name for string comparisons. 73 // Need to use the original directory name for string comparisons.
74 ASSERT_TRUE(net_log_temp_file_->GetNetExportLog()); 74 ASSERT_TRUE(net_log_temp_file_->GetNetExportLog());
75 net_export_log_ = net_log_temp_file_->log_path_; 75 net_export_log_ = net_log_temp_file_->log_path_;
76 ASSERT_FALSE(net_export_log_.empty()); 76 ASSERT_FALSE(net_export_log_.empty());
77 } 77 }
78 78
79 virtual void TearDown() OVERRIDE { 79 virtual void TearDown() override {
80 // Delete the temporary file we have created. 80 // Delete the temporary file we have created.
81 ASSERT_TRUE(base::DeleteFile(net_export_log_, false)); 81 ASSERT_TRUE(base::DeleteFile(net_export_log_, false));
82 } 82 }
83 83
84 std::string GetStateString() const { 84 std::string GetStateString() const {
85 scoped_ptr<base::DictionaryValue> dict(net_log_temp_file_->GetState()); 85 scoped_ptr<base::DictionaryValue> dict(net_log_temp_file_->GetState());
86 std::string state; 86 std::string state;
87 EXPECT_TRUE(dict->GetString("state", &state)); 87 EXPECT_TRUE(dict->GetString("state", &state));
88 return state; 88 return state;
89 } 89 }
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 // Log an event. 342 // Log an event.
343 net_log_->AddGlobalEntry(net::NetLog::TYPE_CANCELLED); 343 net_log_->AddGlobalEntry(net::NetLog::TYPE_CANCELLED);
344 344
345 net_log_temp_file_->ProcessCommand(NetLogTempFile::DO_STOP); 345 net_log_temp_file_->ProcessCommand(NetLogTempFile::DO_STOP);
346 VerifyFileAndStateAfterDoStop(); 346 VerifyFileAndStateAfterDoStop();
347 347
348 int64 new_stop_file_size; 348 int64 new_stop_file_size;
349 EXPECT_TRUE(base::GetFileSize(net_export_log_, &new_stop_file_size)); 349 EXPECT_TRUE(base::GetFileSize(net_export_log_, &new_stop_file_size));
350 EXPECT_GE(new_stop_file_size, stop_file_size); 350 EXPECT_GE(new_stop_file_size, stop_file_size);
351 } 351 }
OLDNEW
« no previous file with comments | « chrome/browser/net/net_error_tab_helper_unittest.cc ('k') | chrome/browser/net/predictor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698