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

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: drop unused line 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
« no previous file with comments | « chrome/browser/drive/fake_drive_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 GURL upload_location; 1620 GURL upload_location;
1620 fake_service_.InitiateUploadExistingFile( 1621 fake_service_.InitiateUploadExistingFile(
1621 "text/plain", 1622 "text/plain",
1622 13, 1623 13,
1623 "file:2_file_resource_id", 1624 "file:2_file_resource_id",
1624 "\"HhMOFgxXHit7ImBr\"", 1625 "\"HhMOFgxXHit7ImBr\"",
1625 test_util::CreateCopyResultCallback(&error, &upload_location)); 1626 test_util::CreateCopyResultCallback(&error, &upload_location));
1626 base::RunLoop().RunUntilIdle(); 1627 base::RunLoop().RunUntilIdle();
1627 1628
1628 EXPECT_EQ(HTTP_SUCCESS, error); 1629 EXPECT_EQ(HTTP_SUCCESS, error);
1629 EXPECT_EQ(GURL("https://2_file_link_resumable_create_media?mode=existing"), 1630 EXPECT_TRUE(upload_location.is_valid());
1630 upload_location);
1631 } 1631 }
1632 1632
1633 TEST_F(FakeDriveServiceTest, ResumeUpload_Offline) { 1633 TEST_F(FakeDriveServiceTest, ResumeUpload_Offline) {
1634 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( 1634 ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
1635 "chromeos/gdata/root_feed.json")); 1635 "chromeos/gdata/root_feed.json"));
1636 1636
1637 GDataErrorCode error = GDATA_OTHER_ERROR; 1637 GDataErrorCode error = GDATA_OTHER_ERROR;
1638 GURL upload_location; 1638 GURL upload_location;
1639 fake_service_.InitiateUploadNewFile( 1639 fake_service_.InitiateUploadNewFile(
1640 "test/foo", 1640 "test/foo",
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 base::FilePath(), 1689 base::FilePath(),
1690 test_util::CreateCopyResultCallback(&response, &entry), 1690 test_util::CreateCopyResultCallback(&response, &entry),
1691 ProgressCallback()); 1691 ProgressCallback());
1692 base::RunLoop().RunUntilIdle(); 1692 base::RunLoop().RunUntilIdle();
1693 1693
1694 EXPECT_EQ(HTTP_NOT_FOUND, response.code); 1694 EXPECT_EQ(HTTP_NOT_FOUND, response.code);
1695 EXPECT_FALSE(entry.get()); 1695 EXPECT_FALSE(entry.get());
1696 } 1696 }
1697 1697
1698 TEST_F(FakeDriveServiceTest, ResumeUpload_ExistingFile) { 1698 TEST_F(FakeDriveServiceTest, ResumeUpload_ExistingFile) {
1699 base::ScopedTempDir temp_dir;
1700 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
1701 base::FilePath local_file_path =
1702 temp_dir.path().Append(FILE_PATH_LITERAL("File 1.txt"));
1703 std::string contents("hogefugapiyo");
1704 ASSERT_TRUE(test_util::WriteStringToFile(local_file_path, contents));
1705
1699 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( 1706 ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
1700 "chromeos/gdata/root_feed.json")); 1707 "chromeos/gdata/root_feed.json"));
1701 1708
1702 GDataErrorCode error = GDATA_OTHER_ERROR; 1709 GDataErrorCode error = GDATA_OTHER_ERROR;
1703 GURL upload_location; 1710 GURL upload_location;
1704 fake_service_.InitiateUploadExistingFile( 1711 fake_service_.InitiateUploadExistingFile(
1705 "text/plain", 1712 "text/plain",
1706 15, 1713 contents.size(),
1707 "file:2_file_resource_id", 1714 "file:2_file_resource_id",
1708 "\"HhMOFgxXHit7ImBr\"", 1715 "\"HhMOFgxXHit7ImBr\"",
1709 test_util::CreateCopyResultCallback(&error, &upload_location)); 1716 test_util::CreateCopyResultCallback(&error, &upload_location));
1710 base::RunLoop().RunUntilIdle(); 1717 base::RunLoop().RunUntilIdle();
1711 1718
1712 ASSERT_EQ(HTTP_SUCCESS, error); 1719 ASSERT_EQ(HTTP_SUCCESS, error);
1713 1720
1714 UploadRangeResponse response; 1721 UploadRangeResponse response;
1715 scoped_ptr<ResourceEntry> entry; 1722 scoped_ptr<ResourceEntry> entry;
1716 std::vector<test_util::ProgressInfo> upload_progress_values; 1723 std::vector<test_util::ProgressInfo> upload_progress_values;
1717 fake_service_.ResumeUpload( 1724 fake_service_.ResumeUpload(
1718 upload_location, 1725 upload_location,
1719 0, 13, 15, "text/plain", 1726 0, contents.size() / 2, contents.size(), "text/plain",
1720 base::FilePath(), 1727 local_file_path,
1721 test_util::CreateCopyResultCallback(&response, &entry), 1728 test_util::CreateCopyResultCallback(&response, &entry),
1722 base::Bind(&test_util::AppendProgressCallbackResult, 1729 base::Bind(&test_util::AppendProgressCallbackResult,
1723 &upload_progress_values)); 1730 &upload_progress_values));
1724 base::RunLoop().RunUntilIdle(); 1731 base::RunLoop().RunUntilIdle();
1725 1732
1726 EXPECT_EQ(HTTP_RESUME_INCOMPLETE, response.code); 1733 EXPECT_EQ(HTTP_RESUME_INCOMPLETE, response.code);
1727 EXPECT_FALSE(entry.get()); 1734 EXPECT_FALSE(entry.get());
1728 ASSERT_TRUE(!upload_progress_values.empty()); 1735 ASSERT_TRUE(!upload_progress_values.empty());
1729 EXPECT_TRUE(base::STLIsSorted(upload_progress_values)); 1736 EXPECT_TRUE(base::STLIsSorted(upload_progress_values));
1730 EXPECT_LE(0, upload_progress_values.front().first); 1737 EXPECT_LE(0, upload_progress_values.front().first);
1731 EXPECT_GE(13, upload_progress_values.back().first); 1738 EXPECT_GE(static_cast<int64>(contents.size() / 2),
1739 upload_progress_values.back().first);
1732 1740
1733 upload_progress_values.clear(); 1741 upload_progress_values.clear();
1734 fake_service_.ResumeUpload( 1742 fake_service_.ResumeUpload(
1735 upload_location, 1743 upload_location,
1736 13, 15, 15, "text/plain", 1744 contents.size() / 2, contents.size(), contents.size(), "text/plain",
1737 base::FilePath(), 1745 local_file_path,
1738 test_util::CreateCopyResultCallback(&response, &entry), 1746 test_util::CreateCopyResultCallback(&response, &entry),
1739 base::Bind(&test_util::AppendProgressCallbackResult, 1747 base::Bind(&test_util::AppendProgressCallbackResult,
1740 &upload_progress_values)); 1748 &upload_progress_values));
1741 base::RunLoop().RunUntilIdle(); 1749 base::RunLoop().RunUntilIdle();
1742 1750
1743 EXPECT_EQ(HTTP_SUCCESS, response.code); 1751 EXPECT_EQ(HTTP_SUCCESS, response.code);
1744 EXPECT_TRUE(entry.get()); 1752 EXPECT_TRUE(entry.get());
1745 EXPECT_EQ(15L, entry->file_size()); 1753 EXPECT_EQ(static_cast<int64>(contents.size()),
1754 entry->file_size());
1746 EXPECT_TRUE(Exists(entry->resource_id())); 1755 EXPECT_TRUE(Exists(entry->resource_id()));
1747 ASSERT_TRUE(!upload_progress_values.empty()); 1756 ASSERT_TRUE(!upload_progress_values.empty());
1748 EXPECT_TRUE(base::STLIsSorted(upload_progress_values)); 1757 EXPECT_TRUE(base::STLIsSorted(upload_progress_values));
1749 EXPECT_LE(0, upload_progress_values.front().first); 1758 EXPECT_LE(0, upload_progress_values.front().first);
1750 EXPECT_GE(2, upload_progress_values.back().first); 1759 EXPECT_GE(static_cast<int64>(contents.size() - contents.size() / 2),
1760 upload_progress_values.back().first);
1761 EXPECT_EQ(base::MD5String(contents), entry->file_md5());
1751 } 1762 }
1752 1763
1753 TEST_F(FakeDriveServiceTest, ResumeUpload_NewFile) { 1764 TEST_F(FakeDriveServiceTest, ResumeUpload_NewFile) {
1765 base::ScopedTempDir temp_dir;
1766 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
1767 base::FilePath local_file_path =
1768 temp_dir.path().Append(FILE_PATH_LITERAL("new file.foo"));
1769 std::string contents("hogefugapiyo");
1770 ASSERT_TRUE(test_util::WriteStringToFile(local_file_path, contents));
1771
1754 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( 1772 ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
1755 "chromeos/gdata/root_feed.json")); 1773 "chromeos/gdata/root_feed.json"));
1756 1774
1757 GDataErrorCode error = GDATA_OTHER_ERROR; 1775 GDataErrorCode error = GDATA_OTHER_ERROR;
1758 GURL upload_location; 1776 GURL upload_location;
1759 fake_service_.InitiateUploadNewFile( 1777 fake_service_.InitiateUploadNewFile(
1760 "test/foo", 1778 "test/foo",
1761 15, 1779 contents.size(),
1762 "folder:1_folder_resource_id", 1780 "folder:1_folder_resource_id",
1763 "new file.foo", 1781 "new file.foo",
1764 test_util::CreateCopyResultCallback(&error, &upload_location)); 1782 test_util::CreateCopyResultCallback(&error, &upload_location));
1765 base::RunLoop().RunUntilIdle(); 1783 base::RunLoop().RunUntilIdle();
1766 1784
1767 EXPECT_EQ(HTTP_SUCCESS, error); 1785 EXPECT_EQ(HTTP_SUCCESS, error);
1768 EXPECT_FALSE(upload_location.is_empty()); 1786 EXPECT_FALSE(upload_location.is_empty());
1769 EXPECT_NE(GURL("https://1_folder_resumable_create_media_link"), 1787 EXPECT_NE(GURL("https://1_folder_resumable_create_media_link"),
1770 upload_location); 1788 upload_location);
1771 1789
1772 UploadRangeResponse response; 1790 UploadRangeResponse response;
1773 scoped_ptr<ResourceEntry> entry; 1791 scoped_ptr<ResourceEntry> entry;
1774 std::vector<test_util::ProgressInfo> upload_progress_values; 1792 std::vector<test_util::ProgressInfo> upload_progress_values;
1775 fake_service_.ResumeUpload( 1793 fake_service_.ResumeUpload(
1776 upload_location, 1794 upload_location,
1777 0, 13, 15, "test/foo", 1795 0, contents.size() / 2, contents.size(), "test/foo",
1778 base::FilePath(), 1796 local_file_path,
1779 test_util::CreateCopyResultCallback(&response, &entry), 1797 test_util::CreateCopyResultCallback(&response, &entry),
1780 base::Bind(&test_util::AppendProgressCallbackResult, 1798 base::Bind(&test_util::AppendProgressCallbackResult,
1781 &upload_progress_values)); 1799 &upload_progress_values));
1782 base::RunLoop().RunUntilIdle(); 1800 base::RunLoop().RunUntilIdle();
1783 1801
1784 EXPECT_EQ(HTTP_RESUME_INCOMPLETE, response.code); 1802 EXPECT_EQ(HTTP_RESUME_INCOMPLETE, response.code);
1785 EXPECT_FALSE(entry.get()); 1803 EXPECT_FALSE(entry.get());
1786 ASSERT_TRUE(!upload_progress_values.empty()); 1804 ASSERT_TRUE(!upload_progress_values.empty());
1787 EXPECT_TRUE(base::STLIsSorted(upload_progress_values)); 1805 EXPECT_TRUE(base::STLIsSorted(upload_progress_values));
1788 EXPECT_LE(0, upload_progress_values.front().first); 1806 EXPECT_LE(0, upload_progress_values.front().first);
1789 EXPECT_GE(13, upload_progress_values.back().first); 1807 EXPECT_GE(static_cast<int64>(contents.size() / 2),
1808 upload_progress_values.back().first);
1790 1809
1791 upload_progress_values.clear(); 1810 upload_progress_values.clear();
1792 fake_service_.ResumeUpload( 1811 fake_service_.ResumeUpload(
1793 upload_location, 1812 upload_location,
1794 13, 15, 15, "test/foo", 1813 contents.size() / 2, contents.size(), contents.size(), "test/foo",
1795 base::FilePath(), 1814 local_file_path,
1796 test_util::CreateCopyResultCallback(&response, &entry), 1815 test_util::CreateCopyResultCallback(&response, &entry),
1797 base::Bind(&test_util::AppendProgressCallbackResult, 1816 base::Bind(&test_util::AppendProgressCallbackResult,
1798 &upload_progress_values)); 1817 &upload_progress_values));
1799 base::RunLoop().RunUntilIdle(); 1818 base::RunLoop().RunUntilIdle();
1800 1819
1801 EXPECT_EQ(HTTP_CREATED, response.code); 1820 EXPECT_EQ(HTTP_CREATED, response.code);
1802 EXPECT_TRUE(entry.get()); 1821 EXPECT_TRUE(entry.get());
1803 EXPECT_EQ(15L, entry->file_size()); 1822 EXPECT_EQ(static_cast<int64>(contents.size()), entry->file_size());
1804 EXPECT_TRUE(Exists(entry->resource_id())); 1823 EXPECT_TRUE(Exists(entry->resource_id()));
1805 ASSERT_TRUE(!upload_progress_values.empty()); 1824 ASSERT_TRUE(!upload_progress_values.empty());
1806 EXPECT_TRUE(base::STLIsSorted(upload_progress_values)); 1825 EXPECT_TRUE(base::STLIsSorted(upload_progress_values));
1807 EXPECT_LE(0, upload_progress_values.front().first); 1826 EXPECT_LE(0, upload_progress_values.front().first);
1808 EXPECT_GE(2, upload_progress_values.back().first); 1827 EXPECT_GE(static_cast<int64>(contents.size() - contents.size() / 2),
1828 upload_progress_values.back().first);
1829 EXPECT_EQ(base::MD5String(contents), entry->file_md5());
1809 } 1830 }
1810 1831
1811 TEST_F(FakeDriveServiceTest, AddNewFile_ToRootDirectory) { 1832 TEST_F(FakeDriveServiceTest, AddNewFile_ToRootDirectory) {
1812 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( 1833 ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
1813 "chromeos/gdata/root_feed.json")); 1834 "chromeos/gdata/root_feed.json"));
1814 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi( 1835 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi(
1815 "chromeos/gdata/account_metadata.json")); 1836 "chromeos/gdata/account_metadata.json"));
1816 1837
1817 int64 old_largest_change_id = GetLargestChangeByAboutResource(); 1838 int64 old_largest_change_id = GetLargestChangeByAboutResource();
1818 1839
(...skipping 18 matching lines...) Expand all
1837 EXPECT_EQ(kContentType, resource_entry->content_mime_type()); 1858 EXPECT_EQ(kContentType, resource_entry->content_mime_type());
1838 EXPECT_EQ(static_cast<int64>(kContentData.size()), 1859 EXPECT_EQ(static_cast<int64>(kContentData.size()),
1839 resource_entry->file_size()); 1860 resource_entry->file_size());
1840 EXPECT_EQ("resource_id_1", resource_entry->resource_id()); 1861 EXPECT_EQ("resource_id_1", resource_entry->resource_id());
1841 EXPECT_EQ(kTitle, resource_entry->title()); 1862 EXPECT_EQ(kTitle, resource_entry->title());
1842 EXPECT_TRUE(HasParent(resource_entry->resource_id(), 1863 EXPECT_TRUE(HasParent(resource_entry->resource_id(),
1843 fake_service_.GetRootResourceId())); 1864 fake_service_.GetRootResourceId()));
1844 // Should be incremented as a new directory was created. 1865 // Should be incremented as a new directory was created.
1845 EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp()); 1866 EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp());
1846 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); 1867 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource());
1868 EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5());
1847 } 1869 }
1848 1870
1849 TEST_F(FakeDriveServiceTest, AddNewFile_ToRootDirectoryOnEmptyFileSystem) { 1871 TEST_F(FakeDriveServiceTest, AddNewFile_ToRootDirectoryOnEmptyFileSystem) {
1850 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( 1872 ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
1851 "chromeos/gdata/empty_feed.json")); 1873 "chromeos/gdata/empty_feed.json"));
1852 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi( 1874 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi(
1853 "chromeos/gdata/account_metadata.json")); 1875 "chromeos/gdata/account_metadata.json"));
1854 1876
1855 int64 old_largest_change_id = GetLargestChangeByAboutResource(); 1877 int64 old_largest_change_id = GetLargestChangeByAboutResource();
1856 1878
(...skipping 18 matching lines...) Expand all
1875 EXPECT_EQ(kContentType, resource_entry->content_mime_type()); 1897 EXPECT_EQ(kContentType, resource_entry->content_mime_type());
1876 EXPECT_EQ(static_cast<int64>(kContentData.size()), 1898 EXPECT_EQ(static_cast<int64>(kContentData.size()),
1877 resource_entry->file_size()); 1899 resource_entry->file_size());
1878 EXPECT_EQ("resource_id_1", resource_entry->resource_id()); 1900 EXPECT_EQ("resource_id_1", resource_entry->resource_id());
1879 EXPECT_EQ(kTitle, resource_entry->title()); 1901 EXPECT_EQ(kTitle, resource_entry->title());
1880 EXPECT_TRUE(HasParent(resource_entry->resource_id(), 1902 EXPECT_TRUE(HasParent(resource_entry->resource_id(),
1881 fake_service_.GetRootResourceId())); 1903 fake_service_.GetRootResourceId()));
1882 // Should be incremented as a new directory was created. 1904 // Should be incremented as a new directory was created.
1883 EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp()); 1905 EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp());
1884 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); 1906 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource());
1907 EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5());
1885 } 1908 }
1886 1909
1887 TEST_F(FakeDriveServiceTest, AddNewFile_ToNonRootDirectory) { 1910 TEST_F(FakeDriveServiceTest, AddNewFile_ToNonRootDirectory) {
1888 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( 1911 ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
1889 "chromeos/gdata/root_feed.json")); 1912 "chromeos/gdata/root_feed.json"));
1890 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi( 1913 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi(
1891 "chromeos/gdata/account_metadata.json")); 1914 "chromeos/gdata/account_metadata.json"));
1892 1915
1893 int64 old_largest_change_id = GetLargestChangeByAboutResource(); 1916 int64 old_largest_change_id = GetLargestChangeByAboutResource();
1894 1917
(...skipping 18 matching lines...) Expand all
1913 EXPECT_TRUE(resource_entry->is_file()); 1936 EXPECT_TRUE(resource_entry->is_file());
1914 EXPECT_EQ(kContentType, resource_entry->content_mime_type()); 1937 EXPECT_EQ(kContentType, resource_entry->content_mime_type());
1915 EXPECT_EQ(static_cast<int64>(kContentData.size()), 1938 EXPECT_EQ(static_cast<int64>(kContentData.size()),
1916 resource_entry->file_size()); 1939 resource_entry->file_size());
1917 EXPECT_EQ("resource_id_1", resource_entry->resource_id()); 1940 EXPECT_EQ("resource_id_1", resource_entry->resource_id());
1918 EXPECT_EQ(kTitle, resource_entry->title()); 1941 EXPECT_EQ(kTitle, resource_entry->title());
1919 EXPECT_TRUE(HasParent(resource_entry->resource_id(), kParentResourceId)); 1942 EXPECT_TRUE(HasParent(resource_entry->resource_id(), kParentResourceId));
1920 // Should be incremented as a new directory was created. 1943 // Should be incremented as a new directory was created.
1921 EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp()); 1944 EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp());
1922 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); 1945 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource());
1946 EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5());
1923 } 1947 }
1924 1948
1925 TEST_F(FakeDriveServiceTest, AddNewFile_ToNonexistingDirectory) { 1949 TEST_F(FakeDriveServiceTest, AddNewFile_ToNonexistingDirectory) {
1926 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( 1950 ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
1927 "chromeos/gdata/root_feed.json")); 1951 "chromeos/gdata/root_feed.json"));
1928 1952
1929 const std::string kContentType = "text/plain"; 1953 const std::string kContentType = "text/plain";
1930 const std::string kContentData = "This is some test content."; 1954 const std::string kContentData = "This is some test content.";
1931 const std::string kTitle = "new file"; 1955 const std::string kTitle = "new file";
1932 const std::string kParentResourceId = "folder:nonexisting_resource_id"; 1956 const std::string kParentResourceId = "folder:nonexisting_resource_id";
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2001 resource_entry->file_size()); 2025 resource_entry->file_size());
2002 EXPECT_EQ("resource_id_1", resource_entry->resource_id()); 2026 EXPECT_EQ("resource_id_1", resource_entry->resource_id());
2003 EXPECT_EQ(kTitle, resource_entry->title()); 2027 EXPECT_EQ(kTitle, resource_entry->title());
2004 EXPECT_TRUE(HasParent(resource_entry->resource_id(), 2028 EXPECT_TRUE(HasParent(resource_entry->resource_id(),
2005 fake_service_.GetRootResourceId())); 2029 fake_service_.GetRootResourceId()));
2006 ASSERT_EQ(1U, resource_entry->labels().size()); 2030 ASSERT_EQ(1U, resource_entry->labels().size());
2007 EXPECT_EQ("shared-with-me", resource_entry->labels()[0]); 2031 EXPECT_EQ("shared-with-me", resource_entry->labels()[0]);
2008 // Should be incremented as a new directory was created. 2032 // Should be incremented as a new directory was created.
2009 EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp()); 2033 EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp());
2010 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); 2034 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource());
2035 EXPECT_EQ(base::MD5String(kContentData), resource_entry->file_md5());
2011 } 2036 }
2012 2037
2013 TEST_F(FakeDriveServiceTest, SetLastModifiedTime_ExistingFile) { 2038 TEST_F(FakeDriveServiceTest, SetLastModifiedTime_ExistingFile) {
2014 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( 2039 ASSERT_TRUE(fake_service_.LoadResourceListForWapi(
2015 "chromeos/gdata/root_feed.json")); 2040 "chromeos/gdata/root_feed.json"));
2016 2041
2017 const std::string kResourceId = "file:2_file_resource_id"; 2042 const std::string kResourceId = "file:2_file_resource_id";
2018 base::Time time; 2043 base::Time time;
2019 ASSERT_TRUE(base::Time::FromString("1 April 2013 12:34:56", &time)); 2044 ASSERT_TRUE(base::Time::FromString("1 April 2013 12:34:56", &time));
2020 2045
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2068 test_util::CreateCopyResultCallback(&error, &resource_entry)); 2093 test_util::CreateCopyResultCallback(&error, &resource_entry));
2069 base::RunLoop().RunUntilIdle(); 2094 base::RunLoop().RunUntilIdle();
2070 2095
2071 EXPECT_EQ(GDATA_NO_CONNECTION, error); 2096 EXPECT_EQ(GDATA_NO_CONNECTION, error);
2072 EXPECT_FALSE(resource_entry); 2097 EXPECT_FALSE(resource_entry);
2073 } 2098 }
2074 2099
2075 } // namespace 2100 } // namespace
2076 2101
2077 } // namespace drive 2102 } // namespace drive
OLDNEW
« no previous file with comments | « 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