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

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: Remove backup file 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..9a68f0ea0853f9ce1463cc73e8473ebb8e7eba73 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);
// 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() const { return url_; }
dewittj 2016/06/10 17:46:10 I think this is unused... can remove it.
Vivian 2016/06/10 17:58:52 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,18 @@ 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) {
dewittj 2016/06/10 17:46:10 No need to pass in callback, you can just refer to
Vivian 2016/06/10 17:58:52 Done.
+ OfflinePageUtils::GetOfflineURLForOnlineURL(profile(), online_url, callback);
+ RunUntilIdle();
+ return url_;
+}
+
void OfflinePageUtilsTest::SetLastPathCreatedByArchiver(
const base::FilePath& file_path) {}
@@ -211,17 +229,26 @@ TEST_F(OfflinePageUtilsTest, MightBeOfflineURL) {
EXPECT_TRUE(OfflinePageUtils::MightBeOfflineURL(GURL("file:///test.mhtml")));
}
-TEST_F(OfflinePageUtilsTest, MaybeGetOfflineURLForOnlineURL) {
+TEST_F(OfflinePageUtilsTest, GetOfflineURLForOnlineURL) {
EXPECT_EQ(offline_url_page_1(),
- OfflinePageUtils::MaybeGetOfflineURLForOnlineURL(profile(),
- kTestPage1Url));
+ OfflinePageUtilsTest::GetOfflineURLForOnlineURL(
+ kTestPage1Url,
+ base::Bind(&OfflinePageUtilsTest::OnGetURLDone, AsWeakPtr())));
+
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));
+ OfflinePageUtilsTest::GetOfflineURLForOnlineURL(
+ kTestPage2Url,
+ base::Bind(&OfflinePageUtilsTest::OnGetURLDone, AsWeakPtr())));
+
+ EXPECT_EQ(GURL::EmptyGURL(),
+ OfflinePageUtilsTest::GetOfflineURLForOnlineURL(
+ kTestPage3Url,
+ base::Bind(&OfflinePageUtilsTest::OnGetURLDone, AsWeakPtr())));
+
+ EXPECT_EQ(GURL::EmptyGURL(),
+ OfflinePageUtilsTest::GetOfflineURLForOnlineURL(
+ kTestPage4Url,
+ base::Bind(&OfflinePageUtilsTest::OnGetURLDone, AsWeakPtr())));
}
TEST_F(OfflinePageUtilsTest, MaybeGetOnlineURLForOfflineURL) {
« 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