reading_list_private_apitest.cc revision 5c02ac1a9c1b504631c0a3d2b6e737b5d738bae1
15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file. 45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/extensions/api/reading_list_private/reading_list_private_api.h" 75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/extensions/extension_apitest.h" 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/profiles/profile.h" 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "components/dom_distiller/core/dom_distiller_service.h" 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "components/dom_distiller/core/dom_distiller_store.h" 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "components/dom_distiller/core/dom_distiller_test_util.h" 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "components/dom_distiller/core/fake_db.h" 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "components/dom_distiller/core/fake_distiller.h" 145c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "components/dom_distiller/core/fake_distiller_page.h" 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)using dom_distiller::test::FakeDB; 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)using dom_distiller::test::FakeDistiller; 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)using dom_distiller::test::util::CreateStoreWithFakeDB; 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)using dom_distiller::DomDistillerContextKeyedService; 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)using dom_distiller::DomDistillerService; 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)using dom_distiller::DistillerFactory; 225c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liuusing dom_distiller::DistillerPageFactory; 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)using dom_distiller::DomDistillerStoreInterface; 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)using dom_distiller::test::MockDistillerFactory; 255c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liuusing dom_distiller::test::MockDistillerPage; 265c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liuusing dom_distiller::test::MockDistillerPageFactory; 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class ReadingListPrivateApiTest : public ExtensionApiTest { 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) static KeyedService* Build(content::BrowserContext* context) { 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FakeDB* fake_db = new FakeDB(new FakeDB::EntryMap); 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FakeDistiller* distiller = new FakeDistiller(true); 335c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu MockDistillerPage* distiller_page = new MockDistillerPage(); 345c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu MockDistillerFactory* distiller_factory = new MockDistillerFactory(); 355c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu MockDistillerPageFactory* distiller_page_factory = 365c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu new MockDistillerPageFactory(); 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DomDistillerContextKeyedService* service = 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) new DomDistillerContextKeyedService( 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<DomDistillerStoreInterface>( 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CreateStoreWithFakeDB(fake_db, FakeDB::EntryMap())), 415c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu scoped_ptr<DistillerFactory>(distiller_factory), 425c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu scoped_ptr<DistillerPageFactory>(distiller_page_factory)); 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) fake_db->InitCallback(true); 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) fake_db->LoadCallback(true); 455c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu EXPECT_CALL(*distiller_factory, CreateDistillerImpl()) 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) .WillOnce(testing::Return(distiller)); 475c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu EXPECT_CALL(*distiller_page_factory, CreateDistillerPageImpl()) 485c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu .WillOnce(testing::Return(distiller_page)); 495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return service; 505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(ReadingListPrivateApiTest, ReadingListPrivate) { 545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) dom_distiller::DomDistillerServiceFactory::GetInstance()->SetTestingFactory( 555c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu profile(), &ReadingListPrivateApiTest::Build); 565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ASSERT_TRUE(RunComponentExtensionTest("reading_list_private")) << message_; 575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 58