| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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. | |
| 4 | |
| 5 #include "base/command_line.h" | |
| 6 #include "base/path_service.h" | |
| 7 #include "chrome/browser/browser_process.h" | |
| 8 #include "chrome/browser/chrome_notification_types.h" | |
| 9 #include "chrome/browser/ui/browser.h" | |
| 10 #include "chrome/browser/ui/browser_commands.h" | |
| 11 #include "chrome/browser/user_data_dir_extractor.h" | |
| 12 #include "chrome/common/chrome_paths.h" | |
| 13 #include "chrome/common/chrome_switches.h" | |
| 14 #include "chrome/test/base/in_process_browser_test.h" | |
| 15 #include "chrome/test/base/ui_test_utils.h" | |
| 16 #include "chrome/test/ui/ui_test.h" | |
| 17 | |
| 18 class ChromeMainUserDataDirTest : public InProcessBrowserTest { | |
| 19 public: | |
| 20 ChromeMainUserDataDirTest() | |
| 21 : did_get_user_data_dir_(false), | |
| 22 did_create_local_state_before_get_user_data_dir_(false) {} | |
| 23 | |
| 24 bool did_get_user_data_dir() const { return did_get_user_data_dir_; } | |
| 25 bool did_create_local_state_before_get_user_data_dir() const { | |
| 26 return did_create_local_state_before_get_user_data_dir_; | |
| 27 } | |
| 28 | |
| 29 protected: | |
| 30 virtual void SetUp() OVERRIDE { | |
| 31 // Install custom GetUserDataDir callback. | |
| 32 callback_ = base::Bind(&ChromeMainUserDataDirTest::GetUserDataDirCallback, | |
| 33 this); | |
| 34 chrome::InstallCustomGetUserDataDirCallbackForTest(&callback_); | |
| 35 | |
| 36 InProcessBrowserTest::SetUp(); | |
| 37 } | |
| 38 | |
| 39 private: | |
| 40 base::FilePath GetUserDataDirCallback() { | |
| 41 did_get_user_data_dir_ = true; | |
| 42 did_create_local_state_before_get_user_data_dir_ = | |
| 43 g_browser_process && g_browser_process->created_local_state(); | |
| 44 | |
| 45 base::FilePath user_data_dir; | |
| 46 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | |
| 47 return user_data_dir; | |
| 48 } | |
| 49 | |
| 50 chrome::GetUserDataDirCallback callback_; | |
| 51 bool did_get_user_data_dir_; | |
| 52 bool did_create_local_state_before_get_user_data_dir_; | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(ChromeMainUserDataDirTest); | |
| 55 }; | |
| 56 | |
| 57 IN_PROC_BROWSER_TEST_F(ChromeMainUserDataDirTest, GetUserDataDir) { | |
| 58 // Verify that GetUserDataDir() has been invoked. | |
| 59 ASSERT_TRUE(did_get_user_data_dir()); | |
| 60 | |
| 61 // Verify that local state was not created before invoking GetUserDataDir(). | |
| 62 ASSERT_FALSE(did_create_local_state_before_get_user_data_dir()); | |
| 63 | |
| 64 // Verify that we have a valid browser process. | |
| 65 ASSERT_TRUE(g_browser_process); | |
| 66 | |
| 67 // Verify that local state is created now. | |
| 68 ASSERT_TRUE(g_browser_process->created_local_state()); | |
| 69 } | |
| OLD | NEW |