| OLD | NEW |
| 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 // The tests in this file are chromeos only. | 5 // The tests in this file are chromeos only. |
| 6 | 6 |
| 7 #include "chrome/browser/ui/webui/feedback_ui.h" | 7 #include "chrome/browser/ui/webui/feedback_ui.h" |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 // This macro helps avoid wrapped lines in the test structs. | 13 // This macro helps avoid wrapped lines in the test structs. |
| 14 #define FPL(x) FILE_PATH_LITERAL(x) | 14 #define FPL(x) FILE_PATH_LITERAL(x) |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 // Simple function to create a file with |filename|. | 18 // Simple function to create a file with |filename|. |
| 19 void CreateFile(const FilePath& filename) { | 19 void CreateFile(const FilePath& filename) { |
| 20 FILE* fp = file_util::OpenFile(filename, "w"); | 20 FILE* fp = file_util::OpenFile(filename, "w"); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 38 virtual void SetUp() OVERRIDE { | 38 virtual void SetUp() OVERRIDE { |
| 39 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 39 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 40 } | 40 } |
| 41 protected: | 41 protected: |
| 42 void CreateScreenshotFile(const std::string& timestamp) { | 42 void CreateScreenshotFile(const std::string& timestamp) { |
| 43 FilePath filepath = temp_dir_.path().Append( | 43 FilePath filepath = temp_dir_.path().Append( |
| 44 FILE_PATH_LITERAL(GetScreenshotFilename(timestamp))); | 44 FILE_PATH_LITERAL(GetScreenshotFilename(timestamp))); |
| 45 ASSERT_NO_FATAL_FAILURE(CreateFile(filepath)); | 45 ASSERT_NO_FATAL_FAILURE(CreateFile(filepath)); |
| 46 } | 46 } |
| 47 | 47 |
| 48 ScopedTempDir temp_dir_; | 48 base::ScopedTempDir temp_dir_; |
| 49 std::vector<std::string> saved_screenshots_; | 49 std::vector<std::string> saved_screenshots_; |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 DISALLOW_COPY_AND_ASSIGN(FeedbackUITest); | 52 DISALLOW_COPY_AND_ASSIGN(FeedbackUITest); |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 TEST_F(FeedbackUITest, GetMostRecentScreenshotsNoScreenShot) { | 55 TEST_F(FeedbackUITest, GetMostRecentScreenshotsNoScreenShot) { |
| 56 // Create a random file. | 56 // Create a random file. |
| 57 FilePath filepath = temp_dir_.path().Append(FILE_PATH_LITERAL("garbage.png")); | 57 FilePath filepath = temp_dir_.path().Append(FILE_PATH_LITERAL("garbage.png")); |
| 58 ASSERT_NO_FATAL_FAILURE(CreateFile(filepath)); | 58 ASSERT_NO_FATAL_FAILURE(CreateFile(filepath)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 79 ASSERT_NO_FATAL_FAILURE(CreateScreenshotFile("20120413-152908")); | 79 ASSERT_NO_FATAL_FAILURE(CreateScreenshotFile("20120413-152908")); |
| 80 // Expect getting most recent 2 screenshots. | 80 // Expect getting most recent 2 screenshots. |
| 81 FeedbackUI::GetMostRecentScreenshots( | 81 FeedbackUI::GetMostRecentScreenshots( |
| 82 temp_dir_.path(), &saved_screenshots_, 2); | 82 temp_dir_.path(), &saved_screenshots_, 2); |
| 83 ASSERT_EQ(2U, saved_screenshots_.size()); | 83 ASSERT_EQ(2U, saved_screenshots_.size()); |
| 84 ASSERT_EQ(GetScreenshotUrl("20120416-162908"), saved_screenshots_[0]); | 84 ASSERT_EQ(GetScreenshotUrl("20120416-162908"), saved_screenshots_[0]); |
| 85 ASSERT_EQ(GetScreenshotUrl("20120416-152908"), saved_screenshots_[1]); | 85 ASSERT_EQ(GetScreenshotUrl("20120416-152908"), saved_screenshots_[1]); |
| 86 } | 86 } |
| 87 | 87 |
| 88 } // namespace | 88 } // namespace |
| OLD | NEW |