Fix failing knewfilemenu test and underlying reason for its failure
ClosedPublic

Authored by ngraham on Jan 2 2019, 3:47 AM.

Details

Summary

After ef57863a73c0e58b94f9f9f0aa1f4e918d98e79a, the knewfilemenu test started failing. This was for three reasons:

  1. I forgot to run the tests, sorry about that!
  2. The test itself had an error that was being masked by the bug fixed in that commit
  3. KIO::mkdir is a subclass of SimpleJob, and is capable of creating directorties, so the previous code did not emit the correct signals because the SimpleJob condition can result in the job having its newDirectoryURL property set

This patch fixes the above issues by correcting the bug in the test and always checking for the newDirectoryURL property no matter what kind of job it is.

Test Plan
  • All tests now pass
  • Copying files and folders still works

Diff Detail

Repository
R241 KIO
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
ngraham created this revision.Jan 2 2019, 3:47 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptJan 2 2019, 3:47 AM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
ngraham requested review of this revision.Jan 2 2019, 3:47 AM
ngraham updated this revision to Diff 48508.Jan 2 2019, 3:49 AM

Revert unintentional whitespace change

dfaure accepted this revision.Jan 2 2019, 8:43 PM

Tests are good :-)

This revision is now accepted and ready to land.Jan 2 2019, 8:43 PM

Thanks! Does the code change in src/filewidgets/knewfilemenu.cpp make sense to you? I tested a bunch but I know you're the expert here. :)

Tagging is on January 5th, so I'd like to get this in before then. Any objections from anyone if I commit this?

dfaure added a comment.Jan 4 2019, 9:37 PM

Hmm, let me read the unittest more closely.

The scenario is: "New Folder" exists. The user asks to create a new folder, the initial suggestion in the dialog is "New Folder (1)". The user removes the (1), and hits OK, i.e. the user is asking to create "New Folder" again.
The unittest is then just checking that "New Folder" exists, which is kind of broken since it does exist anyway, since that's the initial setup.

But now you're testing that "New Folder (1)" gets created? That seems really odd, it's not what the user is asking for.

Hmm, let me read the unittest more closely.

The scenario is: "New Folder" exists. The user asks to create a new folder, the initial suggestion in the dialog is "New Folder (1)". The user removes the (1), and hits OK, i.e. the user is asking to create "New Folder" again.

This is now an error condition. So maybe the test should check to make sure it fails?

That makes sense. You could set expectedFileName to empty, and change the test code to interpret this as "nothing got created (and possibly: check that we got an error signal, if there's one)"

ngraham updated this revision to Diff 48783.Jan 6 2019, 7:34 AM

Test for failure too

dfaure accepted this revision.Jan 6 2019, 7:13 PM
dfaure added inline comments.
autotests/knewfilemenutest.cpp
170

path.clear() or path = QString() would be better; but ok this is only a unittest ;)

ngraham updated this revision to Diff 48818.Jan 6 2019, 8:55 PM
ngraham marked an inline comment as done.

Minor code fix

ngraham updated this revision to Diff 48819.Jan 6 2019, 8:57 PM

Rebase on current master

ngraham updated this revision to Diff 48820.Jan 6 2019, 8:59 PM

Fix rebase barf

This revision was automatically updated to reflect the committed changes.