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

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: 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
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 06173eacea2d88d0a9f0b27416e7e9476826e093..8e4d81b0e5c61fdd102d670aee679354f8550cfb 100644
--- a/chrome/browser/android/offline_pages/offline_page_utils_unittest.cc
+++ b/chrome/browser/android/offline_pages/offline_page_utils_unittest.cc
@@ -55,6 +55,7 @@ class OfflinePageUtilsTest
// Necessary callbacks for the offline page model.
void OnSavePageDone(SavePageResult result, int64_t offlineId);
void OnClearAllDone();
+ void OnGetURLDone(const GURL& url);
// OfflinePageTestArchiver::Observer implementation:
void SetLastPathCreatedByArchiver(const base::FilePath& file_path) override;
@@ -70,6 +71,8 @@ class OfflinePageUtilsTest
int64_t offline_id() const { return offline_id_; }
+ GURL url() const { return url_; }
dewittj 2016/06/09 22:13:58 nit: const GURL&
Vivian 2016/06/10 17:38:14 Done.
+
private:
void CreateOfflinePages();
std::unique_ptr<OfflinePageTestArchiver> BuildArchiver(
@@ -81,6 +84,7 @@ class OfflinePageUtilsTest
GURL offline_url_missing_;
int64_t offline_id_;
+ GURL url_;
scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
base::ThreadTaskRunnerHandle task_runner_handle_;
@@ -125,6 +129,11 @@ void OfflinePageUtilsTest::OnClearAllDone() {
// Result ignored here.
}
+void OfflinePageUtilsTest::OnGetURLDone(const GURL& url) {
+ // Save url here to verify
+ url_ = url;
+}
+
void OfflinePageUtilsTest::SetLastPathCreatedByArchiver(
const base::FilePath& file_path) {}
@@ -188,17 +197,22 @@ 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(), OfflinePageUtils::MaybeGetOfflineURLForOnlineURL(
- profile(), GURL(kTestPage3Url)));
+
+TEST_F(OfflinePageUtilsTest, GetOfflineURLForOnlineURL) {
+ OfflinePageUtils::GetOfflineURLForOnlineURL(profile(), kTestPage1Url, base::Bind(&OfflinePageUtilsTest::OnGetURLDone, AsWeakPtr()));
dewittj 2016/06/09 22:13:58 It doesn't look like this is waiting for the call
Vivian 2016/06/10 17:38:14 Done.
+ GURL url_1 = url();
+ EXPECT_EQ(offline_url_page_1(), url_1);
+
+ OfflinePageUtils::GetOfflineURLForOnlineURL(profile(), kTestPage2Url, base::Bind(&OfflinePageUtilsTest::OnGetURLDone, AsWeakPtr()));
+ GURL url_2 = url();
+ EXPECT_EQ(offline_url_page_2(), url_2);
+
+ OfflinePageUtils::GetOfflineURLForOnlineURL(profile(), GURL(kTestPage3Url), base::Bind(&OfflinePageUtilsTest::OnGetURLDone, AsWeakPtr()));
+ GURL url_3 = url();
+ EXPECT_EQ(GURL(), url_3);
}
+
TEST_F(OfflinePageUtilsTest, MaybeGetOnlineURLForOfflineURL) {
EXPECT_EQ(kTestPage1Url, OfflinePageUtils::MaybeGetOnlineURLForOfflineURL(
profile(), offline_url_page_1()));

Powered by Google App Engine
This is Rietveld 408576698