2013-06-24 13:41:48 +02:00
|
|
|
|
/* Copyright (c) Citrix Systems Inc.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms,
|
|
|
|
|
* with or without modification, are permitted provided
|
|
|
|
|
* that the following conditions are met:
|
|
|
|
|
*
|
|
|
|
|
* * Redistributions of source code must retain the above
|
|
|
|
|
* copyright notice, this list of conditions and the
|
|
|
|
|
* following disclaimer.
|
|
|
|
|
* * Redistributions in binary form must reproduce the above
|
|
|
|
|
* copyright notice, this list of conditions and the
|
|
|
|
|
* following disclaimer in the documentation and/or other
|
|
|
|
|
* materials provided with the distribution.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
|
|
|
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
|
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
2013-08-16 13:57:39 +02:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using XenAdmin;
|
2014-04-29 15:23:53 +02:00
|
|
|
|
using XenAdmin.Controls.MainWindowControls;
|
2013-11-23 12:59:49 +01:00
|
|
|
|
using XenAdmin.Core;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
using XenAdmin.TabPages;
|
|
|
|
|
using XenAdmin.Controls;
|
|
|
|
|
using XenAPI;
|
|
|
|
|
|
|
|
|
|
namespace XenAdminTests.TabsAndMenus
|
|
|
|
|
{
|
|
|
|
|
public class LogsTabTests : MainWindowLauncher_TestFixture
|
|
|
|
|
{
|
2013-08-16 13:57:39 +02:00
|
|
|
|
private List<HistoryPage.DataGridViewActionRow> GetVisibleRows()
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2013-08-16 13:57:39 +02:00
|
|
|
|
var rows = new List<HistoryPage.DataGridViewActionRow>();
|
|
|
|
|
MW(() =>
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2013-09-02 18:00:47 +02:00
|
|
|
|
var gridView = TestUtils.GetDataGridView(MainWindowWrapper.Item, "eventsPage.dataGridView");
|
2013-08-16 13:57:39 +02:00
|
|
|
|
foreach (DataGridViewRow row in gridView.Rows)
|
|
|
|
|
{
|
|
|
|
|
var actionRow = row as HistoryPage.DataGridViewActionRow;
|
|
|
|
|
if (actionRow != null)
|
|
|
|
|
rows.Add(actionRow);
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-06-24 13:41:48 +02:00
|
|
|
|
return rows;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-16 13:57:39 +02:00
|
|
|
|
private List<HistoryPage.DataGridViewActionRow> GetUnfinishedRows()
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2013-08-16 13:57:39 +02:00
|
|
|
|
var rows = new List<HistoryPage.DataGridViewActionRow>();
|
|
|
|
|
MW(() =>
|
|
|
|
|
{
|
2013-09-02 18:00:47 +02:00
|
|
|
|
var gridView = TestUtils.GetDataGridView(MainWindowWrapper.Item, "eventsPage.dataGridView");
|
2013-08-16 13:57:39 +02:00
|
|
|
|
|
|
|
|
|
foreach (DataGridViewRow row in gridView.Rows)
|
|
|
|
|
{
|
|
|
|
|
var actionRow = row as HistoryPage.DataGridViewActionRow;
|
|
|
|
|
if (actionRow != null && !actionRow.Action.IsCompleted)
|
|
|
|
|
rows.Add(actionRow);
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-06-24 13:41:48 +02:00
|
|
|
|
return rows;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TearDown]
|
|
|
|
|
public new void TearDown()
|
|
|
|
|
{
|
|
|
|
|
RemoveStateDBs();
|
2013-09-02 18:00:47 +02:00
|
|
|
|
//Events tab
|
2013-06-24 13:41:48 +02:00
|
|
|
|
ConnectionsManager.History.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
|
|
|
|
ConnectToStateDBs("state4.xml");
|
|
|
|
|
MW(delegate
|
|
|
|
|
{
|
|
|
|
|
// deselect all the default templates - to speed up tests.
|
|
|
|
|
if (MainWindowWrapper.ViewMenuItems.TemplatesToolStripMenuItem.Checked)
|
|
|
|
|
{
|
|
|
|
|
MainWindowWrapper.ViewMenuItems.TemplatesToolStripMenuItem.PerformClick();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2013-10-09 14:33:06 +02:00
|
|
|
|
[Ignore]
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public void TestAfterConnection()
|
|
|
|
|
{
|
|
|
|
|
foreach (VirtualTreeNode n in GetAllTreeNodes())
|
|
|
|
|
{
|
|
|
|
|
SelectInTree(n.Tag);
|
|
|
|
|
MW(n.EnsureVisible);
|
|
|
|
|
|
2013-09-02 18:00:47 +02:00
|
|
|
|
//Events tab
|
2013-08-16 13:57:39 +02:00
|
|
|
|
var visibleRows = GetVisibleRows();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2013-08-16 13:57:39 +02:00
|
|
|
|
Assert.AreEqual(1, visibleRows.Count, "No connection item found.");
|
|
|
|
|
Assert.IsTrue(visibleRows[0].Action.GetDetails().StartsWith("Connected to "),
|
|
|
|
|
"Connected message not found. The message was: " + visibleRows[0].Action.GetDetails());
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestHistoryItemsAppearForVMShutdown()
|
|
|
|
|
{
|
|
|
|
|
VM vm1 = GetAnyVM(v => v.name_label == "Iscsi Box");
|
|
|
|
|
VM vm2 = GetAnyVM(v => v.name_label == "Windows Server 2003 x64 (1)");
|
|
|
|
|
|
|
|
|
|
SelectInTree(vm1, vm2);
|
|
|
|
|
|
|
|
|
|
new List<VirtualTreeNode>(MainWindowWrapper.TreeView.SelectedNodes).ForEach(n => MW(n.EnsureVisible));
|
|
|
|
|
|
2013-09-02 18:00:47 +02:00
|
|
|
|
//Events tab
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2013-08-16 13:57:39 +02:00
|
|
|
|
var rows = GetVisibleRows();
|
|
|
|
|
Assert.AreEqual(1, rows.Count, "History page didn't have 1 message before VMs shut down");
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
MW(MainWindowWrapper.MainToolStripItems.ShutDownToolStripButton.PerformClick);
|
|
|
|
|
|
2013-08-16 13:57:39 +02:00
|
|
|
|
rows = GetVisibleRows();
|
|
|
|
|
Assert.AreEqual(4, rows.Count, "Items weren't added when VMs shut down.");
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestClear()
|
|
|
|
|
{
|
|
|
|
|
SelectInTree(GetAnyPool());
|
2013-09-02 18:00:47 +02:00
|
|
|
|
|
|
|
|
|
//Events tab
|
2013-08-16 13:57:39 +02:00
|
|
|
|
var rows = GetVisibleRows();
|
|
|
|
|
Assert.AreEqual(1, rows.Count, "No connection item found.");
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
// wait for everything to finish.
|
2013-08-16 13:57:39 +02:00
|
|
|
|
rows = GetUnfinishedRows();
|
|
|
|
|
Assert.AreEqual(0, rows.Count, "No connection item found.");
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2013-09-02 18:00:47 +02:00
|
|
|
|
MW(() => TestUtils.GetToolStripMenuItem(MainWindowWrapper.Item, "eventsPage.tsmiDismissAll").PerformClick());
|
2013-08-16 13:57:39 +02:00
|
|
|
|
rows = GetVisibleRows();
|
|
|
|
|
Assert.AreEqual(0, rows.Count, "Items weren't cleared.");
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestHide()
|
|
|
|
|
{
|
|
|
|
|
SelectInTree(GetAnyPool());
|
2013-09-02 18:00:47 +02:00
|
|
|
|
//Events tab
|
2013-08-16 13:57:39 +02:00
|
|
|
|
var showAllButton = MW(() => TestUtils.GetToolStripMenuItem(MainWindowWrapper.Item,
|
2013-09-02 18:00:47 +02:00
|
|
|
|
"eventsPage.toolStripDdbFilterStatus.toolStripMenuItemAll"));
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2013-08-16 13:57:39 +02:00
|
|
|
|
var rows = GetVisibleRows();
|
|
|
|
|
Assert.AreEqual(1, rows.Count, "No connection item found.");
|
|
|
|
|
Assert.IsFalse(showAllButton.Enabled);
|
2014-04-29 15:23:53 +02:00
|
|
|
|
MW(() =>
|
|
|
|
|
{
|
|
|
|
|
TestUtils.GetToolStripItem(MainWindowWrapper.Item,
|
|
|
|
|
"navigationPane.buttonNotifySmall").PerformClick();
|
|
|
|
|
TestUtils.GetNotificationsView(MainWindowWrapper.Item,
|
|
|
|
|
"navigationPane.notificationsView").SelectNotificationsSubMode(NotificationsSubMode.Events);
|
|
|
|
|
});
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2013-08-16 13:57:39 +02:00
|
|
|
|
// this should clear all items as they are all completed.
|
|
|
|
|
MW(() => TestUtils.GetToolStripMenuItem(MainWindowWrapper.Item,
|
2014-04-29 15:23:53 +02:00
|
|
|
|
"eventsPage.toolStripDdbFilterStatus.toolStripMenuItemComplete").PerformClick());
|
2013-08-16 13:57:39 +02:00
|
|
|
|
rows = GetVisibleRows();
|
|
|
|
|
Assert.AreEqual(0, rows.Count, "Items weren't cleared.");
|
|
|
|
|
Assert.IsTrue(showAllButton.Enabled);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2013-08-16 13:57:39 +02:00
|
|
|
|
// this should bring them back.
|
|
|
|
|
MW(() => TestUtils.GetToolStripMenuItem(MainWindowWrapper.Item,
|
2013-09-02 18:00:47 +02:00
|
|
|
|
"eventsPage.toolStripDdbFilterStatus.toolStripMenuItemComplete").PerformClick());
|
2013-08-16 13:57:39 +02:00
|
|
|
|
rows = GetVisibleRows();
|
|
|
|
|
Assert.AreEqual(1, rows.Count, "Items were cleared.");
|
|
|
|
|
Assert.IsFalse(showAllButton.Enabled);
|
|
|
|
|
|
|
|
|
|
// nothing should change for cancelled items
|
|
|
|
|
MW(() => TestUtils.GetToolStripMenuItem(MainWindowWrapper.Item,
|
2013-09-02 18:00:47 +02:00
|
|
|
|
"eventsPage.toolStripDdbFilterStatus.toolStripMenuItemCancelled").PerformClick());
|
2013-08-16 13:57:39 +02:00
|
|
|
|
rows = GetVisibleRows();
|
|
|
|
|
Assert.AreEqual(1, rows.Count, "Items were cleared.");
|
|
|
|
|
Assert.IsTrue(showAllButton.Enabled);
|
|
|
|
|
|
|
|
|
|
// nothing should change for failed items
|
|
|
|
|
MW(() => TestUtils.GetToolStripMenuItem(MainWindowWrapper.Item,
|
2013-09-02 18:00:47 +02:00
|
|
|
|
"eventsPage.toolStripDdbFilterStatus.toolStripMenuItemError").PerformClick());
|
2013-08-16 13:57:39 +02:00
|
|
|
|
rows = GetVisibleRows();
|
|
|
|
|
Assert.AreEqual(1, rows.Count, "Items were cleared.");
|
|
|
|
|
Assert.IsTrue(showAllButton.Enabled);
|
|
|
|
|
|
|
|
|
|
// nothing should change for incomplete items
|
|
|
|
|
MW(() => TestUtils.GetToolStripMenuItem(MainWindowWrapper.Item,
|
2013-09-02 18:00:47 +02:00
|
|
|
|
"eventsPage.toolStripDdbFilterStatus.toolStripMenuItemInProgress").PerformClick());
|
2013-08-16 13:57:39 +02:00
|
|
|
|
rows = GetVisibleRows();
|
|
|
|
|
Assert.AreEqual(1, rows.Count, "Items were cleared.");
|
|
|
|
|
Assert.IsTrue(showAllButton.Enabled);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
// put all these back
|
2013-08-16 13:57:39 +02:00
|
|
|
|
MW(() => TestUtils.GetToolStripMenuItem(MainWindowWrapper.Item,
|
2013-09-02 18:00:47 +02:00
|
|
|
|
"eventsPage.toolStripDdbFilterStatus.toolStripMenuItemAll").PerformClick());
|
2013-08-16 13:57:39 +02:00
|
|
|
|
Assert.IsFalse(showAllButton.Enabled);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|