Author: gert
Date: 2007-08-24 15:03:20 -0400 (Fri, 24 Aug 2007)
New Revision: 84817
Added:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FolderBrowserDialogTest.cs
Modified:
trunk/mcs/class/Managed.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FolderBrowserDialog.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/SaveFileDialogTest.cs
Log:
* System.Windows.Forms_test.dll.sources: Added
FolderBrowserDialogTest.cs.
* FolderBrowserDialogTest.cs: Added tests for SelectedPath and
RootFolder.
* SaveFileDialogTest.cs: Renamed class and improved AddExtension test.
* FolderBrowserDialog.cs: Modifies form caption and text of new folder
button to match MS. Provide more meaningful exception message for
invalid RootFolder value. Use zero-length string when SelectedPath
is set to null. Allow non-rooted paths in SelectedPath, but ignore
them in FolderBrowserTreeView. Allow folders to be created in
RootFolder. Fixes bug #82576.
Modified: trunk/mcs/class/Managed.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/ChangeLog 2007-08-24 18:49:55 UTC
(rev 84816)
+++ trunk/mcs/class/Managed.Windows.Forms/ChangeLog 2007-08-24 19:03:20 UTC
(rev 84817)
@@ -1,3 +1,8 @@
+2007-08-24 Gert Driesen <[EMAIL PROTECTED]>
+
+ * System.Windows.Forms_test.dll.sources: Added
+ FolderBrowserDialogTest.cs.
+
2007-08-22 Jonathan Pobst <[EMAIL PROTECTED]>
* System.Windows.Forms.dll.sources: CheckBoxPainter.cs.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-08-24 18:49:55 UTC (rev 84816)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-08-24 19:03:20 UTC (rev 84817)
@@ -1,3 +1,12 @@
+2007-08-24 Gert Driesen <[EMAIL PROTECTED]>
+
+ * FolderBrowserDialog.cs: Modifies form caption and text of new folder
+ button to match MS. Provide more meaningful exception message for
+ invalid RootFolder value. Use zero-length string when SelectedPath
+ is set to null. Allow non-rooted paths in SelectedPath, but ignore
+ them in FolderBrowserTreeView. Allow folders to be created in
+ RootFolder. Fixes bug #82576.
+
2007-08-24 Carlos Alberto Cortez <[EMAIL PROTECTED]>
* ListView.cs: Correctly compute the layout_ht (height) when using
groups,
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FolderBrowserDialog.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FolderBrowserDialog.cs
2007-08-24 18:49:55 UTC (rev 84816)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FolderBrowserDialog.cs
2007-08-24 19:03:20 UTC (rev 84817)
@@ -40,7 +40,7 @@
#region Local Variables
private string description = "";
private Environment.SpecialFolder rootFolder =
Environment.SpecialFolder.Desktop;
- private string selectedPath = "";
+ private string selectedPath = string.Empty;
private bool showNewFolderButton = true;
private Label descriptionLabel;
@@ -93,7 +93,7 @@
form.SuspendLayout ();
form.ClientSize = new Size (322, 324);
form.MinimumSize = new Size (310, 254);
- form.Text = "Search Folder";
+ form.Text = "Browse For Folder";
form.SizeGripStyle = SizeGripStyle.Show;
newFolderMenuItem = new MenuItem("New Folder", new
EventHandler (OnClickNewFolderButton));
@@ -129,13 +129,13 @@
newFolderButton.Location = new Point (15, 285);
newFolderButton.Size = new Size (105, 23);
newFolderButton.TabIndex = 2;
- newFolderButton.Text = "New Folder";
+ newFolderButton.Text = "Make New Folder";
newFolderButton.Enabled = true;
// okButton
okButton.Anchor = ((AnchorStyles)((AnchorStyles.Bottom
| AnchorStyles.Right)));
okButton.FlatStyle = FlatStyle.System;
- okButton.Location = new Point (142, 285);
+ okButton.Location = new Point (135, 285);
okButton.Size = new Size (80, 23);
okButton.TabIndex = 3;
okButton.Text = "OK";
@@ -198,10 +198,12 @@
public Environment.SpecialFolder RootFolder {
set {
int v = (int)value;
+
+ Type enumType = typeof
(Environment.SpecialFolder);
+ if (!Enum.IsDefined (enumType, v))
+ throw new InvalidEnumArgumentException (
+ "value", v, enumType);
- if
(!Enum.IsDefined(typeof(Environment.SpecialFolder), v))
- throw new InvalidEnumArgumentException
();
-
if (rootFolder != value)
rootFolder = value;
@@ -219,9 +221,8 @@
[Localizable(true)]
public string SelectedPath {
set {
- if (!Path.IsPathRooted(value))
- return;
-
+ if (value == null)
+ value = string.Empty;
selectedPath = value;
old_selectedPath = value;
folderBrowserTreeView.SelectedPath =
selectedPath;
@@ -361,6 +362,12 @@
public string SelectedPath {
set {
+ if (value.Length == 0)
+ return;
+
+ if (!Path.IsPathRooted (value))
+ return;
+
if
(Check_if_path_is_child_of_RootFolder (value)) {
SetSelectedPath
(Path.GetFullPath (value));
}
@@ -374,12 +381,9 @@
{
FBTreeNode fbnode = SelectedNode as FBTreeNode;
- if (fbnode == null || fbnode.Parent == null)
+ if (fbnode == null || fbnode.RealPath == null)
return;
- if (fbnode.RealPath == null)
- return;
-
string tmp_filename = "New Folder";
if (Directory.Exists (Path.Combine
(fbnode.RealPath, tmp_filename))) {
@@ -527,7 +531,7 @@
private bool Check_if_path_is_child_of_RootFolder
(string path)
{
- string root_path = (string)root_node.RealPath;
+ string root_path = (string) root_node.RealPath;
if (root_path != null) {
try {
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources
2007-08-24 18:49:55 UTC (rev 84816)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources
2007-08-24 19:03:20 UTC (rev 84817)
@@ -65,6 +65,7 @@
System.Windows.Forms/ErrorProviderTest.cs
System.Windows.Forms/FlowPanelTests.cs
System.Windows.Forms/FocusTest.cs
+System.Windows.Forms/FolderBrowserDialogTest.cs
System.Windows.Forms/FormHandleTest.cs
System.Windows.Forms/FormTest.cs
System.Windows.Forms/EventArgsTest.cs
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2007-08-24 18:49:55 UTC (rev 84816)
+++ trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2007-08-24 19:03:20 UTC (rev 84817)
@@ -1,3 +1,9 @@
+2007-08-24 Gert Driesen <[EMAIL PROTECTED]>
+
+ * FolderBrowserDialogTest.cs: Added tests for SelectedPath and
+ RootFolder.
+ * SaveFileDialogTest.cs: Renamed class and improved AddExtension test.
+
2007-08-24 Carlos Alberto Cortez <[EMAIL PROTECTED]>
* ListViewGroupTest.cs: New assertions for a pair of tests.
Added:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FolderBrowserDialogTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FolderBrowserDialogTest.cs
2007-08-24 18:49:55 UTC (rev 84816)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FolderBrowserDialogTest.cs
2007-08-24 19:03:20 UTC (rev 84817)
@@ -0,0 +1,59 @@
+//
+// FolderBrowserDialogTest.cs: Test cases for FolderBrowserDialog.
+//
+// Author:
+// Gert Driesen ([EMAIL PROTECTED])
+//
+// (C) 2007 Gert Driesen
+//
+
+using System;
+using System.ComponentModel;
+using System.Windows.Forms;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class FolderBrowserDialogTest
+ {
+ [Test]
+ public void SelectedPath ()
+ {
+ FolderBrowserDialog fbd = new FolderBrowserDialog ();
+ Assert.AreEqual (string.Empty, fbd.SelectedPath, "#1");
+ fbd.SelectedPath = null;
+ Assert.AreEqual (string.Empty, fbd.SelectedPath, "#2");
+ fbd.SelectedPath = "{}###()";
+ Assert.AreEqual ("{}###()", fbd.SelectedPath, "#3");
+ }
+
+ [Test]
+ public void RootFolder ()
+ {
+ FolderBrowserDialog fbd = new FolderBrowserDialog ();
+ Assert.AreEqual (Environment.SpecialFolder.Desktop,
fbd.RootFolder, "#1");
+ fbd.RootFolder = Environment.SpecialFolder.Personal;
+ Assert.AreEqual (Environment.SpecialFolder.Personal,
fbd.RootFolder, "#2");
+ }
+
+ [Test]
+ public void RootFolder_Invalid ()
+ {
+ FolderBrowserDialog fbd = new FolderBrowserDialog ();
+ try {
+ fbd.RootFolder = (Environment.SpecialFolder)
666;
+ Assert.Fail ("#1");
+ } catch (InvalidEnumArgumentException ex) {
+ Assert.AreEqual (typeof
(InvalidEnumArgumentException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsTrue (ex.Message.IndexOf ("666") !=
-1, "#5");
+ Assert.IsTrue (ex.Message.IndexOf
("SpecialFolder") != -1, "#6");
+ Assert.IsNotNull (ex.ParamName, "#7");
+ Assert.AreEqual ("value", ex.ParamName, "#8");
+ }
+ }
+ }
+}
Property changes on:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FolderBrowserDialogTest.cs
___________________________________________________________________
Name: svn:eol-style
+ native
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/SaveFileDialogTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/SaveFileDialogTest.cs
2007-08-24 18:49:55 UTC (rev 84816)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/SaveFileDialogTest.cs
2007-08-24 19:03:20 UTC (rev 84817)
@@ -36,7 +36,7 @@
namespace MonoTests.System.Windows.Forms
{
[TestFixture]
- public class SaveDialogTest
+ public class SaveFileDialogTest
{
[Test]
public void AddExtension ()
@@ -249,6 +249,8 @@
Assert.AreEqual (1, sfd.FilterIndex, "#1");
sfd.FilterIndex = 99;
Assert.AreEqual (99, sfd.FilterIndex, "#2");
+ sfd.FilterIndex = -5;
+ Assert.AreEqual (-5, sfd.FilterIndex, "#3");
}
[Test]
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches