| 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/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"); |
| 21 ASSERT_TRUE(fp != NULL); | 21 ASSERT_TRUE(fp != NULL); |
| 22 file_util::CloseFile(fp); | 22 file_util::CloseFile(fp); |
| 23 } | 23 } |
| 24 | 24 |
| 25 std::string GetScreenshotFilename(const std::string timestamp) { | 25 std::string GetScreenshotFilename(const std::string timestamp) { |
| 26 return std::string("Screenshot_") + timestamp + std::string(".png"); | 26 return std::string("Screenshot ") + timestamp + std::string(".png"); |
| 27 } | 27 } |
| 28 | 28 |
| 29 std::string GetScreenshotUrl(const std::string timestamp) { | 29 std::string GetScreenshotUrl(const std::string timestamp) { |
| 30 return std::string("chrome://screenshots/saved/") + | 30 return std::string("chrome://screenshots/saved/") + |
| 31 GetScreenshotFilename(timestamp); | 31 GetScreenshotFilename(timestamp); |
| 32 } | 32 } |
| 33 | 33 |
| 34 class FeedbackUITest : public testing::Test { | 34 class FeedbackUITest : public testing::Test { |
| 35 public: | 35 public: |
| 36 FeedbackUITest() {} | 36 FeedbackUITest() {} |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |