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

Unified Diff: components/offline_pages/core/downloads/download_ui_adapter_unittest.cc

Issue 2489443002: Move all components/offline_pages/ files into component/offline_pages/core (Closed)
Patch Set: rebase Created 4 years 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: components/offline_pages/core/downloads/download_ui_adapter_unittest.cc
diff --git a/components/offline_pages/downloads/download_ui_adapter_unittest.cc b/components/offline_pages/core/downloads/download_ui_adapter_unittest.cc
similarity index 78%
rename from components/offline_pages/downloads/download_ui_adapter_unittest.cc
rename to components/offline_pages/core/downloads/download_ui_adapter_unittest.cc
index ef21b922942b9436bf2440e9e012cc73dac31a6c..60f1402ba3a187598afd6fef7f12618dc4d8c0b7 100644
--- a/components/offline_pages/downloads/download_ui_adapter_unittest.cc
+++ b/components/offline_pages/core/downloads/download_ui_adapter_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/offline_pages/downloads/download_ui_adapter.h"
+#include "components/offline_pages/core/downloads/download_ui_adapter.h"
#include <stdint.h>
@@ -20,9 +20,9 @@
#include "base/test/test_mock_time_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
-#include "components/offline_pages/client_namespace_constants.h"
-#include "components/offline_pages/client_policy_controller.h"
-#include "components/offline_pages/stub_offline_page_model.h"
+#include "components/offline_pages/core/client_namespace_constants.h"
+#include "components/offline_pages/core/client_policy_controller.h"
+#include "components/offline_pages/core/stub_offline_page_model.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace offline_pages {
@@ -33,8 +33,8 @@ static const int kTestOfflineId1 = 1;
static const int kTestOfflineId2 = 2;
static const int kTestOfflineId3 = 3;
static const char kTestUrl[] = "http://foo.com/bar.mhtml";
-static const char kTestGuid1[] = "cccccccc-cccc-4ccc-0ccc-ccccccccccc1";
-static const char kTestGuid2[] = "cccccccc-cccc-4ccc-0ccc-ccccccccccc2";
+static const char kTestGuid1[] = "cccccccc-cccc-4ccc-0ccc-ccccccccccc1";
+static const char kTestGuid2[] = "cccccccc-cccc-4ccc-0ccc-ccccccccccc2";
static const char kTestBadGuid[] = "ccccccc-cccc-0ccc-0ccc-ccccccccccc0";
static const ClientId kTestClientIdOtherNamespace(kLastNNamespace, kTestGuid1);
static const ClientId kTestClientIdOtherGuid(kLastNNamespace, kTestBadGuid);
@@ -56,12 +56,8 @@ class MockOfflinePageModel : public StubOfflinePageModel {
policy_controller_(new ClientPolicyController()) {
adapter.reset(new DownloadUIAdapter(this));
// Add one page.
- OfflinePageItem page(GURL(kTestUrl),
- kTestOfflineId1,
- kTestClientId1,
- kTestFilePath,
- kFileSize,
- kTestCreationTime);
+ OfflinePageItem page(GURL(kTestUrl), kTestOfflineId1, kTestClientId1,
+ kTestFilePath, kFileSize, kTestCreationTime);
page.title = kTestTitle;
pages[kTestOfflineId1] = page;
}
@@ -82,9 +78,9 @@ class MockOfflinePageModel : public StubOfflinePageModel {
// PostTask instead of just running callback to simpulate the real class.
void GetAllPages(const MultipleOfflinePageItemCallback& callback) override {
- task_runner_->PostTask(
- FROM_HERE, base::Bind(&MockOfflinePageModel::GetAllPagesImpl,
- base::Unretained(this), callback));
+ task_runner_->PostTask(FROM_HERE,
+ base::Bind(&MockOfflinePageModel::GetAllPagesImpl,
+ base::Unretained(this), callback));
}
void GetAllPagesImpl(const MultipleOfflinePageItemCallback& callback) {
@@ -95,7 +91,7 @@ class MockOfflinePageModel : public StubOfflinePageModel {
}
void DeletePageAndNotifyAdapter(const std::string& guid) {
- for(const auto& page : pages) {
+ for (const auto& page : pages) {
if (page.second.client_id.id == guid) {
observer_->OfflinePageDeleted(page.second.offline_id,
page.second.client_id);
@@ -129,9 +125,8 @@ class MockOfflinePageModel : public StubOfflinePageModel {
DISALLOW_COPY_AND_ASSIGN(MockOfflinePageModel);
};
-class DownloadUIAdapterTest
- : public testing::Test,
- public DownloadUIAdapter::Observer {
+class DownloadUIAdapterTest : public testing::Test,
+ public DownloadUIAdapter::Observer {
public:
DownloadUIAdapterTest();
~DownloadUIAdapterTest() override;
@@ -158,12 +153,9 @@ class DownloadUIAdapterTest
};
DownloadUIAdapterTest::DownloadUIAdapterTest()
- : items_loaded(false),
- task_runner_(new base::TestMockTimeTaskRunner) {
-}
+ : items_loaded(false), task_runner_(new base::TestMockTimeTaskRunner) {}
-DownloadUIAdapterTest::~DownloadUIAdapterTest() {
-}
+DownloadUIAdapterTest::~DownloadUIAdapterTest() {}
void DownloadUIAdapterTest::SetUp() {
model.reset(new MockOfflinePageModel(task_runner_.get()));
@@ -215,11 +207,8 @@ TEST_F(DownloadUIAdapterTest, InitialItemConversion) {
TEST_F(DownloadUIAdapterTest, ItemDeletedAdded) {
PumpLoop();
// Add page, notify adapter.
- OfflinePageItem page(GURL(kTestUrl),
- kTestOfflineId2,
- kTestClientId2,
- base::FilePath(kTestFilePath),
- kFileSize,
+ OfflinePageItem page(GURL(kTestUrl), kTestOfflineId2, kTestClientId2,
+ base::FilePath(kTestFilePath), kFileSize,
kTestCreationTime);
model->AddPageAndNotifyAdapter(page);
PumpLoop();
@@ -236,22 +225,16 @@ TEST_F(DownloadUIAdapterTest, ItemDeletedAdded) {
TEST_F(DownloadUIAdapterTest, ItemWithWrongNamespace) {
PumpLoop();
- OfflinePageItem page1(GURL(kTestUrl),
- kTestOfflineId2,
- kTestClientIdOtherNamespace,
- base::FilePath(kTestFilePath),
- kFileSize,
- kTestCreationTime);
+ OfflinePageItem page1(
+ GURL(kTestUrl), kTestOfflineId2, kTestClientIdOtherNamespace,
+ base::FilePath(kTestFilePath), kFileSize, kTestCreationTime);
model->AddPageAndNotifyAdapter(page1);
PumpLoop();
// Should not add the page with wrong namespace.
EXPECT_EQ(0UL, added_guids.size());
- OfflinePageItem page2(GURL(kTestUrl),
- kTestOfflineId3,
- kTestClientIdOtherGuid,
- base::FilePath(kTestFilePath),
- kFileSize,
+ OfflinePageItem page2(GURL(kTestUrl), kTestOfflineId3, kTestClientIdOtherGuid,
+ base::FilePath(kTestFilePath), kFileSize,
kTestCreationTime);
model->AddPageAndNotifyAdapter(page2);
PumpLoop();
@@ -265,18 +248,12 @@ TEST_F(DownloadUIAdapterTest, ItemUpdated) {
model->pages.clear();
// Add page with the same offline_id/guid, notify adapter.
// This should generate 'updated' notification.
- OfflinePageItem page1(GURL(kTestUrl),
- kTestOfflineId1,
- kTestClientId1,
- base::FilePath(kTestFilePath),
- kFileSize,
+ OfflinePageItem page1(GURL(kTestUrl), kTestOfflineId1, kTestClientId1,
+ base::FilePath(kTestFilePath), kFileSize,
kTestCreationTime);
// Add a new page which did not exist before.
- OfflinePageItem page2(GURL(kTestUrl),
- kTestOfflineId2,
- kTestClientId2,
- base::FilePath(kTestFilePath),
- kFileSize,
+ OfflinePageItem page2(GURL(kTestUrl), kTestOfflineId2, kTestClientId2,
+ base::FilePath(kTestFilePath), kFileSize,
kTestCreationTime);
model->AddPageAndNotifyAdapter(page1);
model->AddPageAndNotifyAdapter(page2);

Powered by Google App Engine
This is Rietveld 408576698