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

Unified Diff: ash/display/display_error_dialog_unittest.cc

Issue 12212171: Provides more types of errors for output status. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/display/display_error_dialog.cc ('k') | ash/display/output_configurator_animation.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/display_error_dialog_unittest.cc
diff --git a/ash/display/display_error_dialog_unittest.cc b/ash/display/display_error_dialog_unittest.cc
index e4d21d503a58ccc295a46e41c7d03d43f0bd1a03..87a74f6ffabe07a88d7613a5f9b7fb3fcca244be 100644
--- a/ash/display/display_error_dialog_unittest.cc
+++ b/ash/display/display_error_dialog_unittest.cc
@@ -6,39 +6,90 @@
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
+#include "grit/ash_strings.h"
#include "ui/aura/window.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
namespace ash {
namespace internal {
+namespace {
-typedef test::AshTestBase DisplayErrorDialogTest;
+class DisplayErrorDialogTest : public test::AshTestBase {
+ protected:
+ virtual void SetUp() OVERRIDE {
+ test::AshTestBase::SetUp();
+ observer_.reset(new DisplayErrorObserver());
+ }
+
+ virtual void TearDown() OVERRIDE {
+ if (observer_->dialog()) {
+ views::Widget* widget =
+ const_cast<DisplayErrorDialog*>(observer_->dialog())->GetWidget();
+ widget->CloseNow();
+ }
+ observer_.reset();
+ test::AshTestBase::TearDown();
+ }
+
+ DisplayErrorObserver* observer() { return observer_.get(); }
+
+ const string16& GetMessageContents(const DisplayErrorDialog* dialog) {
+ const views::Label* label = static_cast<const views::Label*>(
+ static_cast<const views::View*>(dialog)->child_at(0));
+ return label->text();
+ }
+
+ private:
+ scoped_ptr<DisplayErrorObserver> observer_;
+};
oshima 2013/02/28 23:00:36 DISALLOW_COPY_AND_ASSIGN
Jun Mukai 2013/02/28 23:03:12 Done.
+
+}
// The test cases in this file usually check if the showing dialog doesn't
// cause any crashes, and the code doesn't cause any memory leaks.
TEST_F(DisplayErrorDialogTest, Normal) {
UpdateDisplay("200x200,300x300");
- DisplayErrorDialog::ShowDialog();
- DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest();
+ DisplayErrorDialog* dialog =
+ DisplayErrorDialog::ShowDialog(chromeos::STATE_DUAL_MIRROR);
EXPECT_TRUE(dialog);
EXPECT_TRUE(dialog->GetWidget()->IsVisible());
+ EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING),
+ GetMessageContents(dialog));
EXPECT_EQ(Shell::GetAllRootWindows()[1],
dialog->GetWidget()->GetNativeView()->GetRootWindow());
}
TEST_F(DisplayErrorDialogTest, CallTwice) {
UpdateDisplay("200x200,300x300");
- DisplayErrorDialog::ShowDialog();
- DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest();
+ observer()->OnDisplayModeChangeFailed(chromeos::STATE_DUAL_MIRROR);
+ const DisplayErrorDialog* dialog = observer()->dialog();
EXPECT_TRUE(dialog);
- DisplayErrorDialog::ShowDialog();
- EXPECT_EQ(dialog, DisplayErrorDialog::GetInstanceForTest());
+
+ observer()->OnDisplayModeChangeFailed(chromeos::STATE_DUAL_MIRROR);
+ EXPECT_EQ(dialog, observer()->dialog());
+}
+
+TEST_F(DisplayErrorDialogTest, CallWithDifferentState) {
+ UpdateDisplay("200x200,300x300");
+ observer()->OnDisplayModeChangeFailed(chromeos::STATE_DUAL_MIRROR);
+ const DisplayErrorDialog* dialog = observer()->dialog();
+ EXPECT_TRUE(dialog);
+ EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING),
+ GetMessageContents(dialog));
+
+ observer()->OnDisplayModeChangeFailed(chromeos::STATE_DUAL_EXTENDED);
+ EXPECT_EQ(dialog, observer()->dialog());
+ EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_EXTENDED),
+ GetMessageContents(dialog));
}
TEST_F(DisplayErrorDialogTest, SingleDisplay) {
UpdateDisplay("200x200");
- DisplayErrorDialog::ShowDialog();
- DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest();
+ DisplayErrorDialog* dialog =
+ DisplayErrorDialog::ShowDialog(chromeos::STATE_DUAL_MIRROR);
EXPECT_TRUE(dialog);
EXPECT_TRUE(dialog->GetWidget()->IsVisible());
EXPECT_EQ(Shell::GetInstance()->GetPrimaryRootWindow(),
@@ -47,15 +98,14 @@ TEST_F(DisplayErrorDialogTest, SingleDisplay) {
TEST_F(DisplayErrorDialogTest, DisplayDisconnected) {
UpdateDisplay("200x200,300x300");
- DisplayErrorDialog::ShowDialog();
- DisplayErrorDialog* dialog = DisplayErrorDialog::GetInstanceForTest();
- EXPECT_TRUE(dialog);
+ observer()->OnDisplayModeChangeFailed(chromeos::STATE_DUAL_MIRROR);
+ EXPECT_TRUE(observer()->dialog());
UpdateDisplay("200x200");
// Disconnection will close the dialog but we have to run all pending tasks
// to make the effect of the close.
RunAllPendingInMessageLoop();
- EXPECT_FALSE(DisplayErrorDialog::GetInstanceForTest());
+ EXPECT_FALSE(observer()->dialog());
}
} // namespace internal
« no previous file with comments | « ash/display/display_error_dialog.cc ('k') | ash/display/output_configurator_animation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698