Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: chrome/browser/drive/fake_drive_service_unittest.cc

Issue 17140009: Support contents upload on FakeDriveService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: split out indentation fix Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/drive/fake_drive_service.h" 5 #include "chrome/browser/drive/fake_drive_service.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/md5.h"
12 #include "base/run_loop.h" 13 #include "base/run_loop.h"
13 #include "base/stl_util.h" 14 #include "base/stl_util.h"
14 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/google_apis/drive_api_parser.h" 17 #include "chrome/browser/google_apis/drive_api_parser.h"
17 #include "chrome/browser/google_apis/gdata_wapi_parser.h" 18 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
18 #include "chrome/browser/google_apis/gdata_wapi_requests.h" 19 #include "chrome/browser/google_apis/gdata_wapi_requests.h"
19 #include "chrome/browser/google_apis/test_util.h" 20 #include "chrome/browser/google_apis/test_util.h"
20 #include "content/public/test/test_browser_thread_bundle.h" 21 #include "content/public/test/test_browser_thread_bundle.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 fake_service_.InitiateUploadExistingFile( 1630 fake_service_.InitiateUploadExistingFile(
1630 base::FilePath(FILE_PATH_LITERAL("drive/File 1.txt")), 1631 base::FilePath(FILE_PATH_LITERAL("drive/File 1.txt")),
1631 "text/plain", 1632 "text/plain",
1632 13, 1633 13,
1633 "file:2_file_resource_id", 1634 "file:2_file_resource_id",
1634 "\"HhMOFgxXHit7ImBr\"", 1635 "\"HhMOFgxXHit7ImBr\"",
1635 test_util::CreateCopyResultCallback(&error, &upload_location)); 1636 test_util::CreateCopyResultCallback(&error, &upload_location));
1636 base::RunLoop().RunUntilIdle(); 1637 base::RunLoop().RunUntilIdle();
1637 1638
1638 EXPECT_EQ(HTTP_SUCCESS, error); 1639 EXPECT_EQ(HTTP_SUCCESS, error);
1639 EXPECT_EQ(GURL("https://2_file_link_resumable_create_media?mode=existing"), 1640 EXPECT_TRUE(upload_location.is_valid());
1640 upload_location);
1641 } 1641 }
1642 1642
1643 TEST_F(FakeDriveServiceTest, ResumeUpload_Offline) { 1643 TEST_F(FakeDriveServiceTest, ResumeUpload_Offline) {
1644 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( 1644 ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
1645 "chromeos/gdata/root_feed.json")); 1645 "chromeos/gdata/root_feed.json"));
1646 1646
1647 GDataErrorCode error = GDATA_OTHER_ERROR; 1647 GDataErrorCode error = GDATA_OTHER_ERROR;
1648 GURL upload_location; 1648 GURL upload_location;
1649 fake_service_.InitiateUploadNewFile( 1649 fake_service_.InitiateUploadNewFile(
1650 base::FilePath(FILE_PATH_LITERAL("drive/Directory 1/new file.foo")), 1650 base::FilePath(FILE_PATH_LITERAL("drive/Directory 1/new file.foo")),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 base::FilePath(), 1703 base::FilePath(),
1704 test_util::CreateCopyResultCallback(&response, &entry), 1704 test_util::CreateCopyResultCallback(&response, &entry),
1705 ProgressCallback()); 1705 ProgressCallback());
1706 base::RunLoop().RunUntilIdle(); 1706 base::RunLoop().RunUntilIdle();
1707 1707
1708 EXPECT_EQ(HTTP_NOT_FOUND, response.code); 1708 EXPECT_EQ(HTTP_NOT_FOUND, response.code);
1709 EXPECT_FALSE(entry.get()); 1709 EXPECT_FALSE(entry.get());
1710 } 1710 }
1711 1711
1712 TEST_F(FakeDriveServiceTest, ResumeUpload_ExistingFile) { 1712 TEST_F(FakeDriveServiceTest, ResumeUpload_ExistingFile) {
1713 base::ScopedTempDir temp_dir;
1714 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
1715 base::FilePath local_file_path =
1716 temp_dir.path().Append(FILE_PATH_LITERAL("File 1.txt"));
1717 std::string contents("hogefugapiyo");
1718 ASSERT_TRUE(test_util::WriteStringToFile(local_file_path, contents));
1719
1713 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( 1720 ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
1714 "chromeos/gdata/root_feed.json")); 1721 "chromeos/gdata/root_feed.json"));
1715 1722
1716 GDataErrorCode error = GDATA_OTHER_ERROR; 1723 GDataErrorCode error = GDATA_OTHER_ERROR;
1717 GURL upload_location; 1724 GURL upload_location;
1718 fake_service_.InitiateUploadExistingFile( 1725 fake_service_.InitiateUploadExistingFile(
1719 base::FilePath(FILE_PATH_LITERAL("drive/File 1.txt")), 1726 base::FilePath(FILE_PATH_LITERAL("drive/File 1.txt")),
1720 "text/plain", 1727 "text/plain",
1721 15, 1728 contents.size(),
1722 "file:2_file_resource_id", 1729 "file:2_file_resource_id",
1723 "\"HhMOFgxXHit7ImBr\"", 1730 "\"HhMOFgxXHit7ImBr\"",
1724 test_util::CreateCopyResultCallback(&error, &upload_location)); 1731 test_util::CreateCopyResultCallback(&error, &upload_location));
1725 base::RunLoop().RunUntilIdle(); 1732 base::RunLoop().RunUntilIdle();
1726 1733
1727 ASSERT_EQ(HTTP_SUCCESS, error); 1734 ASSERT_EQ(HTTP_SUCCESS, error);
1728 1735
1729 UploadRangeResponse response; 1736 UploadRangeResponse response;
1730 scoped_ptr<ResourceEntry> entry; 1737 scoped_ptr<ResourceEntry> entry;
1731 std::vector<test_util::ProgressInfo> upload_progress_values; 1738 std::vector<test_util::ProgressInfo> upload_progress_values;
1732 fake_service_.ResumeUpload( 1739 fake_service_.ResumeUpload(
1733 base::FilePath(FILE_PATH_LITERAL("drive/File 1.txt")), 1740 base::FilePath(FILE_PATH_LITERAL("drive/File 1.txt")),
1734 upload_location, 1741 upload_location,
1735 0, 13, 15, "text/plain", 1742 0, contents.size() / 2, contents.size(), "text/plain",
1736 base::FilePath(), 1743 local_file_path,
1737 test_util::CreateCopyResultCallback(&response, &entry), 1744 test_util::CreateCopyResultCallback(&response, &entry),
1738 base::Bind(&test_util::AppendProgressCallbackResult, 1745 base::Bind(&test_util::AppendProgressCallbackResult,
1739 &upload_progress_values)); 1746 &upload_progress_values));
1740 base::RunLoop().RunUntilIdle(); 1747 base::RunLoop().RunUntilIdle();
1741 1748
1742 EXPECT_EQ(HTTP_RESUME_INCOMPLETE, response.code); 1749 EXPECT_EQ(HTTP_RESUME_INCOMPLETE, response.code);
1743 EXPECT_FALSE(entry.get()); 1750 EXPECT_FALSE(entry.get());
1744 ASSERT_TRUE(!upload_progress_values.empty()); 1751 ASSERT_TRUE(!upload_progress_values.empty());
1745 EXPECT_TRUE(base::STLIsSorted(upload_progress_values)); 1752 EXPECT_TRUE(base::STLIsSorted(upload_progress_values));
1746 EXPECT_LE(0, upload_progress_values.front().first); 1753 EXPECT_LE(0, upload_progress_values.front().first);
1747 EXPECT_GE(13, upload_progress_values.back().first); 1754 EXPECT_GE(static_cast<int64>(contents.size() / 2),
1755 upload_progress_values.back().first);
1748 1756
1749 upload_progress_values.clear(); 1757 upload_progress_values.clear();
1750 fake_service_.ResumeUpload( 1758 fake_service_.ResumeUpload(
1751 base::FilePath(FILE_PATH_LITERAL("drive/File 1.txt")), 1759 base::FilePath(FILE_PATH_LITERAL("drive/File 1.txt")),
1752 upload_location, 1760 upload_location,
1753 13, 15, 15, "text/plain", 1761 contents.size() / 2, contents.size(), contents.size(), "text/plain",
1754 base::FilePath(), 1762 local_file_path,
1755 test_util::CreateCopyResultCallback(&response, &entry), 1763 test_util::CreateCopyResultCallback(&response, &entry),
1756 base::Bind(&test_util::AppendProgressCallbackResult, 1764 base::Bind(&test_util::AppendProgressCallbackResult,
1757 &upload_progress_values)); 1765 &upload_progress_values));
1758 base::RunLoop().RunUntilIdle(); 1766 base::RunLoop().RunUntilIdle();
1759 1767
1760 EXPECT_EQ(HTTP_SUCCESS, response.code); 1768 EXPECT_EQ(HTTP_SUCCESS, response.code);
1761 EXPECT_TRUE(entry.get()); 1769 EXPECT_TRUE(entry.get());
1762 EXPECT_EQ(15L, entry->file_size()); 1770 EXPECT_EQ(static_cast<int64>(contents.size()),
1771 entry->file_size());
1763 EXPECT_TRUE(Exists(entry->resource_id())); 1772 EXPECT_TRUE(Exists(entry->resource_id()));
1764 ASSERT_TRUE(!upload_progress_values.empty()); 1773 ASSERT_TRUE(!upload_progress_values.empty());
1765 EXPECT_TRUE(base::STLIsSorted(upload_progress_values)); 1774 EXPECT_TRUE(base::STLIsSorted(upload_progress_values));
1766 EXPECT_LE(0, upload_progress_values.front().first); 1775 EXPECT_LE(0, upload_progress_values.front().first);
1767 EXPECT_GE(2, upload_progress_values.back().first); 1776 EXPECT_GE(static_cast<int64>(contents.size() - contents.size() / 2),
1777 upload_progress_values.back().first);
1778 EXPECT_EQ(base::MD5String(contents), entry->file_md5());
1768 } 1779 }
1769 1780
1770 TEST_F(FakeDriveServiceTest, ResumeUpload_NewFile) { 1781 TEST_F(FakeDriveServiceTest, ResumeUpload_NewFile) {
1782 base::ScopedTempDir temp_dir;
1783 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
1784 base::FilePath local_file_path =
1785 temp_dir.path().Append(FILE_PATH_LITERAL("new file.foo"));
1786 std::string contents("hogefugapiyo");
1787 ASSERT_TRUE(test_util::WriteStringToFile(local_file_path, contents));
1788
1771 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( 1789 ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
1772 "chromeos/gdata/root_feed.json")); 1790 "chromeos/gdata/root_feed.json"));
1773 1791
1774 GDataErrorCode error = GDATA_OTHER_ERROR; 1792 GDataErrorCode error = GDATA_OTHER_ERROR;
1775 GURL upload_location; 1793 GURL upload_location;
1776 fake_service_.InitiateUploadNewFile( 1794 fake_service_.InitiateUploadNewFile(
1777 base::FilePath(FILE_PATH_LITERAL("drive/Directory 1/new file.foo")), 1795 base::FilePath(FILE_PATH_LITERAL("drive/Directory 1/new file.foo")),
1778 "test/foo", 1796 "test/foo",
1779 15, 1797 contents.size(),
1780 "folder:1_folder_resource_id", 1798 "folder:1_folder_resource_id",
1781 "new file.foo", 1799 "new file.foo",
1782 test_util::CreateCopyResultCallback(&error, &upload_location)); 1800 test_util::CreateCopyResultCallback(&error, &upload_location));
1783 base::RunLoop().RunUntilIdle(); 1801 base::RunLoop().RunUntilIdle();
1784 1802
1785 EXPECT_EQ(HTTP_SUCCESS, error); 1803 EXPECT_EQ(HTTP_SUCCESS, error);
1786 EXPECT_FALSE(upload_location.is_empty()); 1804 EXPECT_FALSE(upload_location.is_empty());
1787 EXPECT_NE(GURL("https://1_folder_resumable_create_media_link"), 1805 EXPECT_NE(GURL("https://1_folder_resumable_create_media_link"),
1788 upload_location); 1806 upload_location);
1789 1807
1790 UploadRangeResponse response; 1808 UploadRangeResponse response;
1791 scoped_ptr<ResourceEntry> entry; 1809 scoped_ptr<ResourceEntry> entry;
1792 std::vector<test_util::ProgressInfo> upload_progress_values; 1810 std::vector<test_util::ProgressInfo> upload_progress_values;
1793 fake_service_.ResumeUpload( 1811 fake_service_.ResumeUpload(
1794 base::FilePath(FILE_PATH_LITERAL("drive/Directory 1/new file.foo")), 1812 base::FilePath(FILE_PATH_LITERAL("drive/Directory 1/new file.foo")),
1795 upload_location, 1813 upload_location,
1796 0, 13, 15, "test/foo", 1814 0, contents.size() / 2, contents.size(), "test/foo",
1797 base::FilePath(), 1815 local_file_path,
1798 test_util::CreateCopyResultCallback(&response, &entry), 1816 test_util::CreateCopyResultCallback(&response, &entry),
1799 base::Bind(&test_util::AppendProgressCallbackResult, 1817 base::Bind(&test_util::AppendProgressCallbackResult,
1800 &upload_progress_values)); 1818 &upload_progress_values));
1801 base::RunLoop().RunUntilIdle(); 1819 base::RunLoop().RunUntilIdle();
1802 1820
1803 EXPECT_EQ(HTTP_RESUME_INCOMPLETE, response.code); 1821 EXPECT_EQ(HTTP_RESUME_INCOMPLETE, response.code);
1804 EXPECT_FALSE(entry.get()); 1822 EXPECT_FALSE(entry.get());
1805 ASSERT_TRUE(!upload_progress_values.empty()); 1823 ASSERT_TRUE(!upload_progress_values.empty());
1806 EXPECT_TRUE(base::STLIsSorted(upload_progress_values)); 1824 EXPECT_TRUE(base::STLIsSorted(upload_progress_values));
1807 EXPECT_LE(0, upload_progress_values.front().first); 1825 EXPECT_LE(0, upload_progress_values.front().first);
1808 EXPECT_GE(13, upload_progress_values.back().first); 1826 EXPECT_GE(static_cast<int64>(contents.size() / 2),
1827 upload_progress_values.back().first);
1809 1828
1810 upload_progress_values.clear(); 1829 upload_progress_values.clear();
1811 fake_service_.ResumeUpload( 1830 fake_service_.ResumeUpload(
1812 base::FilePath(FILE_PATH_LITERAL("drive/Directory 1/new file.foo")), 1831 base::FilePath(FILE_PATH_LITERAL("drive/Directory 1/new file.foo")),
1813 upload_location, 1832 upload_location,
1814 13, 15, 15, "test/foo", 1833 contents.size() / 2, contents.size(), contents.size(), "test/foo",
1815 base::FilePath(), 1834 local_file_path,
1816 test_util::CreateCopyResultCallback(&response, &entry), 1835 test_util::CreateCopyResultCallback(&response, &entry),
1817 base::Bind(&test_util::AppendProgressCallbackResult, 1836 base::Bind(&test_util::AppendProgressCallbackResult,
1818 &upload_progress_values)); 1837 &upload_progress_values));
1819 base::RunLoop().RunUntilIdle(); 1838 base::RunLoop().RunUntilIdle();
1820 1839
1821 EXPECT_EQ(HTTP_CREATED, response.code); 1840 EXPECT_EQ(HTTP_CREATED, response.code);
1822 EXPECT_TRUE(entry.get()); 1841 EXPECT_TRUE(entry.get());
1823 EXPECT_EQ(15L, entry->file_size()); 1842 EXPECT_EQ(static_cast<int64>(contents.size()), entry->file_size());
1824 EXPECT_TRUE(Exists(entry->resource_id())); 1843 EXPECT_TRUE(Exists(entry->resource_id()));
1825 ASSERT_TRUE(!upload_progress_values.empty()); 1844 ASSERT_TRUE(!upload_progress_values.empty());
1826 EXPECT_TRUE(base::STLIsSorted(upload_progress_values)); 1845 EXPECT_TRUE(base::STLIsSorted(upload_progress_values));
1827 EXPECT_LE(0, upload_progress_values.front().first); 1846 EXPECT_LE(0, upload_progress_values.front().first);
1828 EXPECT_GE(2, upload_progress_values.back().first); 1847 EXPECT_GE(static_cast<int64>(contents.size() - contents.size() / 2),
1848 upload_progress_values.back().first);
1849 EXPECT_EQ(base::MD5String(contents), entry->file_md5());
1829 } 1850 }
1830 1851
1831 TEST_F(FakeDriveServiceTest, AddNewFile_ToRootDirectory) { 1852 TEST_F(FakeDriveServiceTest, AddNewFile_ToRootDirectory) {
1832 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( 1853 ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
1833 "chromeos/gdata/root_feed.json")); 1854 "chromeos/gdata/root_feed.json"));
1834 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi( 1855 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi(
1835 "chromeos/gdata/account_metadata.json")); 1856 "chromeos/gdata/account_metadata.json"));
1836 1857
1837 int64 old_largest_change_id = GetLargestChangeByAboutResource(); 1858 int64 old_largest_change_id = GetLargestChangeByAboutResource();
1838 1859
(...skipping 18 matching lines...) Expand all
1857 EXPECT_EQ(kContentType, resource_entry->content_mime_type()); 1878 EXPECT_EQ(kContentType, resource_entry->content_mime_type());
1858 EXPECT_EQ(static_cast<int64>(kContentData.size()), 1879 EXPECT_EQ(static_cast<int64>(kContentData.size()),
1859 resource_entry->file_size()); 1880 resource_entry->file_size());
1860 EXPECT_EQ("resource_id_1", resource_entry->resource_id()); 1881 EXPECT_EQ("resource_id_1", resource_entry->resource_id());
1861 EXPECT_EQ(kTitle, resource_entry->title()); 1882 EXPECT_EQ(kTitle, resource_entry->title());
1862 EXPECT_TRUE(HasParent(resource_entry->resource_id(), 1883 EXPECT_TRUE(HasParent(resource_entry->resource_id(),
1863 fake_service_.GetRootResourceId())); 1884 fake_service_.GetRootResourceId()));
1864 // Should be incremented as a new directory was created. 1885 // Should be incremented as a new directory was created.
1865 EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp()); 1886 EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp());
1866 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); 1887 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource());
1888 EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5());
1867 } 1889 }
1868 1890
1869 TEST_F(FakeDriveServiceTest, AddNewFile_ToRootDirectoryOnEmptyFileSystem) { 1891 TEST_F(FakeDriveServiceTest, AddNewFile_ToRootDirectoryOnEmptyFileSystem) {
1870 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( 1892 ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
1871 "chromeos/gdata/empty_feed.json")); 1893 "chromeos/gdata/empty_feed.json"));
1872 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi( 1894 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi(
1873 "chromeos/gdata/account_metadata.json")); 1895 "chromeos/gdata/account_metadata.json"));
1874 1896
1875 int64 old_largest_change_id = GetLargestChangeByAboutResource(); 1897 int64 old_largest_change_id = GetLargestChangeByAboutResource();
1876 1898
(...skipping 18 matching lines...) Expand all
1895 EXPECT_EQ(kContentType, resource_entry->content_mime_type()); 1917 EXPECT_EQ(kContentType, resource_entry->content_mime_type());
1896 EXPECT_EQ(static_cast<int64>(kContentData.size()), 1918 EXPECT_EQ(static_cast<int64>(kContentData.size()),
1897 resource_entry->file_size()); 1919 resource_entry->file_size());
1898 EXPECT_EQ("resource_id_1", resource_entry->resource_id()); 1920 EXPECT_EQ("resource_id_1", resource_entry->resource_id());
1899 EXPECT_EQ(kTitle, resource_entry->title()); 1921 EXPECT_EQ(kTitle, resource_entry->title());
1900 EXPECT_TRUE(HasParent(resource_entry->resource_id(), 1922 EXPECT_TRUE(HasParent(resource_entry->resource_id(),
1901 fake_service_.GetRootResourceId())); 1923 fake_service_.GetRootResourceId()));
1902 // Should be incremented as a new directory was created. 1924 // Should be incremented as a new directory was created.
1903 EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp()); 1925 EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp());
1904 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); 1926 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource());
1927 EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5());
1905 } 1928 }
1906 1929
1907 TEST_F(FakeDriveServiceTest, AddNewFile_ToNonRootDirectory) { 1930 TEST_F(FakeDriveServiceTest, AddNewFile_ToNonRootDirectory) {
1908 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( 1931 ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
1909 "chromeos/gdata/root_feed.json")); 1932 "chromeos/gdata/root_feed.json"));
1910 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi( 1933 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi(
1911 "chromeos/gdata/account_metadata.json")); 1934 "chromeos/gdata/account_metadata.json"));
1912 1935
1913 int64 old_largest_change_id = GetLargestChangeByAboutResource(); 1936 int64 old_largest_change_id = GetLargestChangeByAboutResource();
1914 1937
(...skipping 18 matching lines...) Expand all
1933 EXPECT_TRUE(resource_entry->is_file()); 1956 EXPECT_TRUE(resource_entry->is_file());
1934 EXPECT_EQ(kContentType, resource_entry->content_mime_type()); 1957 EXPECT_EQ(kContentType, resource_entry->content_mime_type());
1935 EXPECT_EQ(static_cast<int64>(kContentData.size()), 1958 EXPECT_EQ(static_cast<int64>(kContentData.size()),
1936 resource_entry->file_size()); 1959 resource_entry->file_size());
1937 EXPECT_EQ("resource_id_1", resource_entry->resource_id()); 1960 EXPECT_EQ("resource_id_1", resource_entry->resource_id());
1938 EXPECT_EQ(kTitle, resource_entry->title()); 1961 EXPECT_EQ(kTitle, resource_entry->title());
1939 EXPECT_TRUE(HasParent(resource_entry->resource_id(), kParentResourceId)); 1962 EXPECT_TRUE(HasParent(resource_entry->resource_id(), kParentResourceId));
1940 // Should be incremented as a new directory was created. 1963 // Should be incremented as a new directory was created.
1941 EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp()); 1964 EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp());
1942 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); 1965 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource());
1966 EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5());
1943 } 1967 }
1944 1968
1945 TEST_F(FakeDriveServiceTest, AddNewFile_ToNonexistingDirectory) { 1969 TEST_F(FakeDriveServiceTest, AddNewFile_ToNonexistingDirectory) {
1946 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( 1970 ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
1947 "chromeos/gdata/root_feed.json")); 1971 "chromeos/gdata/root_feed.json"));
1948 1972
1949 const std::string kContentType = "text/plain"; 1973 const std::string kContentType = "text/plain";
1950 const std::string kContentData = "This is some test content."; 1974 const std::string kContentData = "This is some test content.";
1951 const std::string kTitle = "new file"; 1975 const std::string kTitle = "new file";
1952 const std::string kParentResourceId = "folder:nonexisting_resource_id"; 1976 const std::string kParentResourceId = "folder:nonexisting_resource_id";
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2021 resource_entry->file_size()); 2045 resource_entry->file_size());
2022 EXPECT_EQ("resource_id_1", resource_entry->resource_id()); 2046 EXPECT_EQ("resource_id_1", resource_entry->resource_id());
2023 EXPECT_EQ(kTitle, resource_entry->title()); 2047 EXPECT_EQ(kTitle, resource_entry->title());
2024 EXPECT_TRUE(HasParent(resource_entry->resource_id(), 2048 EXPECT_TRUE(HasParent(resource_entry->resource_id(),
2025 fake_service_.GetRootResourceId())); 2049 fake_service_.GetRootResourceId()));
2026 ASSERT_EQ(1U, resource_entry->labels().size()); 2050 ASSERT_EQ(1U, resource_entry->labels().size());
2027 EXPECT_EQ("shared-with-me", resource_entry->labels()[0]); 2051 EXPECT_EQ("shared-with-me", resource_entry->labels()[0]);
2028 // Should be incremented as a new directory was created. 2052 // Should be incremented as a new directory was created.
2029 EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp()); 2053 EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp());
2030 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); 2054 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource());
2055 EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5());
2031 } 2056 }
2032 2057
2033 TEST_F(FakeDriveServiceTest, SetLastModifiedTime_ExistingFile) { 2058 TEST_F(FakeDriveServiceTest, SetLastModifiedTime_ExistingFile) {
2034 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( 2059 ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
2035 "chromeos/gdata/root_feed.json")); 2060 "chromeos/gdata/root_feed.json"));
2036 2061
2037 const std::string kResourceId = "file:2_file_resource_id"; 2062 const std::string kResourceId = "file:2_file_resource_id";
2038 base::Time time; 2063 base::Time time;
2039 ASSERT_TRUE(base::Time::FromString("1 April 2013 12:34:56", &time)); 2064 ASSERT_TRUE(base::Time::FromString("1 April 2013 12:34:56", &time));
2040 2065
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2088 test_util::CreateCopyResultCallback(&error, &resource_entry)); 2113 test_util::CreateCopyResultCallback(&error, &resource_entry));
2089 base::RunLoop().RunUntilIdle(); 2114 base::RunLoop().RunUntilIdle();
2090 2115
2091 EXPECT_EQ(GDATA_NO_CONNECTION, error); 2116 EXPECT_EQ(GDATA_NO_CONNECTION, error);
2092 EXPECT_FALSE(resource_entry); 2117 EXPECT_FALSE(resource_entry);
2093 } 2118 }
2094 2119
2095 } // namespace 2120 } // namespace
2096 2121
2097 } // namespace drive 2122 } // namespace drive
OLDNEW
« chrome/browser/drive/fake_drive_service.cc ('K') | « chrome/browser/drive/fake_drive_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698