1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #import "ios/web/browsing_data_partition_impl.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "ios/web/public/active_state_manager.h"
9 #include "ios/web/public/browser_state.h"
10 #include "ios/web/public/test/test_browser_state.h"
11 #include "ios/web/public/test/test_web_thread_bundle.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "testing/platform_test.h"
18 class BrowsingDataPartitionImplTest : public PlatformTest {
20 void SetUp() override {
21 PlatformTest::SetUp();
22 browser_state_.reset(new TestBrowserState());
23 BrowserState::GetActiveStateManager(browser_state_.get())->SetActive(true);
25 void TearDown() override {
26 // The BrowserState needs to be destroyed first so that it is outlived by
27 // the WebThreadBundle.
28 BrowserState::GetActiveStateManager(browser_state_.get())->SetActive(false);
29 browser_state_.reset();
30 PlatformTest::TearDown();
33 // The BrowserState used for testing purposes.
34 scoped_ptr<BrowserState> browser_state_;
37 // Used to create TestWebThreads.
38 TestWebThreadBundle thread_bundle_;
43 // Tests that a BrowsingDataPartitionImplTest is succesfully created with a
44 // BrowserState. And that it returns a non-nil BrowsingDataStore.
45 TEST_F(BrowsingDataPartitionImplTest, CreationAndBrowsingDataStore) {
46 BrowsingDataPartition* browsing_data_partition =
47 BrowserState::GetBrowsingDataPartition(browser_state_.get());
48 ASSERT_TRUE(browsing_data_partition);
50 EXPECT_TRUE(browsing_data_partition->GetBrowsingDataStore());