Fire an error if a pref used in the UI is missing once all prefs are fetched.
[chromium-blink-merge.git] / chrome / browser / sync / test / integration / single_client_directory_sync_test.cc
blob14d9d2a9ec7bd6eb27c411c1e57f36ea609d9a35
1 // Copyright (c) 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.
5 #include "base/message_loop/message_loop.h"
6 #include "base/run_loop.h"
7 #include "base/synchronization/waitable_event.h"
8 #include "base/time/time.h"
9 #include "chrome/browser/sync/profile_sync_service.h"
10 #include "chrome/browser/sync/test/integration/sync_test.h"
11 #include "content/public/browser/browser_thread.h"
13 using content::BrowserThread;
15 class SingleClientDirectorySyncTest : public SyncTest {
16 public:
17 SingleClientDirectorySyncTest() : SyncTest(SINGLE_CLIENT) {}
18 ~SingleClientDirectorySyncTest() override {}
20 private:
21 DISALLOW_COPY_AND_ASSIGN(SingleClientDirectorySyncTest);
24 void SignalEvent(base::WaitableEvent* e) {
25 e->Signal();
28 bool WaitForExistingTasksOnLoop(base::MessageLoop* loop) {
29 base::WaitableEvent e(true, false);
30 loop->PostTask(FROM_HERE, base::Bind(&SignalEvent, &e));
31 // Timeout stolen from StatusChangeChecker::GetTimeoutDuration().
32 return e.TimedWait(base::TimeDelta::FromSeconds(45));
35 IN_PROC_BROWSER_TEST_F(SingleClientDirectorySyncTest,
36 StopThenDisableDeletesDirectory) {
37 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
38 ProfileSyncService* sync_service = GetSyncService(0);
39 base::FilePath directory_path = sync_service->GetDirectoryPathForTest();
40 ASSERT_TRUE(base::DirectoryExists(directory_path));
41 sync_service->StopAndSuppress();
42 sync_service->DisableForUser();
44 // Wait for StartupController::StartUp()'s tasks to finish.
45 base::RunLoop run_loop;
46 base::MessageLoop::current()->PostTask(FROM_HERE, run_loop.QuitClosure());
47 run_loop.Run();
48 // Wait for the directory deletion to finish.
49 base::MessageLoop* sync_loop = sync_service->GetSyncLoopForTest();
50 ASSERT_TRUE(WaitForExistingTasksOnLoop(sync_loop));
52 ASSERT_FALSE(base::DirectoryExists(directory_path));