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

Unified Diff: chrome/browser/android/offline_pages/offline_page_utils_unittest.cc

Issue 2059513002: Remove obsoleted function and add test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add RunUntilIdle and Style fix Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/offline_pages/offline_page_utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/offline_pages/offline_page_utils_unittest.cc
diff --git a/chrome/browser/android/offline_pages/offline_page_utils_unittest.cc b/chrome/browser/android/offline_pages/offline_page_utils_unittest.cc
index 801897962e6fd0693648bf7aa14b875a18332b36..79bb7fcc1d5e708ec1fb48a5d09a75e551dbc3d4 100644
--- a/chrome/browser/android/offline_pages/offline_page_utils_unittest.cc
+++ b/chrome/browser/android/offline_pages/offline_page_utils_unittest.cc
@@ -53,11 +53,14 @@ class OfflinePageUtilsTest
void SetUp() override;
void RunUntilIdle();
+ GURL GetOfflineURLForOnlineURL(GURL online_url,
+ base::Callback<void(const GURL&)> callback);
fgorski 2016/06/10 04:46:24 nit: you need to set up your editor to convert tab
Vivian 2016/06/10 17:38:14 Done. I used git cl format for now. Will set up ed
// Necessary callbacks for the offline page model.
void OnSavePageDone(SavePageResult result, int64_t offlineId);
void OnClearAllDone();
void OnExpirePageDone(bool success);
+ void OnGetURLDone(const GURL& url);
// OfflinePageTestArchiver::Observer implementation:
void SetLastPathCreatedByArchiver(const base::FilePath& file_path) override;
@@ -75,6 +78,8 @@ class OfflinePageUtilsTest
int64_t offline_id() const { return offline_id_; }
+ const GURL& url() { return url_; }
fgorski 2016/06/10 04:46:24 nit: Signature of this method can be updated. cons
Vivian 2016/06/10 17:38:15 Done.
+
private:
void CreateOfflinePages();
std::unique_ptr<OfflinePageTestArchiver> BuildArchiver(
@@ -87,6 +92,7 @@ class OfflinePageUtilsTest
GURL offline_url_expired_;
int64_t offline_id_;
+ GURL url_;
scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
base::ThreadTaskRunnerHandle task_runner_handle_;
@@ -135,6 +141,17 @@ void OfflinePageUtilsTest::OnClearAllDone() {
// Result ignored here.
}
+void OfflinePageUtilsTest::OnGetURLDone(const GURL& url) {
+ url_ = url;
+}
+
+GURL OfflinePageUtilsTest::GetOfflineURLForOnlineURL(GURL online_url,
+ base::Callback<void(const GURL&)> callback) {
fgorski 2016/06/10 04:46:25 This line is too long. Again "git cl format" handl
Vivian 2016/06/10 17:38:14 Done.
+ OfflinePageUtils::GetOfflineURLForOnlineURL(profile(), online_url, callback);
+ RunUntilIdle();
+ return url();
fgorski 2016/06/10 04:46:24 return url_; This should work for you.
Vivian 2016/06/10 17:38:15 Done.
+}
+
void OfflinePageUtilsTest::SetLastPathCreatedByArchiver(
const base::FilePath& file_path) {}
@@ -211,19 +228,18 @@ TEST_F(OfflinePageUtilsTest, MightBeOfflineURL) {
EXPECT_TRUE(OfflinePageUtils::MightBeOfflineURL(GURL("file:///test.mhtml")));
}
-TEST_F(OfflinePageUtilsTest, MaybeGetOfflineURLForOnlineURL) {
- EXPECT_EQ(offline_url_page_1(),
- OfflinePageUtils::MaybeGetOfflineURLForOnlineURL(profile(),
- kTestPage1Url));
- EXPECT_EQ(offline_url_page_2(),
- OfflinePageUtils::MaybeGetOfflineURLForOnlineURL(profile(),
- kTestPage2Url));
- EXPECT_EQ(GURL::EmptyGURL(), OfflinePageUtils::MaybeGetOfflineURLForOnlineURL(
- profile(), kTestPage3Url));
- EXPECT_EQ(GURL::EmptyGURL(), OfflinePageUtils::MaybeGetOfflineURLForOnlineURL(
- profile(), kTestPage4Url));
+TEST_F(OfflinePageUtilsTest, GetOfflineURLForOnlineURL) {
+ EXPECT_EQ(offline_url_page_1(), OfflinePageUtilsTest::GetOfflineURLForOnlineURL(
+ kTestPage1Url, base::Bind(&OfflinePageUtilsTest::OnGetURLDone, AsWeakPtr())));
fgorski 2016/06/10 04:46:25 Lines in this test are too long as well.
Vivian 2016/06/10 17:38:15 Done.
+
+ EXPECT_EQ(offline_url_page_2(), OfflinePageUtilsTest::GetOfflineURLForOnlineURL(
+ kTestPage2Url, base::Bind(&OfflinePageUtilsTest::OnGetURLDone, AsWeakPtr())));
+
+ EXPECT_EQ(GURL(), OfflinePageUtilsTest::GetOfflineURLForOnlineURL(
+ kTestPage3Url, base::Bind(&OfflinePageUtilsTest::OnGetURLDone, AsWeakPtr())));
fgorski 2016/06/10 04:46:24 Please use GURL::EmptyGURL() in place of GURL() A
Vivian 2016/06/10 17:38:15 Done.
}
+
fgorski 2016/06/10 04:46:25 nit: use one empty line only to separate methods.
Vivian 2016/06/10 17:38:14 Done.
TEST_F(OfflinePageUtilsTest, MaybeGetOnlineURLForOfflineURL) {
EXPECT_EQ(kTestPage1Url, OfflinePageUtils::MaybeGetOnlineURLForOfflineURL(
profile(), offline_url_page_1()));
« no previous file with comments | « chrome/browser/android/offline_pages/offline_page_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698