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

Side by Side Diff: chrome/browser/android/offline_pages/offline_page_mhtml_archiver_unittest.cc

Issue 1542413002: Switch to standard integer types in chrome/browser/, part 1 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/android/offline_pages/offline_page_mhtml_archiver.h" 5 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h"
6 6
7 #include <stdint.h>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
9 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
12 #include "base/run_loop.h" 15 #include "base/run_loop.h"
13 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
14 #include "base/test/test_simple_task_runner.h" 17 #include "base/test/test_simple_task_runner.h"
15 #include "base/thread_task_runner_handle.h" 18 #include "base/thread_task_runner_handle.h"
16 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
17 20
18 namespace offline_pages { 21 namespace offline_pages {
19 22
20 namespace { 23 namespace {
21 24
22 const char kTestURL[] = "http://example.com/"; 25 const char kTestURL[] = "http://example.com/";
23 const base::FilePath::CharType kTestFilePath[] = FILE_PATH_LITERAL( 26 const base::FilePath::CharType kTestFilePath[] = FILE_PATH_LITERAL(
24 "/archive_dir/offline_page.mhtml"); 27 "/archive_dir/offline_page.mhtml");
25 const int64 kTestFileSize = 123456LL; 28 const int64_t kTestFileSize = 123456LL;
26 29
27 class TestMHTMLArchiver : public OfflinePageMHTMLArchiver { 30 class TestMHTMLArchiver : public OfflinePageMHTMLArchiver {
28 public: 31 public:
29 enum class TestScenario { 32 enum class TestScenario {
30 SUCCESS, 33 SUCCESS,
31 NOT_ABLE_TO_ARCHIVE, 34 NOT_ABLE_TO_ARCHIVE,
32 WEB_CONTENTS_MISSING, 35 WEB_CONTENTS_MISSING,
33 }; 36 };
34 37
35 TestMHTMLArchiver(const GURL& url, const TestScenario test_scenario); 38 TestMHTMLArchiver(const GURL& url, const TestScenario test_scenario);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 93
91 base::FilePath GetTestFilePath() const { 94 base::FilePath GetTestFilePath() const {
92 return base::FilePath(kTestFilePath); 95 return base::FilePath(kTestFilePath);
93 } 96 }
94 97
95 const OfflinePageArchiver* last_archiver() const { return last_archiver_; } 98 const OfflinePageArchiver* last_archiver() const { return last_archiver_; }
96 OfflinePageArchiver::ArchiverResult last_result() const { 99 OfflinePageArchiver::ArchiverResult last_result() const {
97 return last_result_; 100 return last_result_;
98 } 101 }
99 const base::FilePath& last_file_path() const { return last_file_path_; } 102 const base::FilePath& last_file_path() const { return last_file_path_; }
100 int64 last_file_size() const { return last_file_size_; } 103 int64_t last_file_size() const { return last_file_size_; }
101 104
102 const OfflinePageArchiver::CreateArchiveCallback callback() { 105 const OfflinePageArchiver::CreateArchiveCallback callback() {
103 return base::Bind(&OfflinePageMHTMLArchiverTest::OnCreateArchiveDone, 106 return base::Bind(&OfflinePageMHTMLArchiverTest::OnCreateArchiveDone,
104 base::Unretained(this)); 107 base::Unretained(this));
105 } 108 }
106 109
107 private: 110 private:
108 void OnCreateArchiveDone(OfflinePageArchiver* archiver, 111 void OnCreateArchiveDone(OfflinePageArchiver* archiver,
109 OfflinePageArchiver::ArchiverResult result, 112 OfflinePageArchiver::ArchiverResult result,
110 const GURL& url, 113 const GURL& url,
111 const base::FilePath& file_path, 114 const base::FilePath& file_path,
112 int64 file_size); 115 int64_t file_size);
113 116
114 OfflinePageArchiver* last_archiver_; 117 OfflinePageArchiver* last_archiver_;
115 OfflinePageArchiver::ArchiverResult last_result_; 118 OfflinePageArchiver::ArchiverResult last_result_;
116 GURL last_url_; 119 GURL last_url_;
117 base::FilePath last_file_path_; 120 base::FilePath last_file_path_;
118 int64 last_file_size_; 121 int64_t last_file_size_;
119 122
120 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; 123 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
121 base::ThreadTaskRunnerHandle task_runner_handle_; 124 base::ThreadTaskRunnerHandle task_runner_handle_;
122 125
123 DISALLOW_COPY_AND_ASSIGN(OfflinePageMHTMLArchiverTest); 126 DISALLOW_COPY_AND_ASSIGN(OfflinePageMHTMLArchiverTest);
124 }; 127 };
125 128
126 OfflinePageMHTMLArchiverTest::OfflinePageMHTMLArchiverTest() 129 OfflinePageMHTMLArchiverTest::OfflinePageMHTMLArchiverTest()
127 : last_archiver_(nullptr), 130 : last_archiver_(nullptr),
128 last_result_(OfflinePageArchiver::ArchiverResult:: 131 last_result_(OfflinePageArchiver::ArchiverResult::
(...skipping 10 matching lines...) Expand all
139 const GURL& url, 142 const GURL& url,
140 TestMHTMLArchiver::TestScenario scenario) { 143 TestMHTMLArchiver::TestScenario scenario) {
141 return scoped_ptr<TestMHTMLArchiver>(new TestMHTMLArchiver(url, scenario)); 144 return scoped_ptr<TestMHTMLArchiver>(new TestMHTMLArchiver(url, scenario));
142 } 145 }
143 146
144 void OfflinePageMHTMLArchiverTest::OnCreateArchiveDone( 147 void OfflinePageMHTMLArchiverTest::OnCreateArchiveDone(
145 OfflinePageArchiver* archiver, 148 OfflinePageArchiver* archiver,
146 OfflinePageArchiver::ArchiverResult result, 149 OfflinePageArchiver::ArchiverResult result,
147 const GURL& url, 150 const GURL& url,
148 const base::FilePath& file_path, 151 const base::FilePath& file_path,
149 int64 file_size) { 152 int64_t file_size) {
150 last_url_ = url; 153 last_url_ = url;
151 last_archiver_ = archiver; 154 last_archiver_ = archiver;
152 last_result_ = result; 155 last_result_ = result;
153 last_file_path_ = file_path; 156 last_file_path_ = file_path;
154 last_file_size_ = file_size; 157 last_file_size_ = file_size;
155 } 158 }
156 159
157 void OfflinePageMHTMLArchiverTest::PumpLoop() { 160 void OfflinePageMHTMLArchiverTest::PumpLoop() {
158 task_runner_->RunUntilIdle(); 161 task_runner_->RunUntilIdle();
159 } 162 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 GURL url_2("https://en.m.wikipedia.org/Sample_page_about_stuff"); 218 GURL url_2("https://en.m.wikipedia.org/Sample_page_about_stuff");
216 std::string title_2("Some Wiki Page"); 219 std::string title_2("Some Wiki Page");
217 base::FilePath expected_2(FILE_PATH_LITERAL( 220 base::FilePath expected_2(FILE_PATH_LITERAL(
218 "en.m.wikipedia.org-Some_Wiki_Page-rEdSruS+14jgpnwJN9PGRUDpx9c=.mhtml")); 221 "en.m.wikipedia.org-Some_Wiki_Page-rEdSruS+14jgpnwJN9PGRUDpx9c=.mhtml"));
219 base::FilePath actual_2( 222 base::FilePath actual_2(
220 OfflinePageMHTMLArchiver::GenerateFileName(url_2, title_2)); 223 OfflinePageMHTMLArchiver::GenerateFileName(url_2, title_2));
221 EXPECT_EQ(expected_2, actual_2); 224 EXPECT_EQ(expected_2, actual_2);
222 } 225 }
223 226
224 } // namespace offline_pages 227 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698