Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / xwalk / experimental / native_file_system / native_file_system_api_browsertest.cc
1 // Copyright (c) 2014 Intel Corporation. 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/path_service.h"
6 #include "base/strings/utf_string_conversions.h"
7 #include "content/public/test/browser_test_utils.h"
8 #include "content/public/test/test_utils.h"
9 #include "net/base/filename_util.h"
10 #include "xwalk/experimental/native_file_system/virtual_root_provider.h"
11 #include "xwalk/runtime/browser/runtime.h"
12 #include "xwalk/test/base/in_process_browser_test.h"
13 #include "xwalk/test/base/xwalk_test_utils.h"
14
15 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, NativeFileSystem) {
16   const base::string16 passString = base::ASCIIToUTF16("Pass");
17   const base::string16 failString = base::ASCIIToUTF16("Fail");
18
19   content::RunAllPendingInMessageLoop();
20   content::TitleWatcher title_watcher(runtime()->web_contents(), passString);
21   title_watcher.AlsoWaitForTitle(failString);
22
23   // create "<tmp>/Documents" path if not exists. This path will be used in this
24   // testing to replace real home directory.
25   VirtualRootProvider::SetTesting(true);
26
27   base::FilePath test_file;
28   PathService::Get(base::DIR_SOURCE_ROOT, &test_file);
29   test_file = test_file
30       .Append(FILE_PATH_LITERAL("xwalk"))
31       .Append(FILE_PATH_LITERAL("experimental"))
32       .Append(FILE_PATH_LITERAL("native_file_system"))
33       .Append(FILE_PATH_LITERAL("native_file_system_api_browsertest.html"));
34
35   xwalk_test_utils::NavigateToURL(runtime(), net::FilePathToFileURL(test_file));
36   EXPECT_EQ(passString, title_watcher.WaitAndGetTitle());
37 }