[M120 Migration]Fix for crash during chrome exit
[platform/framework/web/chromium-efl.git] / chrome / browser / browser_process_platform_part_ash_unittest.cc
1 // Copyright 2022 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/browser_process_platform_part_ash.h"
6
7 #include "base/memory/raw_ptr.h"
8 #include "chrome/test/base/browser_process_platform_part_test_api_chromeos.h"
9 #include "chrome/test/base/testing_browser_process.h"
10 #include "chrome/test/base/testing_profile.h"
11 #include "content/public/test/browser_task_environment.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 class BrowserProcessPlatformPartAshTest : public testing::Test {
15  public:
16   BrowserProcessPlatformPartAshTest() = default;
17   BrowserProcessPlatformPartAshTest(const BrowserProcessPlatformPartAshTest&) =
18       delete;
19   BrowserProcessPlatformPartAshTest& operator=(
20       const BrowserProcessPlatformPartAshTest&) = delete;
21   ~BrowserProcessPlatformPartAshTest() override = default;
22
23  protected:
24   content::BrowserTaskEnvironment task_environment_;
25   TestingProfile profile_;
26   raw_ptr<BrowserProcessPlatformPart, ExperimentalAsh> process_part_ =
27       TestingBrowserProcess::GetGlobal()->platform_part();
28 };
29
30 TEST_F(BrowserProcessPlatformPartAshTest, RestoresURLsForRegularProfiles) {
31   BrowserProcessPlatformPartTestApi test_api(process_part_);
32   EXPECT_TRUE(test_api.CanRestoreUrlsForProfile(&profile_));
33 }
34
35 TEST_F(BrowserProcessPlatformPartAshTest,
36        DoesNotRestoreURLsForIncognitoProfiles) {
37   Profile* incognito_profile =
38       profile_.GetPrimaryOTRProfile(/*create_if_needed=*/true);
39   BrowserProcessPlatformPartTestApi test_api(process_part_);
40   EXPECT_FALSE(test_api.CanRestoreUrlsForProfile(incognito_profile));
41 }