Archive for January, 2008
Jan
28

Gotta Look Good

My entire website has had a face lift! There are still some links and such which aren’t going to be working for a little while but for the most part the website is working! A few changes:

  • Easy blog category navigation on the left
  • You can now browse by month and year (archives)
  • Search capabilities! In the upper left box just enter your search query and press enter.
  • Pretty comments. (Hey, it was important to me)
  • Easier to navigate main navigation up top.
  • Easier to read blog entries.

For the most part this was a huge usability update. I loved my old design, but I needed something that was easier to expand, easier to navigate, and more integrated.

Enjoy the new look!

And I understand many pages are broken or missing. This is being looked into and I am fixing the pages one by one. Sorry for the inconvenience! Especially zend screencasts!

Thanks to Thuiven Design for the wonderful look.

time Posted at 5:12 PM | written Written by Mitchell Hashimoto | comments 1 Comment made.
Jan
18

AutoUW: A Preview of What’s To Come.

I mentioned back on new years that I had an automated registration tool for the university of washington coming. This is not a lie. I am here today to show you a bunch of preview screenshots of AutoUW and exactly how it works. AutoUW is easy to use and is very reliable. I used this tool this quarter to grab a couple of my classes and it worked wonders. AutoUW will not drop courses for you. This is for your own security. AutoUW will only add courses. :) When will it be available? Before next quarter. :) That is all.

To see all the screenshots and AutoUW in all its glory, then click read more at the end of this post!

Read more…

time Posted at 3:00 PM | written Written by Mitchell Hashimoto | comments 2 Comments made.
Jan
9

My UW Notifier Blocked! Temporarily ;]

So my program has an automatic internal test suite built into it which runs once a day, just to make sure that it is working correctly, which it has been for the past couple months. I was surprised today to receive a text message from my application which said it was “broken!” Further research and it seems that MyUW now forces you to log in to view SLN information. This renders my UW notifier broken, for the time being.

Lucky for you guys, and unlucky for UW, I already have the code written to automate logging in. So, sorry if you’re waiting for a text message for a class opening now, because you won’t get it.

But I promise this program will be completely up and running before next quarter. :) They can’t stop us that easily.

time Posted at 3:31 PM | written Written by Mitchell Hashimoto | comments 1 Comment made.
Jan
9

Unit Testing WebView Objects in Cocoa

Another subject which revealed no results in Google for me was how I was supposed to possibly test my models which interfaced with the web. My models use a WebView object to talk with various servers (for my UW auto registration program). Like I said in a previous post, I have implemented quite a bit of unit testing to make sure that my code continues to run smoothly. However recently when I was writing some more testing code, I realized the most important thing of all was not being unit tested: the MyUW interfacing.

Let me give a bit of a run through of what the process for using a WebView is, at least with my objects. I set my model to be a WebView’s delegate, make a request, and wait for the WebView to kick back a webView:didFinishLoadingForFrame: method. What this means is that all my web requests are asynchronous, and do not freeze up the main thread or GUI thread, which is why my program is able to run so smoothly. But this blessing is also a curse. Because the requests to my model return immediately (and a delegate call is made later to report the completion of a request), my tests also complete immediately.

For those not familiar with unit testing, let me show you a method from one of my unit tests which checks the MyUW authenticator:

- (void) testLoginDoesWorkWhenShouldWork
{	
	expectedResult = YES;
	[auth authenticateWithId:GOODUSER usingPassword:GOODPASS];
 
	// OH NO! How do I test the result?!
}

As you can see, the test ends… without being able to assert the result I needed to get. My first thought was to use a separate thread to run the authenticator class… which I tried. And this didn’t work. I was stumped! A bit more debugging revealed that the WebView was not even loading the URL!!! WHY?!! (These capitalizations do not even begin to correctly represent the frustration I was experiencing at this point.)

Now, let me tell you a strange fact about myself: When I have a problem, I have a very convenient way of solving it in my sleep. So when I woke up this morning, I was more or less not surprised that the solution was so clear in my head: Because the WebView is event-driven, I need to initialized a Run Loop, or else the events won’t be processed! And because this code is running within a unit test thread, and not within an NSApplication, I didn’t have the luxury of a run loop being made for me (NSApplication creates a run loop for you).

So here is the final code (more or less, I removed some method calls and copied them into this code to make it easier to read) which successfully tests the code:

- (void) testLoginDoesWorkWhenShouldWork
{	
	// 1.) Run the authentication with the expected result being a success
	expectedResult = YES;
	[auth authenticateWithId:GOODUSER usingPassword:GOODPASS];
 
	// 2.) Initialize and loop an NSRunLoop UNTIL WE GET THE RESULT
	// The gotResult flag is modified in the delegate method below...
	gotResult = NO;
	BOOL isRunning;
	do {
		NSDate* next = [NSDate dateWithTimeIntervalSinceNow:1.0];
		isRunning = [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
											 beforeDate:next];
	} while (isRunning && !gotResult);
}
 
// This method is called by the MyUW authenticator object automatically
// when the authentication is complete. Result is a boolean which is... obviously...
// the result.
- (void) didFinishAuthenticating:(BOOL)result
{
	STAssertEquals(expectedResult, result, @"Authentication did not get the expected result.");
	gotResult = YES;
}

I hope this helps relieve some headache for people in the future.

time Posted at 1:03 PM | written Written by Mitchell Hashimoto | comments 1 Comment made.
Jan
7

Using OCMock with Xcode 3 in Leopard

I recently ran into another “programmer’s block” similar to when I was trying to get SVN working with mediatemple. So I am posting this to share my solution.

I am a big fan of unit testing, always have been, but I am not a test driven developer. I merely like including as many unit tests to test my code as possible. It makes me feel better about what I write. So, recently, with my ever-growing cocoa apps (see post below), I decided to begin including unit tests so that I feel better about the growth. Along with unit tests I needed mock objects to simulate a WebView for my models. Although the SenTeskingKit is included with XCode, OCMock, the mock object framework, is not.

Although I got unit testing working very easily following this guide here, I was having a lot of trouble getting the OCMock framework working. I first tried copying the framework into my project folder and linking it within the unit tests target, but that didn’t work. It would cause my app to hang. After checking the logs, I saw this:

/Developer/Tools/RunUnitTests:209: note: Running tests for architecture 'i386'
2008-01-07 18:50:59.461 AutoUW[2405:10b] Error loading /Users/mitchellh/Desktop/AutoUW/build/Debug/UnitTests.octest/Contents/MacOS/UnitTests:  dlopen(/Users/mitchellh/Desktop/AutoUW/build/Debug/UnitTests.octest/Contents/MacOS/UnitTests, 262): Library not loaded: /Library/Frameworks/OCMock.framework/Versions/A/OCMock
  Referenced from: /Users/mitchellh/Desktop/AutoUW/build/Debug/UnitTests.octest/Contents/MacOS/UnitTests
  Reason: image not found

Even though I was adding the project directory the fallback framework path, it wasn’t searching it. I’m still not sure why. But anyways, if you follow the error and just add the OCMock.framework file to the /Library/Frameworks directory and compile, it works fine.

I hope this helped anyone else that may be having this issue.

time Posted at 7:52 PM | written Written by Mitchell Hashimoto | comments 2 Comments made.