| OLD | NEW |
| (Empty) |
| 1 // Copyright 2010 Google Inc. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 // ======================================================================== | |
| 15 | |
| 16 // This unit test is driving the UI through its states so that we can | |
| 17 // visually inspect all the controls are there in their right state and | |
| 18 // position. To go from state to state, simply close the window on the screen. | |
| 19 // | |
| 20 // The unit test is useful for debugging UI states so different tests are | |
| 21 // enabled/disabled at compile time, depending what needs to be tested. | |
| 22 | |
| 23 #include <windows.h> | |
| 24 #include "omaha/base/app_util.h" | |
| 25 #include "omaha/base/scoped_any.h" | |
| 26 #include "omaha/base/utils.h" | |
| 27 #include "omaha/goopdate/resource_manager.h" | |
| 28 #include "omaha/testing/unit_test.h" | |
| 29 #include "omaha/ui/splash_screen.h" | |
| 30 | |
| 31 namespace omaha { | |
| 32 | |
| 33 class SplashScreenTest : public testing::Test { | |
| 34 protected: | |
| 35 SplashScreenTest() {} | |
| 36 | |
| 37 static void SetUpTestCase() { | |
| 38 CString resource_dir = app_util::GetModuleDirectory(NULL); | |
| 39 EXPECT_HRESULT_SUCCEEDED( | |
| 40 ResourceManager::Create(false, resource_dir, _T("en"))); | |
| 41 } | |
| 42 static void TearDownTestCase() { | |
| 43 ResourceManager::Delete(); | |
| 44 } | |
| 45 | |
| 46 static void PostCloseMessage(const SplashScreen& splash_screen) { | |
| 47 ASSERT_TRUE(splash_screen.IsWindow()); | |
| 48 ::PostMessage(splash_screen.m_hWnd, WM_CLOSE, 0, 0); | |
| 49 } | |
| 50 }; | |
| 51 | |
| 52 TEST_F(SplashScreenTest, SplashScreen) { | |
| 53 SplashScreen splash_screen(NULL); | |
| 54 splash_screen.Show(); | |
| 55 ::Sleep(200); | |
| 56 splash_screen.Dismiss(); | |
| 57 } | |
| 58 | |
| 59 TEST_F(SplashScreenTest, SplashScreen_QuickRelease) { | |
| 60 SplashScreen splash_screen(_T("Sample bundle")); | |
| 61 splash_screen.Show(); | |
| 62 splash_screen.Dismiss(); | |
| 63 } | |
| 64 | |
| 65 TEST_F(SplashScreenTest, SplashScreen_NoShow) { | |
| 66 SplashScreen splash_screen(_T("You Should Not See This")); | |
| 67 } | |
| 68 | |
| 69 TEST_F(SplashScreenTest, SplashScreen_PostCloseMessage) { | |
| 70 SplashScreen splash_screen(NULL); | |
| 71 splash_screen.Show(); | |
| 72 ::Sleep(100); | |
| 73 SplashScreenTest::PostCloseMessage(splash_screen); | |
| 74 ::Sleep(100); | |
| 75 splash_screen.Dismiss(); | |
| 76 } | |
| 77 | |
| 78 } // namespace omaha | |
| 79 | |
| OLD | NEW |